diff --git a/src/main/java/forestry/core/config/ForestryItem.java b/src/main/java/forestry/core/config/ForestryItem.java index 60cad8cfc..9e0ac054c 100755 --- a/src/main/java/forestry/core/config/ForestryItem.java +++ b/src/main/java/forestry/core/config/ForestryItem.java @@ -36,30 +36,12 @@ public enum ForestryItem { stamps, letters, catalogue, - // Carpenter - crate, // Butterflies butterflyGE, flutterlyzer, serumGE, caterpillarGE, - researchNote, - // Backpacks - apiaristBackpack, - lepidopteristBackpack, - minerBackpack, - diggerBackpack, - foresterBackpack, - hunterBackpack, - builderBackpack, - adventurerBackpack, - // T2 - minerBackpackT2, - diggerBackpackT2, - foresterBackpackT2, - hunterBackpackT2, - builderBackpackT2, - adventurerBackpackT2; + researchNote; private Item item; public void registerItem(Item item, String name) { diff --git a/src/main/java/forestry/core/items/ItemCrated.java b/src/main/java/forestry/core/items/ItemCrated.java index 3fb412e00..5cb3deb48 100755 --- a/src/main/java/forestry/core/items/ItemCrated.java +++ b/src/main/java/forestry/core/items/ItemCrated.java @@ -12,7 +12,6 @@ package forestry.core.items; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; import net.minecraft.world.World; @@ -25,7 +24,7 @@ import forestry.core.render.TextureManager; import forestry.core.utils.ItemStackUtil; import forestry.core.utils.StringUtil; -public class ItemCrated extends Item { +public class ItemCrated extends ItemForestry { private final ItemStack contained; private final boolean usesOreDict; diff --git a/src/main/java/forestry/plugins/PluginStorage.java b/src/main/java/forestry/plugins/PluginStorage.java index f80c64b76..6c8f4935c 100755 --- a/src/main/java/forestry/plugins/PluginStorage.java +++ b/src/main/java/forestry/plugins/PluginStorage.java @@ -51,10 +51,8 @@ import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; import forestry.Forestry; -import forestry.api.core.Tabs; import forestry.api.recipes.RecipeManagers; import forestry.api.storage.BackpackManager; -import forestry.api.storage.EnumBackpackType; import forestry.api.storage.IBackpackDefinition; import forestry.api.storage.StorageManager; import forestry.core.GuiHandlerBase; @@ -62,11 +60,9 @@ import forestry.core.IPickupHandler; import forestry.core.IResupplyHandler; import forestry.core.config.Constants; import forestry.core.config.ForestryBlock; -import forestry.core.config.ForestryItem; import forestry.core.config.LocalizedConfiguration; import forestry.core.fluids.Fluids; import forestry.core.items.ItemCrated; -import forestry.core.network.GuiId; import forestry.core.recipes.RecipeUtil; import forestry.core.utils.ItemStackUtil; import forestry.core.utils.Log; @@ -79,7 +75,7 @@ import forestry.storage.CrateRegistry; import forestry.storage.GuiHandlerStorage; import forestry.storage.PickupHandlerStorage; import forestry.storage.ResupplyHandler; -import forestry.storage.items.ItemBackpack; +import forestry.storage.items.ItemRegistryStorage; import forestry.storage.proxy.ProxyStorage; @Plugin(pluginID = "Storage", name = "Storage", author = "SirSengir", url = Constants.URL, unlocalizedDescription = "for.plugin.storage.description") @@ -97,6 +93,8 @@ public class PluginStorage extends ForestryPlugin { private final ArrayList adventurerItems = new ArrayList<>(); private final ArrayList builderItems = new ArrayList<>(); + public static ItemRegistryStorage items; + @Override @SuppressWarnings({"unchecked", "rawtypes"}) protected void setupAPI() { @@ -148,47 +146,7 @@ public class PluginStorage extends ForestryPlugin { @Override protected void registerItemsAndBlocks() { - // CRATE - ForestryItem.crate.registerItem((new ItemCrated(null, false)), "crate"); - - // BACKPACKS - IBackpackDefinition definition; - - if (PluginManager.Module.APICULTURE.isEnabled()) { - definition = BackpackManager.definitions.get("apiarist"); - Item backpack = new ItemBackpack(GuiId.ApiaristBackpackGUI, definition, EnumBackpackType.APIARIST).setCreativeTab(Tabs.tabApiculture); - ForestryItem.apiaristBackpack.registerItem(backpack, "apiaristBag"); - } - - if (PluginManager.Module.LEPIDOPTEROLOGY.isEnabled()) { - definition = BackpackManager.definitions.get("lepidopterist"); - Item backpack = new ItemBackpack(GuiId.LepidopteristBackpackGUI, definition, EnumBackpackType.APIARIST).setCreativeTab(Tabs.tabLepidopterology); - ForestryItem.lepidopteristBackpack.registerItem(backpack, "lepidopteristBag"); - } - - definition = BackpackManager.definitions.get("miner"); - ForestryItem.minerBackpack.registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T1), "minerBag"); - ForestryItem.minerBackpackT2.registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T2), "minerBagT2"); - - definition = BackpackManager.definitions.get("digger"); - ForestryItem.diggerBackpack.registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T1), "diggerBag"); - ForestryItem.diggerBackpackT2.registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T2), "diggerBagT2"); - - definition = BackpackManager.definitions.get("forester"); - ForestryItem.foresterBackpack.registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T1), "foresterBag"); - ForestryItem.foresterBackpackT2.registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T2), "foresterBagT2"); - - definition = BackpackManager.definitions.get("hunter"); - ForestryItem.hunterBackpack.registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T1), "hunterBag"); - ForestryItem.hunterBackpackT2.registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T2), "hunterBagT2"); - - definition = BackpackManager.definitions.get("adventurer"); - ForestryItem.adventurerBackpack.registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T1), "adventurerBag"); - ForestryItem.adventurerBackpackT2.registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T2), "adventurerBagT2"); - - definition = BackpackManager.definitions.get("builder"); - ForestryItem.builderBackpack.registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T1), "builderBag"); - ForestryItem.builderBackpackT2.registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T2), "builderBagT2"); + items = new ItemRegistryStorage(); } @Override @@ -487,7 +445,7 @@ public class PluginStorage extends ForestryPlugin { private static void addCrating(ItemStack crateStack, Object uncrated) { FluidStack water = Fluids.WATER.getFluid(Constants.CARPENTER_CRATING_LIQUID_QUANTITY); - ItemStack box = ForestryItem.crate.getItemStack(); + ItemStack box = items.crate.getItemStack(); RecipeManagers.carpenterManager.addRecipe(Constants.CARPENTER_CRATING_CYCLES, water, box, crateStack, "###", "###", "###", '#', uncrated); } @@ -537,73 +495,57 @@ public class PluginStorage extends ForestryPlugin { @Override protected void registerRecipes() { - - if (PluginManager.Module.APICULTURE.isEnabled()) { - // Apiarist's Backpack - RecipeUtil.addRecipe(ForestryItem.apiaristBackpack.getItemStack(), - "X#X", - "VYV", - "X#X", - '#', Blocks.wool, - 'X', Items.string, - 'V', "stickWood", - 'Y', ForestryBlock.apicultureChest.getItemStack(1, Constants.DEFINITION_APIARISTCHEST_META)); + if (items.apiaristBackpack != null) { + ItemStack chest = ForestryBlock.apicultureChest.getItemStack(1, Constants.DEFINITION_APIARISTCHEST_META); + addBackpackRecipe(items.apiaristBackpack, "stickWood", chest); } - if (PluginManager.Module.LEPIDOPTEROLOGY.isEnabled()) { - // Lepidopterist's Backpack - RecipeUtil.addRecipe(ForestryItem.lepidopteristBackpack.getItemStack(), - "X#X", - "VYV", - "X#X", - '#', Blocks.wool, - 'X', Items.string, - 'V', "stickWood", - 'Y', ForestryBlock.lepidopterology.getItemStack(1, Constants.DEFINITION_LEPICHEST_META)); + if (items.lepidopteristBackpack != null) { + ItemStack chest = ForestryBlock.lepidopterology.getItemStack(1, Constants.DEFINITION_LEPICHEST_META); + addBackpackRecipe(items.lepidopteristBackpack, "stickWood", chest); } - // Miner's Backpack - RecipeUtil.addRecipe(ForestryItem.minerBackpack.getItemStack(), - "X#X", "VYV", "X#X", '#', Blocks.wool, 'X', Items.string, 'V', - "ingotIron", 'Y', "chestWood"); - // Digger's Backpack - RecipeUtil.addRecipe(ForestryItem.diggerBackpack.getItemStack(), - "X#X", "VYV", "X#X", '#', Blocks.wool, 'X', Items.string, 'V', - "stone", 'Y', "chestWood"); - // Forester's Backpack - RecipeUtil.addRecipe(ForestryItem.foresterBackpack.getItemStack(), "X#X", "VYV", "X#X", '#', Blocks.wool, - 'X', Items.string, 'V', "logWood", 'Y', "chestWood"); - // Hunter's Backpack - RecipeUtil.addRecipe(ForestryItem.hunterBackpack.getItemStack(), - "X#X", "VYV", "X#X", '#', Blocks.wool, 'X', Items.string, 'V', - Items.feather, 'Y', "chestWood"); - // Adventurer's Backpack - RecipeUtil.addRecipe(ForestryItem.adventurerBackpack.getItemStack(), "X#X", "VYV", "X#X", '#', Blocks.wool, - 'X', Items.string, 'V', Items.bone, 'Y', "chestWood"); - // Builder's Backpack - RecipeUtil.addRecipe(ForestryItem.builderBackpack.getItemStack(), "X#X", "VYV", "X#X", '#', Blocks.wool, - 'X', Items.string, 'V', Items.clay_ball, 'Y', "chestWood"); + addBackpackRecipe(items.minerBackpack, "ingotIron"); + addBackpackRecipe(items.diggerBackpack, "stone"); + addBackpackRecipe(items.foresterBackpack, "logWood"); + addBackpackRecipe(items.hunterBackpack, Items.feather); + addBackpackRecipe(items.adventurerBackpack, Items.bone); + addBackpackRecipe(items.builderBackpack, Items.clay_ball); + // / CARPENTER if (PluginManager.Module.FACTORY.isEnabled()) { - // / CARPENTER - // / CRATES - RecipeManagers.carpenterManager.addRecipe(20, Fluids.WATER.getFluid(1000), null, ForestryItem.crate.getItemStack(24), + RecipeManagers.carpenterManager.addRecipe(20, Fluids.WATER.getFluid(1000), null, items.crate.getItemStack(24), " # ", "# #", " # ", '#', "logWood"); // / BACKPACKS T2 - addT2BackpackRecipe(ForestryItem.minerBackpack.getItemStack(), ForestryItem.minerBackpackT2.getItemStack()); - addT2BackpackRecipe(ForestryItem.diggerBackpack.getItemStack(), ForestryItem.diggerBackpackT2.getItemStack()); - addT2BackpackRecipe(ForestryItem.foresterBackpack.getItemStack(), ForestryItem.foresterBackpackT2.getItemStack()); - addT2BackpackRecipe(ForestryItem.hunterBackpack.getItemStack(), ForestryItem.hunterBackpackT2.getItemStack()); - addT2BackpackRecipe(ForestryItem.adventurerBackpack.getItemStack(), ForestryItem.adventurerBackpackT2.getItemStack()); - addT2BackpackRecipe(ForestryItem.builderBackpack.getItemStack(), ForestryItem.builderBackpackT2.getItemStack()); + addT2BackpackRecipe(items.minerBackpack, items.minerBackpackT2); + addT2BackpackRecipe(items.diggerBackpack, items.diggerBackpackT2); + addT2BackpackRecipe(items.foresterBackpack, items.foresterBackpackT2); + addT2BackpackRecipe(items.hunterBackpack, items.hunterBackpackT2); + addT2BackpackRecipe(items.adventurerBackpack, items.adventurerBackpackT2); + addT2BackpackRecipe(items.builderBackpack, items.builderBackpackT2); } } - private static void addT2BackpackRecipe(ItemStack backpackT1, ItemStack backpackT2) { + private static void addBackpackRecipe(Item backpack, Object material) { + addBackpackRecipe(backpack, material, "chestWood"); + } + + private static void addBackpackRecipe(Item backpack, Object material, Object chest) { + RecipeUtil.addRecipe(backpack, + "X#X", + "VYV", + "X#X", + '#', Blocks.wool, + 'X', Items.string, + 'V', material, + 'Y', chest); + } + + private static void addT2BackpackRecipe(Item backpackT1, Item backpackT2) { ItemStack wovenSilk = PluginCore.items.craftingMaterial.getWovenSilk(); - RecipeManagers.carpenterManager.addRecipe(200, Fluids.WATER.getFluid(1000), null, backpackT2, + RecipeManagers.carpenterManager.addRecipe(200, Fluids.WATER.getFluid(1000), null, new ItemStack(backpackT2), "WXW", "WTW", "WWW", @@ -611,5 +553,4 @@ public class PluginStorage extends ForestryPlugin { 'W', wovenSilk, 'T', backpackT1); } - } diff --git a/src/main/java/forestry/storage/items/ItemRegistryStorage.java b/src/main/java/forestry/storage/items/ItemRegistryStorage.java new file mode 100644 index 000000000..aaf5ef0ca --- /dev/null +++ b/src/main/java/forestry/storage/items/ItemRegistryStorage.java @@ -0,0 +1,90 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.storage.items; + +import net.minecraft.item.Item; + +import forestry.api.core.Tabs; +import forestry.api.storage.BackpackManager; +import forestry.api.storage.EnumBackpackType; +import forestry.api.storage.IBackpackDefinition; +import forestry.core.items.ItemCrated; +import forestry.core.items.ItemRegistry; +import forestry.core.network.GuiId; +import forestry.plugins.PluginManager; + +public class ItemRegistryStorage extends ItemRegistry { + public final ItemCrated crate; + public final ItemBackpack apiaristBackpack; + public final ItemBackpack lepidopteristBackpack; + public final Item minerBackpack; + public final Item minerBackpackT2; + public final Item diggerBackpack; + public final Item diggerBackpackT2; + public final Item foresterBackpack; + public final Item foresterBackpackT2; + public final Item hunterBackpack; + public final Item hunterBackpackT2; + public final Item adventurerBackpack; + public final Item adventurerBackpackT2; + public final Item builderBackpack; + public final Item builderBackpackT2; + + public ItemRegistryStorage() { + // CRATE + crate = registerItem(new ItemCrated(null, false), "crate"); + + // BACKPACKS + IBackpackDefinition definition; + + if (PluginManager.Module.APICULTURE.isEnabled()) { + definition = BackpackManager.definitions.get("apiarist"); + apiaristBackpack = new ItemBackpack(GuiId.ApiaristBackpackGUI, definition, EnumBackpackType.APIARIST); + apiaristBackpack.setCreativeTab(Tabs.tabApiculture); + registerItem(apiaristBackpack, "apiaristBag"); + } else { + apiaristBackpack = null; + } + + if (PluginManager.Module.LEPIDOPTEROLOGY.isEnabled()) { + definition = BackpackManager.definitions.get("lepidopterist"); + lepidopteristBackpack = new ItemBackpack(GuiId.LepidopteristBackpackGUI, definition, EnumBackpackType.APIARIST); + lepidopteristBackpack.setCreativeTab(Tabs.tabLepidopterology); + registerItem(lepidopteristBackpack, "lepidopteristBag"); + } else { + lepidopteristBackpack = null; + } + + definition = BackpackManager.definitions.get("miner"); + minerBackpack = registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T1), "minerBag"); + minerBackpackT2 = registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T2), "minerBagT2"); + + definition = BackpackManager.definitions.get("digger"); + diggerBackpack = registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T1), "diggerBag"); + diggerBackpackT2 = registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T2), "diggerBagT2"); + + definition = BackpackManager.definitions.get("forester"); + foresterBackpack = registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T1), "foresterBag"); + foresterBackpackT2 = registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T2), "foresterBagT2"); + + definition = BackpackManager.definitions.get("hunter"); + hunterBackpack = registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T1), "hunterBag"); + hunterBackpackT2 = registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T2), "hunterBagT2"); + + definition = BackpackManager.definitions.get("adventurer"); + adventurerBackpack = registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T1), "adventurerBag"); + adventurerBackpackT2 = registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T2), "adventurerBagT2"); + + definition = BackpackManager.definitions.get("builder"); + builderBackpack = registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T1), "builderBag"); + builderBackpackT2 = registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T2), "builderBagT2"); + } +}