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
2015-01-26 22:26:21 -08:00
*
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 ;
2015-06-17 01:01:29 -07:00
import java.io.File ;
2014-05-02 21:31:20 +02:00
import java.util.ArrayList ;
2015-06-17 01:01:29 -07:00
import java.util.Arrays ;
import java.util.Collections ;
2014-12-25 23:43:30 -08:00
import java.util.List ;
2015-06-17 01:01:29 -07:00
import java.util.regex.Pattern ;
2014-12-25 01:00:13 -08:00
2014-05-02 21:31:20 +02:00
import net.minecraft.block.BlockBasePressurePlate ;
import net.minecraft.block.BlockButton ;
import net.minecraft.block.BlockChest ;
2015-06-17 01:01:29 -07:00
import net.minecraft.block.BlockDoor ;
2014-05-02 21:31:20 +02:00
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.BlockRedstoneDiode ;
2015-06-17 01:01:29 -07:00
import net.minecraft.block.BlockSlab ;
2014-05-02 21:31:20 +02:00
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 ;
2015-06-17 01:01:29 -07:00
import net.minecraft.block.IGrowable ;
2014-05-02 21:31:20 +02:00
import net.minecraft.init.Blocks ;
import net.minecraft.init.Items ;
import net.minecraft.item.Item ;
import net.minecraft.item.ItemDoor ;
import net.minecraft.item.ItemStack ;
2014-12-25 01:00:13 -08:00
2014-05-02 21:31:20 +02:00
import net.minecraftforge.common.IPlantable ;
import net.minecraftforge.common.IShearable ;
2015-06-17 01:01:29 -07:00
import net.minecraftforge.common.config.Configuration ;
import net.minecraftforge.common.config.Property ;
import net.minecraftforge.oredict.OreDictionary ;
2014-05-02 21:31:20 +02:00
2014-12-25 01:00:13 -08:00
import cpw.mods.fml.common.SidedProxy ;
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage ;
import cpw.mods.fml.common.network.IGuiHandler ;
2015-06-17 01:01:29 -07:00
import forestry.Forestry ;
2014-12-25 01:00:13 -08:00
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 ;
2014-12-25 01:00:13 -08:00
import forestry.core.config.Defaults ;
import forestry.core.config.ForestryBlock ;
import forestry.core.config.ForestryItem ;
import forestry.core.fluids.Fluids ;
import forestry.core.interfaces.IPickupHandler ;
import forestry.core.interfaces.IResupplyHandler ;
import forestry.core.items.ItemCrated ;
import forestry.core.network.GuiId ;
import forestry.core.proxy.Proxies ;
2015-03-01 01:04:07 -08:00
import forestry.core.utils.StackUtils ;
2015-04-12 21:07:49 -07:00
import forestry.factory.gadgets.MachineCarpenter ;
2014-12-25 01:00:13 -08:00
import forestry.storage.BackpackDefinition ;
import forestry.storage.BackpackHelper ;
2014-12-26 02:13:39 -08:00
import forestry.storage.CrateRegistry ;
2014-12-25 01:00:13 -08:00
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" )
2015-06-17 01:01:29 -07:00
public class PluginStorage extends ForestryPlugin {
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 > ();
2014-12-25 01:00:13 -08:00
@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 > ();
@Override
2015-01-26 22:26:21 -08:00
@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 ();
2014-09-25 18:08:36 -07:00
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 () {
2015-06-17 01:01:29 -07:00
File configFile = new File ( Forestry . instance . getConfigFolder (), "backpacks.cfg" );
if ( ! configFile . exists ()) {
setDefaultsForConfig ();
}
File oldConfigFile = new File ( Forestry . instance . getConfigFolder (), "backpacks.conf" );
if ( oldConfigFile . exists ()) {
loadOldConfig ();
File oldConfigFileRenamed = new File ( Forestry . instance . getConfigFolder (), "backpacks.conf.old" );
if ( oldConfigFile . renameTo ( oldConfigFileRenamed )) {
Proxies . log . info ( "Migrated backpack settings to the new file 'backpacks.cfg' and renamed 'backpacks.config' to 'backpacks.conf.old'." );
}
}
Configuration config = new Configuration ( configFile );
handleBackpackConfig ( config , "miner" );
handleBackpackConfig ( config , "digger" );
handleBackpackConfig ( config , "forester" );
handleBackpackConfig ( config , "hunter" );
handleBackpackConfig ( config , "adventurer" );
handleBackpackConfig ( config , "builder" );
config . save ();
BackpackDefinition forester = ( BackpackDefinition ) BackpackManager . definitions . get ( "forester" );
forester . addValidBlockClasses ( Arrays . < Class > asList (
IPlantable . class ,
IGrowable . class ,
IShearable . class
));
forester . addValidItemClasses ( Arrays . < Class > asList (
IPlantable . class ,
IGrowable . class
));
BackpackDefinition builder = ( BackpackDefinition ) BackpackManager . definitions . get ( "builder" );
builder . addValidBlockClasses ( Arrays . < Class > asList (
BlockStairs . class ,
BlockFence . class ,
BlockFenceGate . class ,
BlockWall . class ,
BlockBasePressurePlate . class ,
BlockLever . class ,
BlockButton . class ,
BlockTorch . class ,
BlockRedstoneDiode . class ,
BlockChest . class ,
BlockWorkbench . class ,
BlockFurnace . class ,
BlockLadder . class ,
BlockTrapDoor . class ,
BlockDoor . class ,
BlockSlab . class
));
builder . addValidItemClass ( ItemDoor . class );
}
2014-05-02 21:31:20 +02:00
2015-06-17 01:01:29 -07:00
private static void loadOldConfig () {
2014-05-02 21:31:20 +02:00
2015-06-17 01:01:29 -07:00
final forestry . core . config . Configuration config = new forestry . core . config . Configuration ();
final String CONFIG_CATEGORY = "backpacks" ;
forestry . core . config . Property backpackConf = config . get ( "backpacks.miner.items" , CONFIG_CATEGORY , "" );
2015-03-01 01:04:07 -08:00
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: '*'" ;
2015-06-17 01:01:29 -07:00
old_parseBackpackItems ( backpackConf . value , BackpackManager . definitions . get ( "miner" ));
2014-05-02 21:31:20 +02:00
backpackConf = config . get ( "backpacks.digger.items" , CONFIG_CATEGORY , "" );
2015-03-01 01:04:07 -08:00
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: '*'" ;
2015-06-17 01:01:29 -07:00
old_parseBackpackItems ( backpackConf . value , BackpackManager . definitions . get ( "digger" ));
2014-05-02 21:31:20 +02:00
backpackConf = config . get ( "backpacks.forester.items" , CONFIG_CATEGORY , "" );
2015-03-01 01:04:07 -08:00
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: '*'" ;
2015-06-17 01:01:29 -07:00
old_parseBackpackItems ( backpackConf . value , BackpackManager . definitions . get ( "forester" ));
2014-05-02 21:31:20 +02:00
backpackConf = config . get ( "backpacks.hunter.items" , CONFIG_CATEGORY , "" );
2015-03-01 01:04:07 -08:00
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: '*'" ;
2015-06-17 01:01:29 -07:00
old_parseBackpackItems ( backpackConf . value , BackpackManager . definitions . get ( "hunter" ));
2014-05-02 21:31:20 +02:00
backpackConf = config . get ( "backpacks.adventurer.items" , CONFIG_CATEGORY , "" );
2015-03-01 01:04:07 -08:00
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: '*'" ;
2015-06-17 01:01:29 -07:00
old_parseBackpackItems ( backpackConf . value , BackpackManager . definitions . get ( "adventurer" ));
2014-05-02 21:31:20 +02:00
backpackConf = config . get ( "backpacks.builder.items" , CONFIG_CATEGORY , "" );
2015-03-01 01:04:07 -08:00
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: '*'" ;
2015-06-17 01:01:29 -07:00
old_parseBackpackItems ( backpackConf . value , BackpackManager . definitions . get ( "builder" ));
}
2014-05-02 21:31:20 +02:00
2015-06-17 01:01:29 -07:00
private static void old_parseBackpackItems ( String list , IBackpackDefinition backpackDefinition ) {
2015-06-17 01:21:32 -07:00
List < ItemStack > backpackItems = StackUtils . parseItemStackStrings ( list , 0 );
2015-06-17 01:01:29 -07:00
backpackDefinition . addValidItems ( backpackItems );
}
private void setDefaultsForConfig () {
final BackpackDefinition miner = ( BackpackDefinition ) BackpackManager . definitions . get ( "miner" );
final BackpackDefinition digger = ( BackpackDefinition ) BackpackManager . definitions . get ( "digger" );
final BackpackDefinition forester = ( BackpackDefinition ) BackpackManager . definitions . get ( "forester" );
final BackpackDefinition adventurer = ( BackpackDefinition ) BackpackManager . definitions . get ( "adventurer" );
final BackpackDefinition builder = ( BackpackDefinition ) BackpackManager . definitions . get ( "builder" );
final BackpackDefinition hunter = ( BackpackDefinition ) BackpackManager . definitions . get ( "hunter" );
miner . addValidItems ( minerItems );
digger . addValidItems ( diggerItems );
forester . addValidItems ( foresterItems );
hunter . addValidItems ( hunterItems );
adventurer . addValidItems ( adventurerItems );
builder . addValidItems ( builderItems );
final Pattern minerOreDictPattern = Pattern . compile ( "(ore|dust|gem|ingot|nugget|crushed|cluster|denseore)[A-Z].*" );
final Pattern diggerOreDictPattern = Pattern . compile ( "(stone)[A-Z].*" );
final Pattern foresterOreDictPattern = Pattern . compile ( "(crop|seed|tree)[A-Z].*" );
final Pattern builderOreDictPattern = Pattern . compile ( "(block|paneGlass|slabWood|stainedClay|stainedGlass)[A-Z].*" );
final List < String > minerOreDictNames = new ArrayList < String > ();
final List < String > diggerOreDictNames = new ArrayList < String > ( Arrays . asList (
"cobblestone" ,
"stone" ,
"sand"
));
final List < String > foresterOreDictNames = new ArrayList < String > ( Arrays . asList (
"logWood" ,
"stickWood" ,
"woodStick" ,
"saplingTree"
));
final List < String > builderOreDictNames = new ArrayList < String > ( Arrays . asList (
"stone" ,
"plankWood" ,
"stairWood" ,
"slabWood" ,
"fenceWood" ,
"glass" ,
"blockGlass" ,
"paneGlass"
));
for ( String name : OreDictionary . getOreNames ()) {
if ( minerOreDictPattern . matcher ( name ). matches ()) {
minerOreDictNames . add ( name );
} else if ( diggerOreDictPattern . matcher ( name ). matches ()) {
if ( name . equals ( "stoneRod" )) {
continue ;
}
diggerOreDictNames . add ( name );
} else if ( foresterOreDictPattern . matcher ( name ). matches ()) {
foresterOreDictNames . add ( name );
} else if ( builderOreDictPattern . matcher ( name ). matches ()) {
if ( name . equals ( "blockHopper" )) {
continue ;
}
builderOreDictNames . add ( name );
}
}
miner . addValidOreDictNames ( minerOreDictNames );
miner . addValidItems ( Arrays . asList (
new ItemStack ( Blocks . obsidian ),
new ItemStack ( Blocks . coal_ore ),
new ItemStack ( Items . coal ),
ForestryItem . bronzePickaxe . getItemStack (),
ForestryItem . kitPickaxe . getItemStack (),
ForestryItem . brokenBronzePickaxe . getItemStack ()
));
digger . addValidOreDictNames ( diggerOreDictNames );
digger . addValidItems ( Arrays . asList (
new ItemStack ( Blocks . dirt , 1 , Defaults . WILDCARD ),
new ItemStack ( Blocks . gravel ),
new ItemStack ( Items . flint ),
new ItemStack ( Blocks . netherrack ),
new ItemStack ( Blocks . sandstone , 1 , 0 ),
new ItemStack ( Items . clay_ball ),
new ItemStack ( Blocks . soul_sand ),
ForestryItem . bronzeShovel . getItemStack (),
ForestryItem . kitShovel . getItemStack (),
ForestryItem . brokenBronzeShovel . getItemStack ()
));
forester . addValidOreDictNames ( foresterOreDictNames );
forester . addValidItems ( Arrays . asList (
new ItemStack ( Blocks . red_mushroom ),
new ItemStack ( Blocks . brown_mushroom ),
new ItemStack ( Blocks . red_flower ),
new ItemStack ( Blocks . yellow_flower ),
new ItemStack ( Blocks . cactus ),
new ItemStack ( Blocks . tallgrass , 1 , Defaults . WILDCARD ),
new ItemStack ( Blocks . vine ),
new ItemStack ( Blocks . pumpkin ),
new ItemStack ( Blocks . melon_block ),
new ItemStack ( Items . golden_apple ),
new ItemStack ( Items . nether_wart ),
new ItemStack ( Items . pumpkin_seeds ),
new ItemStack ( Items . melon_seeds )
));
hunter . addValidItems ( Arrays . asList (
new ItemStack ( Items . feather ),
new ItemStack ( Items . gunpowder ),
new ItemStack ( Items . blaze_powder ),
new ItemStack ( Items . blaze_rod ),
new ItemStack ( Items . bone ),
new ItemStack ( Items . string ),
new ItemStack ( Items . rotten_flesh ),
new ItemStack ( Items . ghast_tear ),
new ItemStack ( Items . gold_nugget ),
new ItemStack ( Items . arrow ),
new ItemStack ( Items . porkchop ),
new ItemStack ( Items . cooked_porkchop ),
new ItemStack ( Items . beef ),
new ItemStack ( Items . cooked_beef ),
new ItemStack ( Items . chicken ),
new ItemStack ( Items . cooked_chicken ),
new ItemStack ( Items . leather ),
new ItemStack ( Items . egg ),
new ItemStack ( Items . ender_pearl ),
new ItemStack ( Items . spider_eye ),
new ItemStack ( Items . fermented_spider_eye ),
new ItemStack ( Items . slime_ball ),
new ItemStack ( Items . dye , 1 , 0 ),
new ItemStack ( Blocks . hay_block ),
new ItemStack ( Blocks . wool , 1 , Defaults . WILDCARD ),
new ItemStack ( Items . ender_eye ),
new ItemStack ( Items . magma_cream ),
new ItemStack ( Items . speckled_melon ),
new ItemStack ( Items . fish ),
new ItemStack ( Items . cooked_fished ),
new ItemStack ( Items . lead ),
new ItemStack ( Items . fishing_rod ),
new ItemStack ( Items . name_tag ),
new ItemStack ( Items . saddle ),
new ItemStack ( Items . diamond_horse_armor ),
new ItemStack ( Items . golden_horse_armor ),
new ItemStack ( Items . iron_horse_armor )
));
builder . addValidOreDictNames ( builderOreDictNames );
builder . addValidItems ( Arrays . asList (
new ItemStack ( Blocks . torch ),
new ItemStack ( Blocks . redstone_torch ),
new ItemStack ( Blocks . redstone_lamp ),
new ItemStack ( Blocks . stonebrick , 1 , Defaults . WILDCARD ),
new ItemStack ( Blocks . sandstone , 1 , 1 ),
new ItemStack ( Blocks . sandstone , 1 , 2 ),
new ItemStack ( Blocks . brick_block ),
new ItemStack ( Blocks . clay ),
new ItemStack ( Blocks . hardened_clay , 1 , Defaults . WILDCARD ),
new ItemStack ( Blocks . stained_hardened_clay , 1 , Defaults . WILDCARD ),
new ItemStack ( Blocks . packed_ice ),
new ItemStack ( Blocks . nether_brick ),
new ItemStack ( Blocks . crafting_table ),
new ItemStack ( Blocks . furnace ),
new ItemStack ( Blocks . lever ),
new ItemStack ( Blocks . dispenser ),
new ItemStack ( Blocks . dropper ),
new ItemStack ( Blocks . ladder ),
new ItemStack ( Blocks . iron_bars ),
new ItemStack ( Blocks . quartz_block , 1 , Defaults . WILDCARD ),
new ItemStack ( Items . sign ),
new ItemStack ( Items . item_frame )
));
2014-05-02 21:31:20 +02:00
2015-06-17 01:01:29 -07:00
if ( PluginManager . Module . APICULTURE . isEnabled ()) {
builder . addValidItem ( ForestryBlock . candle . getWildcard ());
builder . addValidItem ( ForestryBlock . stump . getWildcard ());
}
}
private static void handleBackpackConfig ( Configuration config , String backpackName ) {
BackpackDefinition backpackDefinition = ( BackpackDefinition ) BackpackManager . definitions . get ( backpackName );
List < ItemStack > backpackItems ;
List < String > backpackOreDict = new ArrayList < String > ();
{
List < String > validItems = backpackDefinition . getValidItemStacks ();
Collections . sort ( validItems );
String [] defaultValidItems = validItems . toArray ( new String [ validItems . size () ] );
Property backpackConf = config . get ( "backpacks." + backpackName , "itemStacks" , defaultValidItems );
backpackConf . comment = "Add itemStacks for the " + backpackName + "'s backpack here in the format 'modid:name:meta'. For wildcard metadata the format is 'modid:name'." ;
String [] backpackItemList = backpackConf . getStringList ();
2015-06-17 01:21:32 -07:00
backpackItems = StackUtils . parseItemStackStrings ( backpackItemList , OreDictionary . WILDCARD_VALUE );
2015-06-17 01:01:29 -07:00
}
{
List < Integer > oreIds = backpackDefinition . getValidOreIds ();
String [] defaultOreNames = new String [ oreIds . size () ] ;
for ( int i = 0 ; i < oreIds . size (); i ++ ) {
int oreId = oreIds . get ( i );
defaultOreNames [ i ] = OreDictionary . getOreName ( oreId );
}
List < String > defaultOreNamesList = new ArrayList < String > ();
Collections . addAll ( defaultOreNamesList , defaultOreNames );
Collections . sort ( defaultOreNamesList );
defaultOreNames = defaultOreNamesList . toArray ( new String [ defaultOreNamesList . size () ] );
Property backpackConf = config . get ( "backpacks." + backpackName , "oreDict" , defaultOreNames );
backpackConf . comment = "Add ore dictionary names for the " + backpackName + "'s backpack here in the format 'oreDictName'." ;
String [] oreDictNameList = backpackConf . getStringList ();
Collections . addAll ( backpackOreDict , oreDictNameList );
}
backpackDefinition . clearAllValid ();
backpackDefinition . addValidItems ( backpackItems );
backpackDefinition . addValidOreDictNames ( backpackOreDict );
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
@Override
public boolean processIMCMessage ( IMCMessage message ) {
if ( message . key . equals ( "add-backpack-items" )) {
String [] tokens = message . getStringValue (). split ( "@" );
if ( tokens . length != 2 ) {
2015-06-13 16:36:46 -07:00
logInvalidIMCMessage ( message );
2014-05-02 21:31:20 +02:00
return true ;
}
if ( ! BackpackManager . definitions . containsKey ( tokens [ 0 ] )) {
2015-06-13 16:36:46 -07:00
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 ;
}
2015-06-17 01:01:29 -07:00
IBackpackDefinition backpackDefinition = BackpackManager . definitions . get ( tokens [ 0 ] );
2015-06-17 01:21:32 -07:00
List < ItemStack > itemStacks = StackUtils . parseItemStackStrings ( tokens [ 1 ] , 0 );
2015-06-17 01:01:29 -07:00
backpackDefinition . addValidItems ( itemStacks );
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 () {
2014-10-01 19:41:18 -07:00
// CRATE
2014-12-26 02:13:39 -08:00
ForestryItem . crate . registerItem (( new ItemCrated ( null , false )), "crate" );
2014-10-01 19:41:18 -07:00
// BACKPACKS
2015-04-05 14:16:41 -07:00
IBackpackDefinition definition ;
2014-05-02 21:31:20 +02:00
2014-10-04 21:56:26 -07: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" );
2014-10-04 21:56:26 -07:00
}
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-10-04 21:56:26 -07:00
}
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" );
2014-08-18 17:45:04 +02:00
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" );
2014-08-18 17:45:04 +02:00
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 registerRecipes () {
2014-10-01 22:28:21 -07:00
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
2015-02-28 20:56:23 -08:00
// / 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
}
}