Files
ForestryMC/src/main/java/forestry/plugins/PluginStorage.java
T

644 lines
29 KiB
Java
Raw Normal View History

2014-05-02 21:31:20 +02:00
/*******************************************************************************
2014-08-07 08:29:25 +02:00
* 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
2014-08-07 02:56:58 -07:00
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
2014-08-07 08:29:25 +02:00
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
2014-05-02 21:31:20 +02:00
******************************************************************************/
package forestry.plugins;
2015-04-05 14:16:41 -07:00
import java.awt.Color;
2014-05-02 21:31:20 +02:00
import java.util.ArrayList;
2014-12-25 23:43:30 -08:00
import java.util.List;
2014-05-02 21:31:20 +02:00
import net.minecraft.block.Block;
import net.minecraft.block.BlockBasePressurePlate;
import net.minecraft.block.BlockButton;
import net.minecraft.block.BlockChest;
import net.minecraft.block.BlockFence;
import net.minecraft.block.BlockFenceGate;
import net.minecraft.block.BlockFurnace;
import net.minecraft.block.BlockLadder;
import net.minecraft.block.BlockLever;
import net.minecraft.block.BlockLog;
import net.minecraft.block.BlockMelon;
import net.minecraft.block.BlockPumpkin;
import net.minecraft.block.BlockRedstoneDiode;
import net.minecraft.block.BlockStairs;
import net.minecraft.block.BlockTorch;
import net.minecraft.block.BlockTrapDoor;
import net.minecraft.block.BlockWall;
import net.minecraft.block.BlockWorkbench;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemDoor;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
2014-05-02 21:31:20 +02:00
import net.minecraftforge.common.IPlantable;
import net.minecraftforge.common.IShearable;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
import cpw.mods.fml.common.network.IGuiHandler;
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;
2014-12-26 02:13:39 -08:00
import forestry.api.storage.StorageManager;
import forestry.core.config.Configuration;
import forestry.core.config.Defaults;
import forestry.core.config.ForestryBlock;
import forestry.core.config.ForestryItem;
import forestry.core.config.Property;
import forestry.core.fluids.Fluids;
import forestry.core.interfaces.IOreDictionaryHandler;
import forestry.core.interfaces.IPickupHandler;
import forestry.core.interfaces.IResupplyHandler;
import forestry.core.interfaces.ISaveEventHandler;
import forestry.core.items.ItemCrated;
import forestry.core.network.GuiId;
import forestry.core.proxy.Proxies;
import forestry.core.utils.StackUtils;
2015-04-12 21:07:49 -07:00
import forestry.factory.gadgets.MachineCarpenter;
import forestry.storage.BackpackDefinition;
import forestry.storage.BackpackHelper;
2014-12-26 02:13:39 -08:00
import forestry.storage.CrateRegistry;
import forestry.storage.GuiHandlerStorage;
import forestry.storage.PickupHandlerStorage;
import forestry.storage.ResupplyHandler;
import forestry.storage.items.ItemNaturalistBackpack;
import forestry.storage.items.ItemNaturalistBackpack.BackpackDefinitionApiarist;
import forestry.storage.items.ItemNaturalistBackpack.BackpackDefinitionLepidopterist;
import forestry.storage.proxy.ProxyStorage;
2014-09-27 12:46:54 -07:00
@Plugin(pluginID = "Storage", name = "Storage", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.storage.description")
public class PluginStorage extends ForestryPlugin implements IOreDictionaryHandler {
2014-05-02 21:31:20 +02:00
2014-12-25 23:43:30 -08:00
private static final List<ItemCrated> crates = new ArrayList<ItemCrated>();
private static final String CONFIG_CATEGORY = "backpacks";
@SidedProxy(clientSide = "forestry.storage.proxy.ClientProxyStorage", serverSide = "forestry.storage.proxy.ProxyStorage")
public static ProxyStorage proxy;
2014-05-02 21:31:20 +02:00
private final ArrayList<ItemStack> minerItems = new ArrayList<ItemStack>();
private final ArrayList<ItemStack> diggerItems = new ArrayList<ItemStack>();
private final ArrayList<ItemStack> foresterItems = new ArrayList<ItemStack>();
private final ArrayList<ItemStack> hunterItems = new ArrayList<ItemStack>();
private final ArrayList<ItemStack> adventurerItems = new ArrayList<ItemStack>();
private final ArrayList<ItemStack> builderItems = new ArrayList<ItemStack>();
2014-12-25 23:43:30 -08:00
private Configuration config;
2014-05-02 21:31:20 +02:00
@Override
@SuppressWarnings({"unchecked", "rawtypes"})
2015-04-05 14:16:41 -07:00
protected void setupAPI() {
super.setupAPI();
StorageManager.crateRegistry = new CrateRegistry();
2014-05-02 21:31:20 +02:00
BackpackManager.backpackInterface = new BackpackHelper();
BackpackManager.backpackItems = new ArrayList[6];
BackpackManager.backpackItems[0] = minerItems;
BackpackManager.backpackItems[1] = diggerItems;
BackpackManager.backpackItems[2] = foresterItems;
BackpackManager.backpackItems[3] = hunterItems;
BackpackManager.backpackItems[4] = adventurerItems;
BackpackManager.backpackItems[5] = builderItems;
2014-12-26 02:13:39 -08:00
2015-04-05 14:16:41 -07:00
BackpackDefinition definition;
if (PluginManager.Module.APICULTURE.isEnabled()) {
definition = new BackpackDefinitionApiarist("apiarist", new Color(0xc4923d).getRGB());
BackpackManager.definitions.put(definition.getKey(), definition);
}
if (PluginManager.Module.LEPIDOPTEROLOGY.isEnabled()) {
definition = new BackpackDefinitionLepidopterist("lepidopterist", new Color(0x995b31).getRGB());
BackpackManager.definitions.put(definition.getKey(), definition);
}
definition = new BackpackDefinition("miner", new Color(0x36187d).getRGB());
BackpackManager.definitions.put(definition.getKey(), definition);
definition = new BackpackDefinition("digger", new Color(0x363cc5).getRGB());
BackpackManager.definitions.put(definition.getKey(), definition);
definition = new BackpackDefinition("forester", new Color(0x347427).getRGB());
BackpackManager.definitions.put(definition.getKey(), definition);
definition = new BackpackDefinition("hunter", new Color(0x412215).getRGB());
BackpackManager.definitions.put(definition.getKey(), definition);
definition = new BackpackDefinition("adventurer", new Color(0x7fb8c2).getRGB());
BackpackManager.definitions.put(definition.getKey(), definition);
definition = new BackpackDefinition("builder", new Color(0xdd3a3a).getRGB());
BackpackManager.definitions.put(definition.getKey(), definition);
2014-05-02 21:31:20 +02:00
}
@Override
public void postInit() {
scanForItems();
config = new Configuration();
Property backpackConf = config.get("backpacks.miner.items", CONFIG_CATEGORY, "");
backpackConf.comment = "add additional blocks and items for the miner's backpack here in the format modid:name:meta. separate blocks and items using ';'. wildcard for metadata: '*'";
parseBackpackItems(backpackConf.value, BackpackManager.definitions.get("miner"));
2014-05-02 21:31:20 +02:00
backpackConf = config.get("backpacks.digger.items", CONFIG_CATEGORY, "");
backpackConf.comment = "add additional blocks and items for the digger's backpack here in the format modid:name:meta. separate blocks and items using ';'. wildcard for metadata: '*'";
parseBackpackItems(backpackConf.value, BackpackManager.definitions.get("digger"));
2014-05-02 21:31:20 +02:00
backpackConf = config.get("backpacks.forester.items", CONFIG_CATEGORY, "");
backpackConf.comment = "add additional blocks and items for the forester's backpack here in the format modid:name:meta. separate blocks and items using ';'. wildcard for metadata: '*'";
parseBackpackItems(backpackConf.value, BackpackManager.definitions.get("forester"));
2014-05-02 21:31:20 +02:00
backpackConf = config.get("backpacks.hunter.items", CONFIG_CATEGORY, "");
backpackConf.comment = "add additional blocks and items for the hunter's backpack here in the format modid:name:meta. separate blocks and items using ';'. wildcard for metadata: '*'";
parseBackpackItems(backpackConf.value, BackpackManager.definitions.get("hunter"));
2014-05-02 21:31:20 +02:00
backpackConf = config.get("backpacks.adventurer.items", CONFIG_CATEGORY, "");
backpackConf.comment = "add blocks and items for the adventurer's backpack here in the format modid:name:meta. separate blocks and items using ';'. wildcard for metadata: '*'";
parseBackpackItems(backpackConf.value, BackpackManager.definitions.get("adventurer"));
2014-05-02 21:31:20 +02:00
backpackConf = config.get("backpacks.builder.items", CONFIG_CATEGORY, "");
backpackConf.comment = "add blocks and items for the builder's backpack here in the format modid:name:meta. separate blocks and items using ';'. wildcard for metadata: '*'";
parseBackpackItems(backpackConf.value, BackpackManager.definitions.get("builder"));
2014-05-02 21:31:20 +02:00
config.save();
BackpackManager.definitions.get("miner").addValidItems(minerItems);
BackpackManager.definitions.get("digger").addValidItems(diggerItems);
BackpackManager.definitions.get("forester").addValidItems(foresterItems);
BackpackManager.definitions.get("hunter").addValidItems(hunterItems);
BackpackManager.definitions.get("adventurer").addValidItems(adventurerItems);
BackpackManager.definitions.get("builder").addValidItems(builderItems);
2014-05-02 21:31:20 +02:00
}
2014-12-25 23:43:30 -08:00
public static void registerCrate(ItemCrated crate) {
2015-04-05 14:16:41 -07:00
proxy.registerCrateForRendering(crate);
2014-12-25 23:43:30 -08:00
crates.add(crate);
}
public static void createCrateRecipes() {
2015-04-12 21:07:49 -07:00
MachineCarpenter.RecipeManager carpenterManager = (MachineCarpenter.RecipeManager) RecipeManagers.carpenterManager;
2014-12-25 23:43:30 -08:00
for (ItemCrated crate : crates) {
ItemStack itemStack = new ItemStack(crate);
if (crate.usesOreDict()) {
2015-04-12 21:07:49 -07:00
carpenterManager.addCratingWithOreDict(itemStack);
2014-12-25 23:43:30 -08:00
} else {
2015-04-12 21:07:49 -07:00
carpenterManager.addCrating(itemStack);
2014-12-25 23:43:30 -08:00
}
}
}
2014-05-02 21:31:20 +02:00
public static void addBackpackItem(String pack, ItemStack stack) {
if (stack == null) {
2014-05-02 21:31:20 +02:00
return;
}
2014-05-02 21:31:20 +02:00
BackpackManager.definitions.get(pack).addValidItem(stack);
}
public static void addBackpackItem(String pack, Block block) {
BackpackManager.definitions.get(pack).addValidItem(new ItemStack(block, 1, Defaults.WILDCARD));
}
public static void addBackpackItem(String pack, Item item) {
BackpackManager.definitions.get(pack).addValidItem(new ItemStack(item, 1, Defaults.WILDCARD));
}
public static void scanForItems() {
for (Object id : Block.blockRegistry.getKeys()) {
2014-05-02 21:31:20 +02:00
try {
Block block = (Block) Block.blockRegistry.getObject(id);
if (block instanceof IPlantable
|| block instanceof IShearable
|| block instanceof BlockLog
|| block instanceof BlockMelon
|| block instanceof BlockPumpkin) {
2014-05-02 21:31:20 +02:00
addBackpackItem("forester", block);
}
if (block instanceof BlockStairs || block.getRenderType() == 10
|| block instanceof BlockFence || block.getRenderType() == 11
|| block instanceof BlockFenceGate || block.getRenderType() == 21
|| block instanceof BlockWall || block.getRenderType() == 32
|| block instanceof BlockBasePressurePlate
|| block instanceof BlockLever
|| block instanceof BlockButton
|| block instanceof BlockTorch
|| block instanceof BlockRedstoneDiode
|| block instanceof BlockChest || block.getRenderType() == 22
|| block instanceof BlockWorkbench
|| block instanceof BlockFurnace
|| block instanceof BlockLadder || block.getRenderType() == 8
|| block instanceof BlockTrapDoor
|| block.getUnlocalizedName().contains("door")) {
2014-05-02 21:31:20 +02:00
addBackpackItem("builder", block);
}
2014-05-02 21:31:20 +02:00
} catch (Throwable error) {
error.printStackTrace();
}
}
2014-05-02 21:31:20 +02:00
for (Object id : Item.itemRegistry.getKeys()) {
2014-05-02 21:31:20 +02:00
try {
Item item = (Item) Item.itemRegistry.getObject(id);
if (item instanceof IPlantable) {
2014-05-02 21:31:20 +02:00
addBackpackItem("forester", item);
} else if (item instanceof ItemFood) {
2014-05-02 21:31:20 +02:00
addBackpackItem("hunter", item);
} else if (item instanceof ItemDoor) {
2014-05-02 21:31:20 +02:00
addBackpackItem("builder", item);
}
2014-05-02 21:31:20 +02:00
} catch (Throwable error) {
error.printStackTrace();
}
}
2014-05-02 21:31:20 +02:00
}
@Override
public boolean processIMCMessage(IMCMessage message) {
if (message.key.equals("add-backpack-items")) {
String[] tokens = message.getStringValue().split("@");
if (tokens.length != 2) {
logInvalidIMCMessage(message);
2014-05-02 21:31:20 +02:00
return true;
}
if (!BackpackManager.definitions.containsKey(tokens[0])) {
String errorMessage = getInvalidIMCMessageText(message);
Proxies.log.warning("%s For non-existent backpack %s.", errorMessage, tokens[0]);
2014-05-02 21:31:20 +02:00
return true;
}
parseBackpackItems(tokens[1], BackpackManager.definitions.get(tokens[0]));
2014-05-02 21:31:20 +02:00
return true;
}
return false;
}
@Override
public IPickupHandler getPickupHandler() {
return new PickupHandlerStorage();
}
@Override
public IGuiHandler getGuiHandler() {
return new GuiHandlerStorage();
}
@Override
public IResupplyHandler getResupplyHandler() {
return new ResupplyHandler();
}
@Override
protected void registerItems() {
// CRATE
2014-12-26 02:13:39 -08:00
ForestryItem.crate.registerItem((new ItemCrated(null, false)), "crate");
// BACKPACKS
2015-04-05 14:16:41 -07:00
IBackpackDefinition definition;
2014-05-02 21:31:20 +02:00
if (PluginManager.Module.APICULTURE.isEnabled()) {
2015-04-05 14:16:41 -07:00
definition = BackpackManager.definitions.get("apiarist");
Item backpack = new ItemNaturalistBackpack(GuiId.ApiaristBackpackGUI.ordinal(), definition).setCreativeTab(Tabs.tabApiculture);
ForestryItem.apiaristBackpack.registerItem(backpack, "apiaristBag");
}
if (PluginManager.Module.LEPIDOPTEROLOGY.isEnabled()) {
2015-04-05 14:16:41 -07:00
definition = BackpackManager.definitions.get("lepidopterist");
Item backpack = new ItemNaturalistBackpack(GuiId.LepidopteristBackpackGUI.ordinal(), definition).setCreativeTab(Tabs.tabLepidopterology);
ForestryItem.lepidopteristBackpack.registerItem(backpack, "lepidopteristBag");
}
2014-05-02 21:31:20 +02:00
2015-04-05 14:16:41 -07:00
definition = BackpackManager.definitions.get("miner");
2014-05-02 21:31:20 +02:00
ForestryItem.minerBackpack.registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T1), "minerBag");
ForestryItem.minerBackpackT2.registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T2), "minerBagT2");
2015-04-05 14:16:41 -07:00
definition = BackpackManager.definitions.get("digger");
2014-05-02 21:31:20 +02:00
ForestryItem.diggerBackpack.registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T1), "diggerBag");
ForestryItem.diggerBackpackT2.registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T2), "diggerBagT2");
2015-04-05 14:16:41 -07:00
definition = BackpackManager.definitions.get("forester");
2014-05-02 21:31:20 +02:00
ForestryItem.foresterBackpack.registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T1), "foresterBag");
ForestryItem.foresterBackpackT2.registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T2), "foresterBagT2");
2015-04-05 14:16:41 -07:00
definition = BackpackManager.definitions.get("hunter");
2014-05-02 21:31:20 +02:00
ForestryItem.hunterBackpack.registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T1), "hunterBag");
ForestryItem.hunterBackpackT2.registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T2), "hunterBagT2");
2015-04-05 14:16:41 -07:00
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");
2014-05-02 21:31:20 +02:00
2015-04-05 14:16:41 -07:00
definition = BackpackManager.definitions.get("builder");
ForestryItem.builderBackpack.registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T1), "builderBag");
2014-08-18 17:49:38 +02:00
ForestryItem.builderBackpackT2.registerItem(BackpackManager.backpackInterface.addBackpack(definition, EnumBackpackType.T2), "builderBagT2");
2014-05-02 21:31:20 +02:00
}
@Override
protected void registerBackpackItems() {
// [0] Set valid items in miner's backpack
minerItems.add(new ItemStack(Blocks.obsidian));
minerItems.add(new ItemStack(Blocks.coal_ore));
minerItems.add(new ItemStack(Items.coal));
minerItems.add(new ItemStack(Blocks.diamond_ore));
minerItems.add(new ItemStack(Items.diamond));
minerItems.add(new ItemStack(Blocks.gold_ore));
minerItems.add(new ItemStack(Items.gold_ingot));
minerItems.add(new ItemStack(Blocks.iron_ore));
minerItems.add(new ItemStack(Items.iron_ingot));
minerItems.add(new ItemStack(Blocks.lapis_ore));
minerItems.add(new ItemStack(Blocks.redstone_ore));
minerItems.add(new ItemStack(Items.redstone));
minerItems.add(new ItemStack(Items.dye, 1, 4));
minerItems.add(new ItemStack(Items.glowstone_dust));
minerItems.add(new ItemStack(Items.emerald));
minerItems.add(new ItemStack(Blocks.diamond_block));
minerItems.add(new ItemStack(Blocks.emerald_block));
minerItems.add(new ItemStack(Blocks.gold_block));
minerItems.add(new ItemStack(Blocks.iron_block));
minerItems.add(new ItemStack(Blocks.lapis_block));
minerItems.add(ForestryItem.bronzePickaxe.getItemStack());
minerItems.add(ForestryItem.kitPickaxe.getItemStack());
minerItems.add(ForestryItem.brokenBronzePickaxe.getItemStack());
minerItems.add(new ItemStack(Items.quartz));
minerItems.add(new ItemStack(Blocks.emerald_ore));
minerItems.add(new ItemStack(Blocks.quartz_ore));
// [1] Set valid items in digger's backpack
diggerItems.add(new ItemStack(Blocks.dirt));
diggerItems.add(new ItemStack(Blocks.cobblestone));
diggerItems.add(new ItemStack(Blocks.sand));
diggerItems.add(new ItemStack(Blocks.sandstone));
diggerItems.add(new ItemStack(Blocks.gravel));
diggerItems.add(new ItemStack(Items.flint));
diggerItems.add(new ItemStack(Blocks.netherrack));
diggerItems.add(new ItemStack(Items.clay_ball));
diggerItems.add(new ItemStack(Blocks.soul_sand));
diggerItems.add(ForestryItem.bronzeShovel.getItemStack());
diggerItems.add(ForestryItem.kitShovel.getItemStack());
diggerItems.add(ForestryItem.brokenBronzeShovel.getItemStack());
// [2] Set valid items in forester's backpack
foresterItems.add(new ItemStack(Blocks.sapling, 1, Defaults.WILDCARD));
foresterItems.add(new ItemStack(Blocks.red_mushroom));
foresterItems.add(new ItemStack(Blocks.brown_mushroom));
foresterItems.add(new ItemStack(Blocks.log, 1, Defaults.WILDCARD));
foresterItems.add(new ItemStack(Items.wheat_seeds));
foresterItems.add(new ItemStack(Blocks.red_flower));
foresterItems.add(new ItemStack(Blocks.yellow_flower));
foresterItems.add(new ItemStack(Blocks.leaves, 1, Defaults.WILDCARD));
foresterItems.add(new ItemStack(Blocks.cactus));
foresterItems.add(new ItemStack(Blocks.tallgrass, 1, Defaults.WILDCARD));
foresterItems.add(new ItemStack(Blocks.vine));
foresterItems.add(new ItemStack(Blocks.pumpkin));
foresterItems.add(new ItemStack(Blocks.melon_block));
foresterItems.add(new ItemStack(Items.apple));
foresterItems.add(new ItemStack(Items.golden_apple));
foresterItems.add(new ItemStack(Items.nether_wart));
foresterItems.add(new ItemStack(Items.pumpkin_seeds));
foresterItems.add(new ItemStack(Items.melon_seeds));
foresterItems.add(new ItemStack(Items.wheat));
2014-10-11 16:52:10 -07:00
if (PluginManager.Module.ARBORICULTURE.isEnabled()) {
foresterItems.add(ForestryBlock.saplingGE.getWildcard());
}
2014-05-02 21:31:20 +02:00
// [3] Set valid items in hunter's backpack
hunterItems.add(new ItemStack(Items.feather));
hunterItems.add(new ItemStack(Items.gunpowder));
hunterItems.add(new ItemStack(Items.blaze_powder));
hunterItems.add(new ItemStack(Items.blaze_rod));
hunterItems.add(new ItemStack(Items.bone));
hunterItems.add(new ItemStack(Items.string));
hunterItems.add(new ItemStack(Items.rotten_flesh));
hunterItems.add(new ItemStack(Items.ghast_tear));
hunterItems.add(new ItemStack(Items.gold_nugget));
hunterItems.add(new ItemStack(Items.arrow));
hunterItems.add(new ItemStack(Items.porkchop));
hunterItems.add(new ItemStack(Items.cooked_porkchop));
hunterItems.add(new ItemStack(Items.beef));
hunterItems.add(new ItemStack(Items.cooked_beef));
hunterItems.add(new ItemStack(Items.chicken));
hunterItems.add(new ItemStack(Items.cooked_chicken));
hunterItems.add(new ItemStack(Items.leather));
hunterItems.add(new ItemStack(Items.egg));
hunterItems.add(new ItemStack(Items.ender_pearl));
hunterItems.add(new ItemStack(Items.spider_eye));
hunterItems.add(new ItemStack(Items.fermented_spider_eye));
hunterItems.add(new ItemStack(Items.slime_ball));
hunterItems.add(new ItemStack(Items.dye, 1, 0));
hunterItems.add(new ItemStack(Blocks.hay_block));
hunterItems.add(new ItemStack(Blocks.wool));
hunterItems.add(new ItemStack(Blocks.wool, 1, Defaults.WILDCARD));
hunterItems.add(new ItemStack(Items.ender_eye));
hunterItems.add(new ItemStack(Items.magma_cream));
hunterItems.add(new ItemStack(Items.speckled_melon));
hunterItems.add(new ItemStack(Items.fish));
hunterItems.add(new ItemStack(Items.cooked_fished));
hunterItems.add(new ItemStack(Items.lead));
hunterItems.add(new ItemStack(Items.fishing_rod));
hunterItems.add(new ItemStack(Items.name_tag));
hunterItems.add(new ItemStack(Items.saddle));
hunterItems.add(new ItemStack(Items.diamond_horse_armor));
hunterItems.add(new ItemStack(Items.golden_horse_armor));
hunterItems.add(new ItemStack(Items.iron_horse_armor));
// [4] Set valid items in adventurer's backpack
2014-05-02 21:31:20 +02:00
// [5] Set valid items in builder's backpack
if (PluginManager.Module.APICULTURE.isEnabled()) {
builderItems.add(ForestryBlock.candle.getWildcard());
builderItems.add(ForestryBlock.stump.getWildcard());
}
2014-05-02 21:31:20 +02:00
builderItems.add(new ItemStack(Blocks.torch));
builderItems.add(new ItemStack(Blocks.redstone_torch));
builderItems.add(new ItemStack(Blocks.redstone_lamp));
builderItems.add(new ItemStack(Blocks.stonebrick, 1, Defaults.WILDCARD));
builderItems.add(new ItemStack(Blocks.sandstone, 1, 1));
builderItems.add(new ItemStack(Blocks.sandstone, 1, 2));
builderItems.add(new ItemStack(Blocks.stone));
builderItems.add(new ItemStack(Blocks.brick_block));
builderItems.add(new ItemStack(Blocks.planks, 1, Defaults.WILDCARD));
builderItems.add(new ItemStack(Blocks.clay));
2014-05-02 21:31:20 +02:00
builderItems.add(new ItemStack(Blocks.hardened_clay, 1, Defaults.WILDCARD));
builderItems.add(new ItemStack(Blocks.stained_hardened_clay, 1, Defaults.WILDCARD));
builderItems.add(new ItemStack(Blocks.packed_ice));
2014-05-02 21:31:20 +02:00
builderItems.add(new ItemStack(Blocks.nether_brick));
builderItems.add(new ItemStack(Blocks.nether_brick_fence));
builderItems.add(new ItemStack(Blocks.stone_stairs));
builderItems.add(new ItemStack(Blocks.oak_stairs));
builderItems.add(new ItemStack(Blocks.brick_stairs));
builderItems.add(new ItemStack(Blocks.nether_brick_stairs));
builderItems.add(new ItemStack(Blocks.stone_brick_stairs));
builderItems.add(new ItemStack(Blocks.glass));
builderItems.add(new ItemStack(Blocks.glass_pane));
builderItems.add(new ItemStack(Blocks.chest));
builderItems.add(new ItemStack(Blocks.crafting_table));
builderItems.add(new ItemStack(Blocks.furnace));
builderItems.add(new ItemStack(Blocks.lever));
builderItems.add(new ItemStack(Blocks.wooden_button));
builderItems.add(new ItemStack(Blocks.stone_button));
builderItems.add(new ItemStack(Blocks.dispenser));
builderItems.add(new ItemStack(Blocks.dropper));
builderItems.add(new ItemStack(Blocks.ladder));
builderItems.add(new ItemStack(Blocks.fence));
builderItems.add(new ItemStack(Blocks.fence_gate));
builderItems.add(new ItemStack(Blocks.iron_bars));
builderItems.add(new ItemStack(Blocks.stone_slab, 1, Defaults.WILDCARD));
builderItems.add(new ItemStack(Blocks.quartz_block, 1, Defaults.WILDCARD));
builderItems.add(new ItemStack(Blocks.quartz_stairs));
builderItems.add(new ItemStack(Blocks.sandstone_stairs));
builderItems.add(new ItemStack(Blocks.birch_stairs));
builderItems.add(new ItemStack(Blocks.spruce_stairs));
builderItems.add(new ItemStack(Blocks.jungle_stairs));
builderItems.add(new ItemStack(Blocks.cobblestone_wall, 1, Defaults.WILDCARD));
builderItems.add(new ItemStack(Items.iron_door));
builderItems.add(new ItemStack(Items.wooden_door));
builderItems.add(new ItemStack(Items.sign));
builderItems.add(new ItemStack(Items.repeater));
builderItems.add(new ItemStack(Items.comparator));
builderItems.add(new ItemStack(Items.item_frame));
}
@Override
protected void registerRecipes() {
if (PluginManager.Module.APICULTURE.isEnabled()) {
// Apiarist's Backpack
Proxies.common.addRecipe(ForestryItem.apiaristBackpack.getItemStack(),
"X#X",
"VYV",
"X#X",
'#', Blocks.wool,
'X', Items.string,
'V', "stickWood",
'Y', ForestryBlock.apiculture.getItemStack(1, Defaults.DEFINITION_APIARISTCHEST_META));
}
if (PluginManager.Module.LEPIDOPTEROLOGY.isEnabled()) {
// Lepidopterist's Backpack
Proxies.common.addRecipe(ForestryItem.lepidopteristBackpack.getItemStack(),
"X#X",
"VYV",
"X#X",
'#', Blocks.wool,
'X', Items.string,
'V', "stickWood",
'Y', ForestryBlock.lepidopterology.getItemStack(1, Defaults.DEFINITION_LEPICHEST_META));
}
2014-05-02 21:31:20 +02:00
// Miner's Backpack
Proxies.common.addRecipe(ForestryItem.minerBackpack.getItemStack(),
2014-11-29 22:13:28 -08:00
"X#X", "VYV", "X#X", '#', Blocks.wool, 'X', Items.string, 'V',
Items.iron_ingot, 'Y', Blocks.chest);
2014-05-02 21:31:20 +02:00
// Digger's Backpack
Proxies.common.addRecipe(ForestryItem.diggerBackpack.getItemStack(),
2014-11-29 22:13:28 -08:00
"X#X", "VYV", "X#X", '#', Blocks.wool, 'X', Items.string, 'V',
Blocks.stone, 'Y', Blocks.chest);
2014-05-02 21:31:20 +02:00
// Forester's Backpack
2014-11-29 22:13:28 -08:00
Proxies.common.addRecipe(ForestryItem.foresterBackpack.getItemStack(), "X#X", "VYV", "X#X", '#', Blocks.wool,
'X', Items.string, 'V', "logWood", 'Y', Blocks.chest);
2014-05-02 21:31:20 +02:00
// Hunter's Backpack
Proxies.common.addRecipe(ForestryItem.hunterBackpack.getItemStack(),
2014-11-29 22:13:28 -08:00
"X#X", "VYV", "X#X", '#', Blocks.wool, 'X', Items.string, 'V',
Items.feather, 'Y', Blocks.chest);
2014-05-02 21:31:20 +02:00
// Adventurer's Backpack
2014-11-29 22:13:28 -08:00
Proxies.common.addRecipe(ForestryItem.adventurerBackpack.getItemStack(), "X#X", "VYV", "X#X", '#', Blocks.wool,
'X', Items.string, 'V', Items.bone, 'Y', Blocks.chest);
2014-05-02 21:31:20 +02:00
// Builder's Backpack
2014-11-29 22:13:28 -08:00
Proxies.common.addRecipe(ForestryItem.builderBackpack.getItemStack(), "X#X", "VYV", "X#X", '#', Blocks.wool,
'X', Items.string, 'V', Items.clay_ball, 'Y', Blocks.chest);
2014-05-02 21:31:20 +02:00
2015-01-07 07:07:45 -08:00
if (PluginManager.Module.FACTORY.isEnabled()) {
// / CARPENTER
// / CRATES
RecipeManagers.carpenterManager.addRecipe(20, Fluids.WATER.getFluid(1000), null, ForestryItem.crate.getItemStack(24),
" # ", "# #", " # ", '#', "logWood");
2015-01-07 07:07:45 -08:00
// / BACKPACKS T2
RecipeManagers.carpenterManager.addRecipe(200, Fluids.WATER.getFluid(1000), null, ForestryItem.minerBackpackT2.getItemStack(),
"WXW", "WTW", "WWW", 'X', Items.diamond, 'W',
ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.minerBackpack);
RecipeManagers.carpenterManager.addRecipe(200, Fluids.WATER.getFluid(1000), null, ForestryItem.diggerBackpackT2.getItemStack(),
"WXW", "WTW", "WWW", 'X', Items.diamond, 'W',
ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.diggerBackpack);
RecipeManagers.carpenterManager.addRecipe(200, Fluids.WATER.getFluid(1000), null, ForestryItem.foresterBackpackT2.getItemStack(),
"WXW", "WTW", "WWW", 'X', Items.diamond, 'W',
ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.foresterBackpack);
RecipeManagers.carpenterManager.addRecipe(200, Fluids.WATER.getFluid(1000), null, ForestryItem.hunterBackpackT2.getItemStack(),
"WXW", "WTW", "WWW", 'X', Items.diamond, 'W',
ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.hunterBackpack);
RecipeManagers.carpenterManager.addRecipe(200, Fluids.WATER.getFluid(1000), null, ForestryItem.adventurerBackpackT2.getItemStack(),
"WXW", "WTW", "WWW", 'X', Items.diamond, 'W',
ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.adventurerBackpack);
RecipeManagers.carpenterManager.addRecipe(200, Fluids.WATER.getFluid(1000), null, ForestryItem.builderBackpackT2.getItemStack(),
"WXW", "WTW", "WWW", 'X', Items.diamond, 'W',
ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.builderBackpack);
}
2014-05-02 21:31:20 +02:00
}
@Override
protected void registerCrates() {
}
private static void parseBackpackItems(String list, IBackpackDefinition target) {
List<ItemStack> backpackItems = StackUtils.parseItemStackStrings(list);
target.addValidItems(backpackItems);
2014-05-02 21:31:20 +02:00
}
@Override
public ISaveEventHandler getSaveEventHandler() {
return null;
}
@Override
public IOreDictionaryHandler getDictionaryHandler() {
return this;
}
@Override
public void onOreRegistration(String name, ItemStack ore) {
if (ore == null) {
Proxies.log.warning("An ore/item of type %s was registered with the Forge ore dictionary, however the passed itemstack is null. Someone broke it. :(", name);
return;
}
if (name.startsWith("ingot")) {
2014-05-02 21:31:20 +02:00
minerItems.add(ore);
} else if (name.startsWith("ore")) {
2014-05-02 21:31:20 +02:00
minerItems.add(ore);
} else if (name.startsWith("gem")) {
2014-05-02 21:31:20 +02:00
minerItems.add(ore);
} else if (name.startsWith("dust")) {
2014-05-02 21:31:20 +02:00
minerItems.add(ore);
} else if (name.startsWith("crystal")) {
2014-05-02 21:31:20 +02:00
minerItems.add(ore);
} else if (name.startsWith("cluster")) {
2014-09-18 11:53:33 -04:00
minerItems.add(ore);
} else if (name.startsWith("shard")) {
2014-09-18 11:53:33 -04:00
minerItems.add(ore);
} else if (name.startsWith("clump")) {
2014-09-18 11:53:33 -04:00
minerItems.add(ore);
} else if (name.matches("dropUranium")) {
2014-05-02 21:31:20 +02:00
minerItems.add(ore);
} else if (name.equals("treeLeaves") || name.equals("treeSapling") || name.equals("logWood")) {
2014-05-02 21:31:20 +02:00
foresterItems.add(ore);
} else if (name.equals("stairWood") || name.equals("plankWood") || name.equals("slabWood")) {
2014-05-02 21:31:20 +02:00
builderItems.add(ore);
} else if (name.startsWith("wood")) {
2014-05-02 21:31:20 +02:00
foresterItems.add(ore);
}
2014-05-02 21:31:20 +02:00
}
}