From b1ea699fd8d2663f5436d420d6e006b982f49554 Mon Sep 17 00:00:00 2001 From: kuba6000 Date: Sun, 9 Oct 2022 16:14:32 +0200 Subject: [PATCH] Hide items, add info in tooltip --- dependencies.gradle | 2 +- .../scala/net/bdew/gendustry/config/Items.scala | 4 ++-- .../bdew/gendustry/custom/CustomUpgradeFrame.scala | 14 ++++++++++++++ .../gendustry/machines/apiary/BlockApiary.scala | 3 ++- .../apiary/upgrades/ItemApiaryUpgrade.scala | 6 +++--- .../net/bdew/gendustry/nei/BaseRecipeHandler.scala | 4 ++-- .../net/bdew/gendustry/nei/ExtractorHandler.scala | 2 +- .../net/bdew/gendustry/nei/ImprinterHandler.scala | 2 +- .../net/bdew/gendustry/nei/MutatronHandler.scala | 2 +- .../bdew/gendustry/nei/NEIGendustryConfig.scala | 14 ++++++++++++++ .../net/bdew/gendustry/nei/SamplerHandler.scala | 2 +- .../gendustry/nei/SmeltingTooltipHandler.scala | 4 ++-- .../net/bdew/gendustry/nei/TransposerHandler.scala | 2 +- 13 files changed, 45 insertions(+), 16 deletions(-) create mode 100644 src/main/scala/net/bdew/gendustry/custom/CustomUpgradeFrame.scala diff --git a/dependencies.gradle b/dependencies.gradle index 0b73450..deae5f5 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -2,7 +2,7 @@ dependencies { compile("com.github.GTNewHorizons:CodeChickenLib:1.1.5.1:dev") - compile("com.github.GTNewHorizons:NotEnoughItems:2.1.22-GTNH:dev") + compile("com.github.GTNewHorizons:NotEnoughItems:2.3.7-GTNH:dev") compile("com.github.GTNewHorizons:bdlib:1.9.6:dev") compile("com.github.GTNewHorizons:ForestryMC:4.4.4:dev") { exclude group: "net.industrial-craft", module: "industrialcraft-2" diff --git a/src/main/scala/net/bdew/gendustry/config/Items.scala b/src/main/scala/net/bdew/gendustry/config/Items.scala index 11889f7..e83083b 100644 --- a/src/main/scala/net/bdew/gendustry/config/Items.scala +++ b/src/main/scala/net/bdew/gendustry/config/Items.scala @@ -11,7 +11,7 @@ package net.bdew.gendustry.config import net.bdew.gendustry.Gendustry import net.bdew.gendustry.compat.ForestryHelper -import net.bdew.gendustry.custom.{CustomHoneyComb, CustomHoneyDrop} +import net.bdew.gendustry.custom.{CustomHoneyComb, CustomHoneyDrop, CustomUpgradeFrame} import net.bdew.gendustry.items._ import net.bdew.gendustry.items.covers.{EjectCover, ErrorSensorCover, ImportCover} import net.bdew.gendustry.machines.apiary.upgrades.ItemApiaryUpgrade @@ -39,7 +39,7 @@ object Items extends ItemManager(GendustryCreativeTabs.main) { regSimpleItem("PowerModule") regSimpleItem("GeneticsProcessor") regSimpleItem("EnvProcessor") - regSimpleItem("UpgradeFrame") + regItem(CustomUpgradeFrame) regSimpleItem("ClimateModule") if (ForestryHelper.haveRoot("Trees")) { diff --git a/src/main/scala/net/bdew/gendustry/custom/CustomUpgradeFrame.scala b/src/main/scala/net/bdew/gendustry/custom/CustomUpgradeFrame.scala new file mode 100644 index 0000000..db02504 --- /dev/null +++ b/src/main/scala/net/bdew/gendustry/custom/CustomUpgradeFrame.scala @@ -0,0 +1,14 @@ +package net.bdew.gendustry.custom + +import net.bdew.lib.items.SimpleItem +import net.minecraft.entity.player.EntityPlayer +import net.minecraft.item.ItemStack +import net.minecraft.util.EnumChatFormatting + +import java.util + +object CustomUpgradeFrame extends SimpleItem("UpgradeFrame"){ + override def addInformation(p_77624_1_ : ItemStack, p_77624_2_ : EntityPlayer, p_77624_3_ : util.List[_], p_77624_4_ : Boolean): Unit ={ + p_77624_3_.asInstanceOf[util.List[String]].add(EnumChatFormatting.RED + "DEPRECATED: Put in crafting table to get back !") + } +} diff --git a/src/main/scala/net/bdew/gendustry/machines/apiary/BlockApiary.scala b/src/main/scala/net/bdew/gendustry/machines/apiary/BlockApiary.scala index 0e0cc4a..ff1b0e8 100644 --- a/src/main/scala/net/bdew/gendustry/machines/apiary/BlockApiary.scala +++ b/src/main/scala/net/bdew/gendustry/machines/apiary/BlockApiary.scala @@ -21,7 +21,7 @@ import net.minecraft.block.Block import net.minecraft.client.renderer.texture.IIconRegister import net.minecraft.entity.player.{EntityPlayer, EntityPlayerMP} import net.minecraft.item.ItemStack -import net.minecraft.util.IIcon +import net.minecraft.util.{EnumChatFormatting, IIcon} import net.minecraft.world.{IBlockAccess, World} object BlockApiary extends Block(MachineMaterial) with HasTE[TileApiary] with BlockCoverable[TileApiary] with BlockGuiWrenchable with BlockTooltip with BlockKeepData { @@ -52,6 +52,7 @@ object BlockApiary extends Block(MachineMaterial) with HasTE[TileApiary] with Bl } override def getTooltip(stack: ItemStack, player: EntityPlayer, advanced: Boolean): List[String] = { + return List(EnumChatFormatting.RED + "DEPRECATED: Put in crafting table to get back !") if (stack.hasTagCompound && stack.getTagCompound.hasKey("data")) { val data = stack.getTagCompound.getCompoundTag("data") val inv = BlockTooltipHelper.getInventory(data) diff --git a/src/main/scala/net/bdew/gendustry/machines/apiary/upgrades/ItemApiaryUpgrade.scala b/src/main/scala/net/bdew/gendustry/machines/apiary/upgrades/ItemApiaryUpgrade.scala index 98d7bfa..a02bda0 100644 --- a/src/main/scala/net/bdew/gendustry/machines/apiary/upgrades/ItemApiaryUpgrade.scala +++ b/src/main/scala/net/bdew/gendustry/machines/apiary/upgrades/ItemApiaryUpgrade.scala @@ -10,7 +10,6 @@ package net.bdew.gendustry.machines.apiary.upgrades import java.util - import cpw.mods.fml.relauncher.{Side, SideOnly} import net.bdew.gendustry.Gendustry import net.bdew.gendustry.api.ApiaryModifiers @@ -21,7 +20,7 @@ import net.minecraft.client.renderer.texture.IIconRegister import net.minecraft.creativetab.CreativeTabs import net.minecraft.entity.player.EntityPlayer import net.minecraft.item.{Item, ItemStack} -import net.minecraft.util.IIcon +import net.minecraft.util.{EnumChatFormatting, IIcon} object ItemApiaryUpgrade extends Item with IApiaryUpgrade with NamedItem { var icons = Map.empty[Int, IIcon] @@ -84,7 +83,8 @@ object ItemApiaryUpgrade extends Item with IApiaryUpgrade with NamedItem { def getStackingId(stack: ItemStack) = Item.getIdFromItem(this) * Int.MaxValue + stack.getItemDamage override def addInformation(stack: ItemStack, player: EntityPlayer, list: util.List[_], par4: Boolean) { - list.asInstanceOf[util.List[String]].addAll(getDisplayDetails(stack)) + //list.asInstanceOf[util.List[String]].addAll(getDisplayDetails(stack)) + list.asInstanceOf[util.List[String]].add(EnumChatFormatting.RED + "DEPRECATED: Put in crafting table to get back !") } def getMaxNumber(stack: ItemStack): Int = { diff --git a/src/main/scala/net/bdew/gendustry/nei/BaseRecipeHandler.scala b/src/main/scala/net/bdew/gendustry/nei/BaseRecipeHandler.scala index 4faf6ff..9acbd14 100644 --- a/src/main/scala/net/bdew/gendustry/nei/BaseRecipeHandler.scala +++ b/src/main/scala/net/bdew/gendustry/nei/BaseRecipeHandler.scala @@ -39,14 +39,14 @@ abstract class BaseRecipeHandler(val offX: Int, val offY: Int) extends TemplateR super.drawExtras(recipe) } - override def mouseClicked(gui: GuiRecipe, button: Int, recipe: Int): Boolean = { + override def mouseClicked(gui: GuiRecipe[_], button: Int, recipe: Int): Boolean = { val relative = getMousePosition - gui.getRecipePosition(recipe) +(offX, offY) -(gui.guiLeft, gui.guiTop) for (component <- arecipes.get(recipe).asInstanceOf[CachedRecipeWithComponents].components) if (component.rect.contains(relative) && component.mouseClick(button)) return true super.mouseClicked(gui, button, recipe) } - override def handleTooltip(gui: GuiRecipe, tip: util.List[String], recipe: Int) = { + override def handleTooltip(gui: GuiRecipe[_], tip: util.List[String], recipe: Int) = { import scala.collection.JavaConversions._ val relative = getMousePosition - gui.getRecipePosition(recipe) +(offX, offY) -(gui.guiLeft, gui.guiTop) for (component <- arecipes.get(recipe).asInstanceOf[CachedRecipeWithComponents].components) diff --git a/src/main/scala/net/bdew/gendustry/nei/ExtractorHandler.scala b/src/main/scala/net/bdew/gendustry/nei/ExtractorHandler.scala index e2d7c03..c97439e 100644 --- a/src/main/scala/net/bdew/gendustry/nei/ExtractorHandler.scala +++ b/src/main/scala/net/bdew/gendustry/nei/ExtractorHandler.scala @@ -103,7 +103,7 @@ class ExtractorHandler extends BaseRecipeHandler(5, 13) { } } - override def handleItemTooltip(gui: GuiRecipe, stack: ItemStack, tip: util.List[String], recipe: Int): util.List[String] = { + override def handleItemTooltip(gui: GuiRecipe[_], stack: ItemStack, tip: util.List[String], recipe: Int): util.List[String] = { if (stack == getRecipe(recipe).labware.item) tip.add(Misc.toLocalF("gendustry.label.consume", MachineExtractor.labwareConsumeChance.toInt)) super.handleItemTooltip(gui, stack, tip, recipe) diff --git a/src/main/scala/net/bdew/gendustry/nei/ImprinterHandler.scala b/src/main/scala/net/bdew/gendustry/nei/ImprinterHandler.scala index 6c0c370..3b16e86 100644 --- a/src/main/scala/net/bdew/gendustry/nei/ImprinterHandler.scala +++ b/src/main/scala/net/bdew/gendustry/nei/ImprinterHandler.scala @@ -100,7 +100,7 @@ class ImprinterHandler extends BaseRecipeHandler(5, 13) { } } - override def handleItemTooltip(gui: GuiRecipe, stack: ItemStack, tip: util.List[String], recipe: Int): util.List[String] = { + override def handleItemTooltip(gui: GuiRecipe[_], stack: ItemStack, tip: util.List[String], recipe: Int): util.List[String] = { if (stack == getRecipe(recipe).labware.item) tip += Misc.toLocalF("gendustry.label.consume", MachineImprinter.labwareConsumeChance.toInt) super.handleItemTooltip(gui, stack, tip, recipe) diff --git a/src/main/scala/net/bdew/gendustry/nei/MutatronHandler.scala b/src/main/scala/net/bdew/gendustry/nei/MutatronHandler.scala index 1cabe0d..f608bf5 100644 --- a/src/main/scala/net/bdew/gendustry/nei/MutatronHandler.scala +++ b/src/main/scala/net/bdew/gendustry/nei/MutatronHandler.scala @@ -121,7 +121,7 @@ class MutatronHandler extends BaseRecipeHandler(5, 13) { } } - override def handleItemTooltip(gui: GuiRecipe, stack: ItemStack, tip: util.List[String], recipe: Int): util.List[String] = { + override def handleItemTooltip(gui: GuiRecipe[_], stack: ItemStack, tip: util.List[String], recipe: Int): util.List[String] = { if (stack == getRecipe(recipe).labware.item) tip += Misc.toLocalF("gendustry.label.consume", MachineMutatron.labwareConsumeChance.toInt) if (stack == getRecipe(recipe).getResult.item) { diff --git a/src/main/scala/net/bdew/gendustry/nei/NEIGendustryConfig.scala b/src/main/scala/net/bdew/gendustry/nei/NEIGendustryConfig.scala index 8639cca..5ff96f2 100644 --- a/src/main/scala/net/bdew/gendustry/nei/NEIGendustryConfig.scala +++ b/src/main/scala/net/bdew/gendustry/nei/NEIGendustryConfig.scala @@ -15,7 +15,10 @@ import codechicken.nei.recipe.{ICraftingHandler, IUsageHandler} import cpw.mods.fml.common.event.FMLInterModComms import net.bdew.gendustry.Gendustry import net.bdew.gendustry.config.Config +import net.bdew.gendustry.custom.CustomUpgradeFrame import net.bdew.gendustry.items.GeneSample +import net.bdew.gendustry.machines.apiary.BlockApiary +import net.bdew.gendustry.machines.apiary.upgrades.ItemApiaryUpgrade import net.bdew.gendustry.machines.extractor.MachineExtractor import net.bdew.gendustry.machines.imprinter.MachineImprinter import net.bdew.gendustry.machines.liquifier.MachineLiquifier @@ -25,6 +28,10 @@ import net.bdew.gendustry.machines.replicator.MachineReplicator import net.bdew.gendustry.machines.sampler.MachineSampler import net.bdew.gendustry.machines.transposer.MachineTransposer import net.bdew.gendustry.misc.GeneticsCache +import net.minecraft.item.ItemStack + +import java.util +import scala.collection.JavaConverters.collectionAsScalaIterableConverter class NEIGendustryConfig extends IConfigureNEI { def getName: String = "Gendustry" @@ -82,5 +89,12 @@ class NEIGendustryConfig extends IConfigureNEI { } GuiContainerManager.addTooltipHandler(new SmeltingTooltipHandler) + + API.hideItem(new ItemStack(BlockApiary)) + val upgradelist = new util.ArrayList[ItemStack]() + ItemApiaryUpgrade.getSubItems(null, null, upgradelist) + for(i <- upgradelist.asScala.toList) + API.hideItem(i) + API.hideItem(new ItemStack(CustomUpgradeFrame)) } } diff --git a/src/main/scala/net/bdew/gendustry/nei/SamplerHandler.scala b/src/main/scala/net/bdew/gendustry/nei/SamplerHandler.scala index e4d7603..321af2e 100644 --- a/src/main/scala/net/bdew/gendustry/nei/SamplerHandler.scala +++ b/src/main/scala/net/bdew/gendustry/nei/SamplerHandler.scala @@ -105,7 +105,7 @@ import scala.collection.JavaConversions._ } } - override def handleItemTooltip(gui: GuiRecipe, stack: ItemStack, tip: util.List[String], recipe: Int): util.List[String] = { + override def handleItemTooltip(gui: GuiRecipe[_], stack: ItemStack, tip: util.List[String], recipe: Int): util.List[String] = { if (stack == getRecipe(recipe).labware.item) tip += Misc.toLocalF("gendustry.label.consume", MachineSampler.labwareConsumeChance.toInt) super.handleItemTooltip(gui, stack, tip, recipe) diff --git a/src/main/scala/net/bdew/gendustry/nei/SmeltingTooltipHandler.scala b/src/main/scala/net/bdew/gendustry/nei/SmeltingTooltipHandler.scala index 832a14d..f21b045 100644 --- a/src/main/scala/net/bdew/gendustry/nei/SmeltingTooltipHandler.scala +++ b/src/main/scala/net/bdew/gendustry/nei/SmeltingTooltipHandler.scala @@ -22,8 +22,8 @@ class SmeltingTooltipHandler extends IContainerTooltipHandler { override def handleItemDisplayName(gui: GuiContainer, stack: ItemStack, tip: util.List[String]) = tip override def handleTooltip(gui: GuiContainer, mouseX: Int, mouseY: Int, tip: util.List[String]) = tip override def handleItemTooltip(gui: GuiContainer, itemStack: ItemStack, mouseX: Int, mouseY: Int, tip: util.List[String]) = { - if (gui.isInstanceOf[GuiRecipe] && itemStack != null) { - val gr = gui.asInstanceOf[GuiRecipe] + if (gui.isInstanceOf[GuiRecipe[_]] && itemStack != null) { + val gr = gui.asInstanceOf[GuiRecipe[_]] val handler = gr.currenthandlers.get(gr.recipetype) if (handler.isInstanceOf[FurnaceRecipeHandler]) { if (itemStack.getItem == GeneSample) diff --git a/src/main/scala/net/bdew/gendustry/nei/TransposerHandler.scala b/src/main/scala/net/bdew/gendustry/nei/TransposerHandler.scala index bbf2c2f..52922ea 100644 --- a/src/main/scala/net/bdew/gendustry/nei/TransposerHandler.scala +++ b/src/main/scala/net/bdew/gendustry/nei/TransposerHandler.scala @@ -108,7 +108,7 @@ class TransposerHandler extends BaseRecipeHandler(5, 13) { } } - override def handleItemTooltip(gui: GuiRecipe, stack: ItemStack, tip: util.List[String], recipe: Int): util.List[String] = { + override def handleItemTooltip(gui: GuiRecipe[_], stack: ItemStack, tip: util.List[String], recipe: Int): util.List[String] = { if (stack == getRecipe(recipe).labware.item) tip += Misc.toLocalF("gendustry.label.consume", MachineTransposer.labwareConsumeChance.toInt) super.handleItemTooltip(gui, stack, tip, recipe)