diff --git a/src/main/java/techreborn/client/RegisterItemJsons.java b/src/main/java/techreborn/client/RegisterItemJsons.java index 815143890..ce371017f 100644 --- a/src/main/java/techreborn/client/RegisterItemJsons.java +++ b/src/main/java/techreborn/client/RegisterItemJsons.java @@ -39,7 +39,6 @@ import techreborn.config.ConfigTechReborn; import techreborn.init.ModBlocks; import techreborn.init.TRItems; import techreborn.init.TRIngredients; -import techreborn.items.*; import techreborn.lib.ModInfo; import java.util.Map; @@ -51,37 +50,47 @@ public class RegisterItemJsons { } private static void registerItems() { + TRIngredients.registerModel(); + + // Armor + register(TRItems.CLOAKING_DEVICE, "tool/cloaking_device"); + register(TRItems.LAPOTRONIC_ORB_PACK, "tool/lapotronic_orbpack"); + register(TRItems.LITHIUM_BATTERY_PACK, "tool/lithium_batpack"); + + // Battery register(TRItems.RE_BATTERY, "battery/re_battery"); register(TRItems.LITHIUM_BATTERY, "battery/lithium_battery"); register(TRItems.ENERGY_CRYSTAL, "battery/energy_crystal"); register(TRItems.LAPOTRONIC_CRYSTAL, "battery/lapotron_crystal"); register(TRItems.LAPOTRONIC_ORB, "battery/lapotronic_orb"); - + + // Tools + register(TRItems.ADVANCED_CHAINSAW, "tool/advanced_chainsaw"); + register(TRItems.ADVANCED_DRILL, "tool/advanced_drill"); + register(TRItems.ADVANCED_JACKHAMMER, "tool/advanced_jackhammer"); + register(TRItems.DEBUG, "misc/debug"); + register(TRItems.DIAMOND_CHAINSAW, "tool/diamond_chainsaw"); + register(TRItems.DIAMOND_DRILL, "tool/diamond_drill"); + register(TRItems.DIAMOND_JACKHAMMER, "tool/diamond_jackhammer"); + register(TRItems.ELECTRIC_TREE_TAP, "tool/electric_treetap"); + register(TRItems.NANOSABER, "tool/nanosaber"); + register(TRItems.OMNI_TOOL, "tool/omni_tool"); + register(TRItems.ROCK_CUTTER, "tool/rock_cutter"); + register(TRItems.STEEL_CHAINSAW, "tool/steel_chainsaw"); + register(TRItems.STEEL_DRILL, "tool/steel_drill"); + register(TRItems.STEEL_JACKHAMMER, "tool/steel_jackhammer"); + register(TRItems.TREE_TAP, "tool/treetap"); + register(TRItems.WRENCH, "tool/wrench"); + + // Other register(TRItems.FREQUENCY_TRANSMITTER, "misc/frequency_transmitter"); register(TRItems.SCRAP_BOX, "misc/scrapbox"); register(TRItems.MANUAL, "misc/manual"); - register(TRItems.DEBUG, "misc/debug"); - register(ModBlocks.RUBBER_SAPLING, "misc/rubber_sapling"); - - register(TRItems.STEEL_DRILL, "tool/steel_drill"); - register(TRItems.DIAMOND_DRILL, "tool/diamond_drill"); - register(TRItems.ADVANCED_DRILL, "tool/advanced_drill"); - register(TRItems.STEEL_CHAINSAW, "tool/steel_chainsaw"); - register(TRItems.DIAMOND_CHAINSAW, "tool/diamond_chainsaw"); - register(TRItems.ADVANCED_CHAINSAW, "tool/advanced_chainsaw"); - register(TRItems.STEEL_JACKHAMMER, "tool/steel_jackhammer"); - register(TRItems.DIAMOND_JACKHAMMER, "tool/diamond_jackhammer"); - register(TRItems.ADVANCED_JACKHAMMER, "tool/advanced_jackhammer"); - register(TRItems.NANOSABER, "tool/nanosaber"); - register(TRItems.TREE_TAP, "tool/treetap"); - register(TRItems.ELECTRIC_TREE_TAP, "tool/electric_treetap"); - register(TRItems.CLOAKING_DEVICE, "tool/cloaking_device"); - register(TRItems.OMNI_TOOL, "tool/omni_tool"); - register(TRItems.ROCK_CUTTER, "tool/rock_cutter"); - register(TRItems.WRENCH, "tool/wrench"); - register(TRItems.LAPOTRONIC_ORB_PACK, "tool/lapotronic_orbpack"); - register(TRItems.LITHIUM_BATTERY_PACK, "tool/lithium_batpack"); - + registerBlockstateMultiItem(TRItems.UPGRADE_OVERCLOCKER, 0, "overclock", "items/misc/upgrades"); + registerBlockstateMultiItem(TRItems.UPGRADE_TRANSFORMER, 0, "transformer", "items/misc/upgrades"); + registerBlockstateMultiItem(TRItems.UPGRADE_ENERGY_STORAGE, 0, "energy_storage", "items/misc/upgrades"); + + // Gem armor & tools if (ConfigTechReborn.enableGemArmorAndTools) { registerBlockstateMultiItem(TRItems.RUBY_HELMET, "ruby_helmet", "items/tool/armour"); registerBlockstateMultiItem(TRItems.RUBY_CHESTPLATE, "ruby_chestplate", "items/tool/armour"); @@ -122,12 +131,8 @@ public class RegisterItemJsons { registerBlockstateMultiItem(TRItems.BRONZE_HOE, "bronze_hoe", "items/tool/tool"); } - TRIngredients.registerModel(); - - String[] name = ItemUpgrades.types.clone(); - for (int i = 0; i < ItemUpgrades.types.length; ++i) { - registerBlockstate(TRItems.UPGRADES, i, name[i], "items/misc/"); - } + + register(ModBlocks.RUBBER_SAPLING, "misc/rubber_sapling"); for (EnumCableType cableType : EnumCableType.values()) { registerBlockstateMultiItem(Item.getItemFromBlock(ModBlocks.CABLE), cableType.ordinal(), cableType.getName().toLowerCase(), "cable_inv"); diff --git a/src/main/java/techreborn/client/gui/GuiManual.java b/src/main/java/techreborn/client/gui/GuiManual.java index c5c3abf0e..7d25ccdda 100644 --- a/src/main/java/techreborn/client/gui/GuiManual.java +++ b/src/main/java/techreborn/client/gui/GuiManual.java @@ -30,7 +30,7 @@ import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; -import techreborn.items.tools.ItemTechManual; +import techreborn.items.ItemTechManual; import java.awt.*; diff --git a/src/main/java/techreborn/init/SubItemRetriever.java b/src/main/java/techreborn/init/SubItemRetriever.java index 39939c11b..d914f72cc 100644 --- a/src/main/java/techreborn/init/SubItemRetriever.java +++ b/src/main/java/techreborn/init/SubItemRetriever.java @@ -137,12 +137,14 @@ public class SubItemRetriever implements ISubItemRetriever { @Override public ItemStack getUpgradeByName(String name) { - return ItemUpgrades.getUpgradeByName(name); +// return ItemUpgrades.getUpgradeByName(name); + return null; } @Override public ItemStack getUpgradeByName(String name, int count) { - return ItemUpgrades.getUpgradeByName(name, count); +// return ItemUpgrades.getUpgradeByName(name, count); + return null; } @Override diff --git a/src/main/java/techreborn/init/TRItems.java b/src/main/java/techreborn/init/TRItems.java index 23d2ff150..5c6e6f3ef 100644 --- a/src/main/java/techreborn/init/TRItems.java +++ b/src/main/java/techreborn/init/TRItems.java @@ -34,10 +34,13 @@ import techreborn.Core; import techreborn.api.Reference; import techreborn.blocks.BlockMachineFrames; import techreborn.config.ConfigTechReborn; +import techreborn.events.TRRecipeHandler; import techreborn.items.*; import techreborn.items.armor.*; import techreborn.items.battery.*; import techreborn.items.tools.*; +import techreborn.lib.ModInfo; + import javax.annotation.Nullable; public class TRItems { @@ -69,7 +72,6 @@ public class TRItems { public static Item STEEL_CHAINSAW; public static Item STEEL_DRILL; public static Item STEEL_JACKHAMMER; - public static Item MANUAL; public static Item TREE_TAP; public static Item WRENCH; @@ -77,7 +79,10 @@ public class TRItems { public static DynamicCell CELL; public static Item FREQUENCY_TRANSMITTER; public static Item SCRAP_BOX; - public static Item UPGRADES; + public static Item MANUAL; + public static Item UPGRADE_OVERCLOCKER; + public static Item UPGRADE_TRANSFORMER; + public static Item UPGRADE_ENERGY_STORAGE; // Gem armor & tools @Nullable @@ -221,9 +226,13 @@ public class TRItems { registerItem(FREQUENCY_TRANSMITTER, "frequencyTransmitter"); SCRAP_BOX = new ItemScrapBox(); registerItem(SCRAP_BOX, "scrapbox"); - UPGRADES = new ItemUpgrades(); - registerItem(UPGRADES, "upgrades"); - + UPGRADE_OVERCLOCKER = new ItemUpgrades(); + registerItem(UPGRADE_OVERCLOCKER, "upgrade_overclocker"); + UPGRADE_TRANSFORMER = new ItemUpgrades(); + registerItem(UPGRADE_TRANSFORMER, "upgrade_transformer"); + UPGRADE_ENERGY_STORAGE = new ItemUpgrades(); + registerItem(UPGRADE_ENERGY_STORAGE, "upgrade_energystorage"); + // Gem armor & tools if (ConfigTechReborn.enableGemArmorAndTools) { BRONZE_SWORD = new ItemTRSword(Reference.BRONZE, "ingotBronze"); @@ -314,6 +323,8 @@ public class TRItems { public static void registerItem(Item item, String name) { item.setRegistryName(name); + item.setTranslationKey(ModInfo.MOD_ID + "." + name); + TRRecipeHandler.hideEntry(item); RebornRegistry.registerItem(item); } diff --git a/src/main/java/techreborn/init/recipes/CraftingTableRecipes.java b/src/main/java/techreborn/init/recipes/CraftingTableRecipes.java index 9fe406c62..3fdcc15c1 100644 --- a/src/main/java/techreborn/init/recipes/CraftingTableRecipes.java +++ b/src/main/java/techreborn/init/recipes/CraftingTableRecipes.java @@ -95,11 +95,11 @@ public class CraftingTableRecipes extends RecipeMethods { } //Upgrades - registerShaped(ItemUpgrades.getUpgradeByName("energy_storage"), "PPP", "WBW", "PCP", 'P', "plankWood", 'W', EnumCableType.ICOPPER.getStack(), 'C', "circuitBasic", 'B', "reBattery"); - registerShaped(ItemUpgrades.getUpgradeByName("overclock"), "TTT", "WCW", 'T', TRIngredients.Parts.COOLANT_SIMPLE.getStack(), 'W', EnumCableType.ICOPPER.getStack(), 'C', "circuitBasic"); - registerShaped(ItemUpgrades.getUpgradeByName("overclock", 2), " T ", "WCW", 'T', TRIngredients.Parts.HELIUM_COOLANT_TRIPLE.getStack(), 'W', EnumCableType.ICOPPER.getStack(), 'C', "circuitBasic"); - registerShaped(ItemUpgrades.getUpgradeByName("overclock", 2), " T ", "WCW", 'T', TRIngredients.Parts.NAK_COOLANT_SIMPLE.getStack(), 'W', EnumCableType.ICOPPER.getStack(), 'C', "circuitBasic"); - registerShaped(ItemUpgrades.getUpgradeByName("transformer"), "GGG", "WTW", "GCG", 'G', "blockGlass", 'W', EnumCableType.IGOLD.getStack(), 'C', "circuitBasic", 'T', getStack(ModBlocks.MV_TRANSFORMER)); +// registerShaped(ItemUpgrades.getUpgradeByName("energy_storage"), "PPP", "WBW", "PCP", 'P', "plankWood", 'W', EnumCableType.ICOPPER.getStack(), 'C', "circuitBasic", 'B', "reBattery"); +// registerShaped(ItemUpgrades.getUpgradeByName("overclock"), "TTT", "WCW", 'T', TRIngredients.Parts.COOLANT_SIMPLE.getStack(), 'W', EnumCableType.ICOPPER.getStack(), 'C', "circuitBasic"); +// registerShaped(ItemUpgrades.getUpgradeByName("overclock", 2), " T ", "WCW", 'T', TRIngredients.Parts.HELIUM_COOLANT_TRIPLE.getStack(), 'W', EnumCableType.ICOPPER.getStack(), 'C', "circuitBasic"); +// registerShaped(ItemUpgrades.getUpgradeByName("overclock", 2), " T ", "WCW", 'T', TRIngredients.Parts.NAK_COOLANT_SIMPLE.getStack(), 'W', EnumCableType.ICOPPER.getStack(), 'C', "circuitBasic"); +// registerShaped(ItemUpgrades.getUpgradeByName("transformer"), "GGG", "WTW", "GCG", 'G', "blockGlass", 'W', EnumCableType.IGOLD.getStack(), 'C', "circuitBasic", 'T', getStack(ModBlocks.MV_TRANSFORMER)); //Machines registerShapeless(getStack(ModBlocks.SOLID_FUEL_GENEREATOR), "reBattery", "machineBlockBasic", getStack(Blocks.FURNACE)); diff --git a/src/main/java/techreborn/init/recipes/RecipeMethods.java b/src/main/java/techreborn/init/recipes/RecipeMethods.java index a7d4071c9..802468564 100644 --- a/src/main/java/techreborn/init/recipes/RecipeMethods.java +++ b/src/main/java/techreborn/init/recipes/RecipeMethods.java @@ -66,8 +66,8 @@ public abstract class RecipeMethods { return BlockMachineFrames.getFrameByName(name, count); } else if (type == Type.MACHINE_CASING) { return BlockMachineCasing.getStackByName(name, count); - } else if (type == Type.UPGRADE) { - return ItemUpgrades.getUpgradeByName(name, count); +// } else if (type == Type.UPGRADE) { +// return ItemUpgrades.getUpgradeByName(name, count); } else if (type == Type.ORE) { return BlockOre.getOreByName(name, count); } diff --git a/src/main/java/techreborn/items/tools/ItemTechManual.java b/src/main/java/techreborn/items/ItemTechManual.java similarity index 97% rename from src/main/java/techreborn/items/tools/ItemTechManual.java rename to src/main/java/techreborn/items/ItemTechManual.java index f9ec8da13..dbd4c4e9f 100644 --- a/src/main/java/techreborn/items/tools/ItemTechManual.java +++ b/src/main/java/techreborn/items/ItemTechManual.java @@ -22,7 +22,7 @@ * SOFTWARE. */ -package techreborn.items.tools; +package techreborn.items; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -32,7 +32,6 @@ import net.minecraft.util.EnumHand; import net.minecraft.world.World; import techreborn.Core; import techreborn.client.EGui; -import techreborn.items.ItemTR; import techreborn.utils.TechRebornCreativeTab; public class ItemTechManual extends ItemTR { diff --git a/src/main/java/techreborn/items/ItemUpgrades.java b/src/main/java/techreborn/items/ItemUpgrades.java index 42fb1e16e..f4544441b 100644 --- a/src/main/java/techreborn/items/ItemUpgrades.java +++ b/src/main/java/techreborn/items/ItemUpgrades.java @@ -24,14 +24,9 @@ package techreborn.items; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.creativetab.CreativeTabs; import net.minecraft.inventory.Container; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.NonNullList; -import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import reborncore.api.tile.IUpgrade; @@ -40,16 +35,10 @@ import reborncore.common.recipes.IUpgradeHandler; import reborncore.common.registration.RebornRegistry; import reborncore.common.registration.impl.ConfigRegistry; import reborncore.common.tile.TileLegacyMachineBase; -import reborncore.common.util.ItemNBTHelper; -import techreborn.Core; import techreborn.init.TRItems; import techreborn.lib.ModInfo; -import techreborn.utils.TechRebornCreativeTab; - import javax.annotation.Nonnull; import javax.annotation.Nullable; -import java.security.InvalidParameterException; -import java.util.List; @RebornRegistry(modID = ModInfo.MOD_ID) public class ItemUpgrades extends ItemTR implements IUpgrade { @@ -61,91 +50,32 @@ public class ItemUpgrades extends ItemTR implements IUpgrade { public static double overclockerPower = 0.75; @ConfigRegistry(config = "items", category = "upgrades", key = "energy_storage", comment = "Energy storage upgrade extra power") - public static double energyStoragePower = 40000; - - public static final String[] types = new String[] { "overclock", "transformer", "energy_storage"}; + public static double energyStoragePower = 40_000; public ItemUpgrades() { - setTranslationKey("techreborn.upgrade"); - setHasSubtypes(true); - setCreativeTab(TechRebornCreativeTab.instance); setMaxStackSize(16); } - public static ItemStack getUpgradeByName(String name, int count) { - for (int i = 0; i < types.length; i++) { - if (types[i].equalsIgnoreCase(name)) { - return new ItemStack(TRItems.UPGRADES, count, i); - } - } - throw new InvalidParameterException("The upgrade " + name + " could not be found."); - } - - public static ItemStack getUpgradeByName(String name) { - return getUpgradeByName(name, 1); - } - @Override - // gets Unlocalized Name depending on meta data - public String getTranslationKey(ItemStack itemStack) { - int meta = itemStack.getItemDamage(); - if (meta < 0 || meta >= types.length) { - meta = 0; + public void process(@Nonnull TileLegacyMachineBase tile, @Nullable IUpgradeHandler handler, @Nonnull ItemStack stack) { + TilePowerAcceptor powerAcceptor = null; + if (tile instanceof TilePowerAcceptor) { + powerAcceptor = (TilePowerAcceptor) tile; } - - return super.getTranslationKey() + "." + types[meta]; - } - - // Adds Dusts SubItems To Creative Tab - @Override - public void getSubItems(CreativeTabs creativeTabs, NonNullList list) { - if (!isInCreativeTab(creativeTabs)) { - return; - } - for (int meta = 0; meta < types.length; ++meta) { - list.add(new ItemStack(this, 1, meta)); - } - } - - @SideOnly(Side.CLIENT) - @Override - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { - super.addInformation(stack, world, tooltip, flag); - if (stack.getItemDamage() == 4 || stack.getItemDamage() == 5) { - tooltip.add("Facing: " + getFacing(stack).getName()); - String text = Core.proxy.getUpgradeConfigText(); - if (!text.isEmpty()) { - tooltip.add(text); - } - } - } - - @Override - public void process( - @Nonnull - TileLegacyMachineBase machineBase, - @Nullable - IUpgradeHandler handler, - @Nonnull - ItemStack stack) { - - if (stack.getItemDamage() == 0) { + if (stack.isItemEqual(new ItemStack(TRItems.UPGRADE_OVERCLOCKER))) { handler.addSpeedMulti(overclockerSpeed); handler.addPowerMulti(overclockerPower); - if(machineBase instanceof TilePowerAcceptor){ - TilePowerAcceptor powerAcceptor = (TilePowerAcceptor) machineBase; + if (powerAcceptor != null) { powerAcceptor.extraPowerInput += powerAcceptor.getMaxInput(); powerAcceptor.extraPowerStoage += powerAcceptor.getBaseMaxPower(); - } + } } - if (machineBase instanceof TilePowerAcceptor) { - if (stack.getItemDamage() == 2) { - TilePowerAcceptor acceptor = (TilePowerAcceptor) machineBase; - acceptor.extraPowerStoage += energyStoragePower; + if (powerAcceptor != null) { + if (stack.isItemEqual(new ItemStack(TRItems.UPGRADE_TRANSFORMER))) { + powerAcceptor.extraTeir += 1; } - if (stack.getItemDamage() == 1) { - TilePowerAcceptor acceptor = (TilePowerAcceptor) machineBase; - acceptor.extraTeir += 1; + if (stack.isItemEqual(new ItemStack(TRItems.UPGRADE_ENERGY_STORAGE))) { + powerAcceptor.extraPowerStoage += energyStoragePower; } } } @@ -155,8 +85,4 @@ public class ItemUpgrades extends ItemTR implements IUpgrade { public void handleRightClick(TileEntity tile, ItemStack stack, Container container, int slotID) { } - - public EnumFacing getFacing(ItemStack stack) { - return EnumFacing.VALUES[ItemNBTHelper.getInt(stack, "side", 0)]; - } } diff --git a/src/main/resources/assets/techreborn/lang/en_us.lang b/src/main/resources/assets/techreborn/lang/en_us.lang index 391323591..ced779aaa 100644 --- a/src/main/resources/assets/techreborn/lang/en_us.lang +++ b/src/main/resources/assets/techreborn/lang/en_us.lang @@ -586,11 +586,9 @@ fluid.fluidwolframium=Wolframium item.techreborn.manual.name=Tech Manual item.techreborn.debug.name=Debug Tool item.techreborn.frequencyTransmitter.name=Frequency Transmitter -item.techreborn.upgrade.overclock.name=Overclocker Upgrade -item.techreborn.upgrade.transformer.name=Transformer Upgrade -item.techreborn.upgrade.energy_storage.name=Energy Storage Upgrade -item.techreborn.upgrade.ejection.name=Ejector Upgrade -item.techreborn.upgrade.injection.name=Importer Upgrade +item.techreborn.upgrade_overclocker.name=Overclocker Upgrade +item.techreborn.upgrade_transformer.name=Transformer Upgrade +item.techreborn.upgrade_energystorage.name=Energy Storage Upgrade item.techreborn.cell.name=Empty Cell item.techreborn.cell.fluid.name=$fluid$ Cell item.techreborn.rebattery.name=Battery