2012-05-09 22:43:05 +02:00
/ * *
* BuildCraft is open - source . It is distributed under the terms of the
* BuildCraft Open Source License . It grants rights to read , modify , compile
* or run the code . It does * NOT * grant the right to redistribute this software
* or its modifications in any form , binary or source , except if expressively
* granted by the copyright holder .
* /
2012-07-25 12:45:15 +02:00
package buildcraft ;
2012-05-09 22:43:05 +02:00
import java.util.LinkedList ;
2012-10-25 03:57:31 +02:00
import java.util.logging.Level ;
import java.util.logging.Logger ;
2012-12-17 23:30:54 +01:00
import net.minecraft.block.Block ;
import net.minecraft.item.Item ;
import net.minecraft.item.ItemStack ;
import net.minecraft.world.World ;
import net.minecraftforge.common.Configuration ;
import net.minecraftforge.common.Property ;
2013-03-16 09:21:48 +01:00
import buildcraft.api.core.IIconProvider ;
2012-07-25 12:45:15 +02:00
import buildcraft.api.gates.ActionManager ;
import buildcraft.api.recipes.AssemblyRecipe ;
2012-07-27 23:16:34 +02:00
import buildcraft.api.transport.IExtractionHandler ;
2012-12-17 23:30:54 +01:00
import buildcraft.api.transport.IPipe ;
2012-07-27 23:16:34 +02:00
import buildcraft.api.transport.PipeManager ;
2013-03-22 23:00:02 +01:00
import buildcraft.core.CreativeTabBuildCraft ;
2012-07-25 12:45:15 +02:00
import buildcraft.core.DefaultProps ;
import buildcraft.core.ItemBuildCraft ;
2012-09-08 21:46:17 +02:00
import buildcraft.core.Version ;
2013-01-13 19:52:48 +01:00
import buildcraft.core.proxy.CoreProxy ;
2013-03-16 09:21:48 +01:00
import buildcraft.core.triggers.BCAction ;
import buildcraft.core.triggers.BCTrigger ;
2012-07-25 12:45:15 +02:00
import buildcraft.transport.BlockGenericPipe ;
2013-03-16 00:47:08 +01:00
import buildcraft.transport.GateIconProvider ;
2012-08-24 19:25:54 +02:00
import buildcraft.transport.GuiHandler ;
2012-07-25 12:45:15 +02:00
import buildcraft.transport.ItemFacade ;
import buildcraft.transport.ItemGate ;
import buildcraft.transport.ItemPipe ;
import buildcraft.transport.Pipe ;
2013-03-16 00:47:08 +01:00
import buildcraft.transport.PipeIconProvider ;
2012-07-25 12:45:15 +02:00
import buildcraft.transport.PipeTriggerProvider ;
2012-08-24 15:20:43 +02:00
import buildcraft.transport.TransportProxy ;
2013-03-16 00:47:08 +01:00
import buildcraft.transport.WireIconProvider ;
2012-09-05 22:29:38 +02:00
import buildcraft.transport.blueprints.BptBlockPipe ;
import buildcraft.transport.blueprints.BptItemPipeDiamond ;
2013-01-15 02:05:49 +01:00
import buildcraft.transport.blueprints.BptItemPipeEmerald ;
2012-09-05 22:29:38 +02:00
import buildcraft.transport.blueprints.BptItemPipeIron ;
import buildcraft.transport.blueprints.BptItemPipeWooden ;
2012-08-24 19:25:54 +02:00
import buildcraft.transport.network.PacketHandlerTransport ;
2012-07-25 12:45:15 +02:00
import buildcraft.transport.pipes.PipeItemsCobblestone ;
import buildcraft.transport.pipes.PipeItemsDiamond ;
2013-01-15 02:05:49 +01:00
import buildcraft.transport.pipes.PipeItemsEmerald ;
2012-07-25 12:45:15 +02:00
import buildcraft.transport.pipes.PipeItemsGold ;
import buildcraft.transport.pipes.PipeItemsIron ;
import buildcraft.transport.pipes.PipeItemsObsidian ;
import buildcraft.transport.pipes.PipeItemsSandstone ;
import buildcraft.transport.pipes.PipeItemsStone ;
import buildcraft.transport.pipes.PipeItemsVoid ;
import buildcraft.transport.pipes.PipeItemsWood ;
import buildcraft.transport.pipes.PipeLiquidsCobblestone ;
2013-01-15 02:05:49 +01:00
import buildcraft.transport.pipes.PipeLiquidsEmerald ;
2012-07-25 12:45:15 +02:00
import buildcraft.transport.pipes.PipeLiquidsGold ;
import buildcraft.transport.pipes.PipeLiquidsIron ;
import buildcraft.transport.pipes.PipeLiquidsSandstone ;
import buildcraft.transport.pipes.PipeLiquidsStone ;
import buildcraft.transport.pipes.PipeLiquidsVoid ;
import buildcraft.transport.pipes.PipeLiquidsWood ;
import buildcraft.transport.pipes.PipePowerGold ;
import buildcraft.transport.pipes.PipePowerStone ;
import buildcraft.transport.pipes.PipePowerWood ;
import buildcraft.transport.pipes.PipeStructureCobblestone ;
2012-09-05 22:29:38 +02:00
import buildcraft.transport.triggers.ActionEnergyPulser ;
import buildcraft.transport.triggers.ActionSignalOutput ;
import buildcraft.transport.triggers.TriggerPipeContents ;
import buildcraft.transport.triggers.TriggerPipeContents.Kind ;
2012-12-17 23:30:54 +01:00
import buildcraft.transport.triggers.TriggerPipeSignal ;
2012-07-25 12:45:15 +02:00
2012-12-17 23:30:54 +01:00
import com.google.common.base.Splitter ;
import com.google.common.collect.Iterables ;
import com.google.common.primitives.Ints ;
2012-05-09 22:43:05 +02:00
2012-12-17 23:30:54 +01:00
import cpw.mods.fml.common.Mod ;
import cpw.mods.fml.common.Mod.IMCCallback ;
import cpw.mods.fml.common.Mod.Init ;
import cpw.mods.fml.common.Mod.Instance ;
import cpw.mods.fml.common.Mod.PostInit ;
import cpw.mods.fml.common.Mod.PreInit ;
import cpw.mods.fml.common.event.FMLInitializationEvent ;
import cpw.mods.fml.common.event.FMLInterModComms ;
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage ;
import cpw.mods.fml.common.event.FMLPostInitializationEvent ;
import cpw.mods.fml.common.event.FMLPreInitializationEvent ;
import cpw.mods.fml.common.network.NetworkMod ;
import cpw.mods.fml.common.network.NetworkRegistry ;
import cpw.mods.fml.common.registry.GameRegistry ;
import cpw.mods.fml.common.registry.LanguageRegistry ;
@Mod ( version = Version . VERSION , modid = " BuildCraft|Transport " , name = " Buildcraft Transport " , dependencies = DefaultProps . DEPENDENCY_CORE )
@NetworkMod ( channels = { DefaultProps . NET_CHANNEL_NAME } , packetHandler = PacketHandlerTransport . class )
2012-05-09 22:43:05 +02:00
public class BuildCraftTransport {
public static BlockGenericPipe genericPipeBlock ;
public static boolean alwaysConnectPipes ;
2012-07-25 07:57:15 +02:00
public static boolean usePipeLoss ;
2012-05-09 22:43:05 +02:00
public static int maxItemsInPipes ;
2012-12-06 00:07:37 +01:00
public static float pipeDurability ;
2012-05-09 22:43:05 +02:00
public static Item pipeWaterproof ;
public static Item pipeGate ;
public static Item pipeGateAutarchic ;
public static Item redPipeWire ;
public static Item bluePipeWire ;
public static Item greenPipeWire ;
public static Item yellowPipeWire ;
public static Item pipeItemsWood ;
2013-01-15 02:05:49 +01:00
public static Item pipeItemsEmerald ;
2012-05-09 22:43:05 +02:00
public static Item pipeItemsStone ;
public static Item pipeItemsCobblestone ;
public static Item pipeItemsIron ;
public static Item pipeItemsGold ;
public static Item pipeItemsDiamond ;
public static Item pipeItemsObsidian ;
2012-06-28 16:26:50 +02:00
public static Item pipeItemsVoid ;
2012-06-28 17:25:09 +02:00
public static Item pipeItemsSandstone ;
2012-05-09 22:43:05 +02:00
public static Item pipeLiquidsWood ;
public static Item pipeLiquidsCobblestone ;
public static Item pipeLiquidsStone ;
public static Item pipeLiquidsIron ;
public static Item pipeLiquidsGold ;
2012-06-28 16:26:50 +02:00
public static Item pipeLiquidsVoid ;
2012-06-28 17:25:09 +02:00
public static Item pipeLiquidsSandstone ;
2013-01-15 02:05:49 +01:00
public static Item pipeLiquidsEmerald ;
2012-05-09 22:43:05 +02:00
public static Item pipePowerWood ;
public static Item pipePowerStone ;
public static Item pipePowerGold ;
2012-08-24 15:20:43 +02:00
2012-07-13 21:52:39 +02:00
public static Item facadeItem ;
2012-05-09 22:43:05 +02:00
2012-12-17 23:30:54 +01:00
// public static Item pipeItemsStipes;
2012-05-09 22:43:05 +02:00
public static Item pipeStructureCobblestone ;
public static int groupItemsTrigger ;
2013-03-16 09:21:48 +01:00
public static BCTrigger triggerPipeEmpty = new TriggerPipeContents ( DefaultProps . TRIGGER_PIPE_EMPTY , Kind . Empty ) ;
public static BCTrigger triggerPipeItems = new TriggerPipeContents ( DefaultProps . TRIGGER_PIPE_ITEMS , Kind . ContainsItems ) ;
public static BCTrigger triggerPipeLiquids = new TriggerPipeContents ( DefaultProps . TRIGGER_PIPE_LIQUIDS , Kind . ContainsLiquids ) ;
public static BCTrigger triggerPipeEnergy = new TriggerPipeContents ( DefaultProps . TRIGGER_PIPE_ENERGY , Kind . ContainsEnergy ) ;
public static BCTrigger triggerRedSignalActive = new TriggerPipeSignal ( DefaultProps . TRIGGER_RED_SIGNAL_ACTIVE , true , IPipe . WireColor . Red ) ;
public static BCTrigger triggerRedSignalInactive = new TriggerPipeSignal ( DefaultProps . TRIGGER_RED_SIGNAL_INACTIVE , false , IPipe . WireColor . Red ) ;
public static BCTrigger triggerBlueSignalActive = new TriggerPipeSignal ( DefaultProps . TRIGGER_BLUE_SIGNAL_ACTIVE , true , IPipe . WireColor . Blue ) ;
public static BCTrigger triggerBlueSignalInactive = new TriggerPipeSignal ( DefaultProps . TRIGGER_BLUE_SIGNAL_INACTIVE , false , IPipe . WireColor . Blue ) ;
public static BCTrigger triggerGreenSignalActive = new TriggerPipeSignal ( DefaultProps . TRIGGER_GREEN_SIGNAL_ACTIVE , true , IPipe . WireColor . Green ) ;
public static BCTrigger triggerGreenSignalInactive = new TriggerPipeSignal ( DefaultProps . TRIGGER_GREEN_SIGNAL_INACTIVE , false , IPipe . WireColor . Green ) ;
public static BCTrigger triggerYellowSignalActive = new TriggerPipeSignal ( DefaultProps . TRIGGER_YELLOW_SIGNAL_ACTIVE , true , IPipe . WireColor . Yellow ) ;
public static BCTrigger triggerYellowSignalInactive = new TriggerPipeSignal ( DefaultProps . TRIGGER_YELLOW_SIGNAL_INACTIVE , false , IPipe . WireColor . Yellow ) ;
public static BCAction actionRedSignal = new ActionSignalOutput ( DefaultProps . ACTION_RED_SIGNAL , IPipe . WireColor . Red ) ;
public static BCAction actionBlueSignal = new ActionSignalOutput ( DefaultProps . ACTION_BLUE_SIGNAL , IPipe . WireColor . Blue ) ;
public static BCAction actionGreenSignal = new ActionSignalOutput ( DefaultProps . ACTION_GREEN_SIGNAL , IPipe . WireColor . Green ) ;
public static BCAction actionYellowSignal = new ActionSignalOutput ( DefaultProps . ACTION_YELLOW_SIGNAL , IPipe . WireColor . Yellow ) ;
public static BCAction actionEnergyPulser = new ActionEnergyPulser ( DefaultProps . ACTION_ENERGY_PULSER ) ;
2012-08-24 15:20:43 +02:00
2012-08-26 20:27:37 +02:00
@Instance ( " BuildCraft|Transport " )
2012-08-24 19:25:54 +02:00
public static BuildCraftTransport instance ;
2013-03-16 00:47:08 +01:00
public IIconProvider pipeIconProvider = new PipeIconProvider ( ) ;
public IIconProvider gateIconProvider = new GateIconProvider ( ) ;
public IIconProvider wireIconProvider = new WireIconProvider ( ) ;
2012-05-09 22:43:05 +02:00
private static class PipeRecipe {
boolean isShapeless = false ; // pipe recipes come shaped and unshaped.
ItemStack result ;
2012-06-04 22:48:18 +02:00
Object [ ] input ;
2012-05-09 22:43:05 +02:00
}
2012-08-24 19:25:54 +02:00
private static class ExtractionHandler implements IExtractionHandler {
2012-12-17 23:30:54 +01:00
private final String [ ] items ;
private final String [ ] liquids ;
2012-10-19 04:48:58 +02:00
2012-12-17 23:30:54 +01:00
public ExtractionHandler ( String [ ] items , String [ ] liquids ) {
this . items = items ;
this . liquids = liquids ;
}
2012-10-19 04:48:58 +02:00
2012-12-17 23:30:54 +01:00
@Override
public boolean canExtractItems ( IPipe pipe , World world , int i , int j , int k ) {
return testStrings ( items , world , i , j , k ) ;
}
2012-10-19 04:48:58 +02:00
2012-12-17 23:30:54 +01:00
@Override
public boolean canExtractLiquids ( IPipe pipe , World world , int i , int j , int k ) {
return testStrings ( liquids , world , i , j , k ) ;
}
2012-10-19 04:48:58 +02:00
2012-12-17 23:30:54 +01:00
private boolean testStrings ( String [ ] excludedBlocks , World world , int i , int j , int k ) {
int id = world . getBlockId ( i , j , k ) ;
Block block = Block . blocksList [ id ] ;
if ( block = = null )
return false ;
2012-10-19 04:48:58 +02:00
2012-12-17 23:30:54 +01:00
int meta = world . getBlockMetadata ( i , j , k ) ;
2012-10-19 04:48:58 +02:00
2012-12-17 23:30:54 +01:00
for ( String excluded : excludedBlocks ) {
2013-03-07 00:22:17 +01:00
if ( excluded . equals ( block . getUnlocalizedName ( ) ) )
2012-12-17 23:30:54 +01:00
return false ;
2012-10-19 04:48:58 +02:00
2012-12-17 23:30:54 +01:00
String [ ] tokens = excluded . split ( " : " ) ;
if ( tokens [ 0 ] . equals ( Integer . toString ( id ) ) & & ( tokens . length = = 1 | | tokens [ 1 ] . equals ( Integer . toString ( meta ) ) ) )
return false ;
2012-10-19 04:48:58 +02:00
}
2012-12-17 23:30:54 +01:00
return true ;
2012-10-19 04:48:58 +02:00
}
2012-12-17 23:30:54 +01:00
}
2012-07-27 23:16:34 +02:00
2012-08-24 19:25:54 +02:00
private static LinkedList < PipeRecipe > pipeRecipes = new LinkedList < PipeRecipe > ( ) ;
2012-08-24 15:20:43 +02:00
2012-08-24 19:25:54 +02:00
@PreInit
2012-12-17 23:30:54 +01:00
public void preInitialize ( FMLPreInitializationEvent evt ) {
try {
Property alwaysConnect = BuildCraftCore . mainConfiguration . get ( Configuration . CATEGORY_GENERAL , " pipes.alwaysConnect " ,
DefaultProps . PIPES_ALWAYS_CONNECT ) ;
2012-08-24 19:25:54 +02:00
alwaysConnect . comment = " set to false to deactivate pipe connection rules, true by default " ;
alwaysConnectPipes = alwaysConnect . getBoolean ( DefaultProps . PIPES_ALWAYS_CONNECT ) ;
2012-07-27 23:16:34 +02:00
2012-12-17 23:30:54 +01:00
Property pipeLoss = BuildCraftCore . mainConfiguration . get ( Configuration . CATEGORY_GENERAL , " power.usePipeLoss " , DefaultProps . USE_PIPELOSS ) ;
2012-08-24 19:25:54 +02:00
pipeLoss . comment = " Set to false to turn off energy loss over distance on all power pipes " ;
usePipeLoss = pipeLoss . getBoolean ( DefaultProps . USE_PIPELOSS ) ;
2012-07-27 23:16:34 +02:00
2012-12-06 00:07:37 +01:00
Property durability = BuildCraftCore . mainConfiguration . get ( Configuration . CATEGORY_GENERAL , " pipes.durability " , DefaultProps . PIPES_DURABILITY ) ;
durability . comment = " How long a pipe will take to break " ;
2012-12-17 23:30:54 +01:00
pipeDurability = ( float ) durability . getDouble ( DefaultProps . PIPES_DURABILITY ) ;
2013-03-07 06:31:35 +01:00
Property exclusionItemList = BuildCraftCore . mainConfiguration . get ( Configuration . CATEGORY_BLOCK , " woodenPipe.item.exclusion " , new String [ 0 ] ) ;
2012-07-27 23:16:34 +02:00
2013-03-07 06:31:35 +01:00
String [ ] excludedItemBlocks = exclusionItemList . getStringList ( ) ;
2012-12-17 23:30:54 +01:00
for ( int j = 0 ; j < excludedItemBlocks . length ; + + j ) {
2012-08-24 19:25:54 +02:00
excludedItemBlocks [ j ] = excludedItemBlocks [ j ] . trim ( ) ;
}
2012-07-27 23:16:34 +02:00
2013-03-07 06:31:35 +01:00
Property exclusionLiquidList = BuildCraftCore . mainConfiguration . get ( Configuration . CATEGORY_BLOCK , " woodenPipe.liquid.exclusion " , new String [ 0 ] ) ;
2012-07-27 23:16:34 +02:00
2013-03-07 06:31:35 +01:00
String [ ] excludedLiquidBlocks = exclusionLiquidList . getStringList ( ) ;
2012-12-17 23:30:54 +01:00
for ( int j = 0 ; j < excludedLiquidBlocks . length ; + + j ) {
2012-08-24 19:25:54 +02:00
excludedLiquidBlocks [ j ] = excludedLiquidBlocks [ j ] . trim ( ) ;
}
2012-05-09 22:43:05 +02:00
2012-08-24 19:25:54 +02:00
PipeManager . registerExtractionHandler ( new ExtractionHandler ( excludedItemBlocks , excludedLiquidBlocks ) ) ;
2012-05-09 22:43:05 +02:00
2012-12-17 23:30:54 +01:00
Property maxItemInPipesProp = BuildCraftCore . mainConfiguration . get ( Configuration . CATEGORY_GENERAL , " pipes.maxItems " , 100 ) ;
2012-08-24 19:25:54 +02:00
maxItemInPipesProp . comment = " pipes containing more than this amount of items will explode, not dropping any item " ;
2012-05-09 22:43:05 +02:00
2013-03-07 06:31:35 +01:00
maxItemsInPipes = maxItemInPipesProp . getInt ( ) ;
2012-08-24 15:20:43 +02:00
2012-12-17 23:30:54 +01:00
Property groupItemsTriggerProp = BuildCraftCore . mainConfiguration . get ( Configuration . CATEGORY_GENERAL , " pipes.groupItemsTrigger " , 32 ) ;
2012-08-24 19:25:54 +02:00
groupItemsTriggerProp . comment = " when reaching this amount of objects in a pipes, items will be automatically grouped " ;
2012-05-09 22:43:05 +02:00
2013-03-07 06:31:35 +01:00
groupItemsTrigger = groupItemsTriggerProp . getInt ( ) ;
2012-07-27 23:16:34 +02:00
2013-03-12 20:43:39 +01:00
2012-11-21 12:50:31 +01:00
Property genericPipeId = BuildCraftCore . mainConfiguration . getBlock ( " pipe.id " , DefaultProps . GENERIC_PIPE_ID ) ;
2012-09-17 05:49:08 +02:00
2012-11-21 12:50:31 +01:00
Property pipeWaterproofId = BuildCraftCore . mainConfiguration . getItem ( " pipeWaterproof.id " , DefaultProps . PIPE_WATERPROOF_ID ) ;
2012-07-27 23:16:34 +02:00
2013-03-07 06:31:35 +01:00
pipeWaterproof = new ItemBuildCraft ( pipeWaterproofId . getInt ( ) ) ;
2013-03-07 00:22:17 +01:00
pipeWaterproof . setUnlocalizedName ( " pipeWaterproof " ) ;
2013-03-22 23:00:02 +01:00
pipeWaterproof . setCreativeTab ( CreativeTabBuildCraft . tabBuildCraft ) ;
2012-08-24 19:25:54 +02:00
LanguageRegistry . addName ( pipeWaterproof , " Pipe Waterproof " ) ;
2013-03-07 06:31:35 +01:00
genericPipeBlock = new BlockGenericPipe ( genericPipeId . getInt ( ) ) ;
2012-08-24 19:25:54 +02:00
GameRegistry . registerBlock ( genericPipeBlock ) ;
2012-07-27 23:16:34 +02:00
2012-08-24 19:25:54 +02:00
// Fixing retro-compatiblity
2013-01-13 19:52:48 +01:00
pipeItemsWood = createPipe ( DefaultProps . PIPE_ITEMS_WOOD_ID , PipeItemsWood . class , " Wooden Transport Pipe " , " plankWood " , Block . glass , " plankWood " ) ;
2013-01-15 02:05:49 +01:00
pipeItemsEmerald = createPipe ( DefaultProps . PIPE_ITEMS_EMERALD_ID , PipeItemsEmerald . class , " Emerald Transport Pipe " , Item . emerald , Block . glass , Item . emerald ) ;
pipeItemsCobblestone = createPipe ( DefaultProps . PIPE_ITEMS_COBBLESTONE_ID , PipeItemsCobblestone . class , " Cobblestone Transport Pipe " , Block . cobblestone , Block . glass , Block . cobblestone ) ;
2012-08-24 19:25:54 +02:00
pipeItemsStone = createPipe ( DefaultProps . PIPE_ITEMS_STONE_ID , PipeItemsStone . class , " Stone Transport Pipe " , Block . stone , Block . glass , Block . stone ) ;
pipeItemsIron = createPipe ( DefaultProps . PIPE_ITEMS_IRON_ID , PipeItemsIron . class , " Iron Transport Pipe " , Item . ingotIron , Block . glass , Item . ingotIron ) ;
2013-01-15 02:05:49 +01:00
pipeItemsGold = createPipe ( DefaultProps . PIPE_ITEMS_GOLD_ID , PipeItemsGold . class , " Golden Transport Pipe " , Item . ingotGold , Block . glass , Item . ingotGold ) ;
pipeItemsDiamond = createPipe ( DefaultProps . PIPE_ITEMS_DIAMOND_ID , PipeItemsDiamond . class , " Diamond Transport Pipe " , Item . diamond , Block . glass , Item . diamond ) ;
pipeItemsObsidian = createPipe ( DefaultProps . PIPE_ITEMS_OBSIDIAN_ID , PipeItemsObsidian . class , " Obsidian Transport Pipe " , Block . obsidian , Block . glass , Block . obsidian ) ;
pipeLiquidsWood = createPipe ( DefaultProps . PIPE_LIQUIDS_WOOD_ID , PipeLiquidsWood . class , " Wooden Waterproof Pipe " , pipeWaterproof , pipeItemsWood , null ) ;
pipeLiquidsCobblestone = createPipe ( DefaultProps . PIPE_LIQUIDS_COBBLESTONE_ID , PipeLiquidsCobblestone . class , " Cobblestone Waterproof Pipe " , pipeWaterproof , pipeItemsCobblestone , null ) ;
pipeLiquidsStone = createPipe ( DefaultProps . PIPE_LIQUIDS_STONE_ID , PipeLiquidsStone . class , " Stone Waterproof Pipe " , pipeWaterproof , pipeItemsStone , null ) ;
2012-08-24 19:25:54 +02:00
pipeLiquidsIron = createPipe ( DefaultProps . PIPE_LIQUIDS_IRON_ID , PipeLiquidsIron . class , " Iron Waterproof Pipe " , pipeWaterproof , pipeItemsIron , null ) ;
2013-01-15 02:05:49 +01:00
pipeLiquidsGold = createPipe ( DefaultProps . PIPE_LIQUIDS_GOLD_ID , PipeLiquidsGold . class , " Golden Waterproof Pipe " , pipeWaterproof , pipeItemsGold , null ) ;
pipeLiquidsEmerald = createPipe ( DefaultProps . PIPE_LIQUIDS_EMERALD_ID , PipeLiquidsEmerald . class , " Emerald Waterproof Pipe " , pipeWaterproof , pipeItemsEmerald , null ) ;
2012-05-09 22:43:05 +02:00
2012-08-24 19:25:54 +02:00
pipePowerWood = createPipe ( DefaultProps . PIPE_POWER_WOOD_ID , PipePowerWood . class , " Wooden Conductive Pipe " , Item . redstone , pipeItemsWood , null ) ;
pipePowerStone = createPipe ( DefaultProps . PIPE_POWER_STONE_ID , PipePowerStone . class , " Stone Conductive Pipe " , Item . redstone , pipeItemsStone , null ) ;
pipePowerGold = createPipe ( DefaultProps . PIPE_POWER_GOLD_ID , PipePowerGold . class , " Golden Conductive Pipe " , Item . redstone , pipeItemsGold , null ) ;
2012-05-09 22:43:05 +02:00
2013-01-15 02:05:49 +01:00
pipeStructureCobblestone = createPipe ( DefaultProps . PIPE_STRUCTURE_COBBLESTONE_ID , PipeStructureCobblestone . class , " Cobblestone Structure Pipe " , Block . gravel , pipeItemsCobblestone , null ) ;
2012-05-09 22:43:05 +02:00
2012-08-24 19:25:54 +02:00
// Fix the recipe
2012-12-17 23:30:54 +01:00
// pipeItemsStipes = createPipe(DefaultProps.PIPE_ITEMS_STRIPES_ID, PipeItemsStripes.class, "Stripes Transport Pipe", new ItemStack(Item.dyePowder,
// 1, 0), Block.glass, new ItemStack(Item.dyePowder, 1, 11));
2012-05-09 22:43:05 +02:00
2012-12-17 23:30:54 +01:00
pipeItemsVoid = createPipe ( DefaultProps . PIPE_ITEMS_VOID_ID , PipeItemsVoid . class , " Void Transport Pipe " , new ItemStack ( Item . dyePowder , 1 , 0 ) ,
Block . glass , Item . redstone ) ;
2012-05-09 22:43:05 +02:00
2012-08-24 19:25:54 +02:00
pipeLiquidsVoid = createPipe ( DefaultProps . PIPE_LIQUIDS_VOID_ID , PipeLiquidsVoid . class , " Void Waterproof Pipe " , pipeWaterproof , pipeItemsVoid , null ) ;
2012-05-09 22:43:05 +02:00
2012-12-17 23:30:54 +01:00
pipeItemsSandstone = createPipe ( DefaultProps . PIPE_ITEMS_SANDSTONE_ID , PipeItemsSandstone . class , " Sandstone Transport Pipe " , Block . sandStone ,
Block . glass , Block . sandStone ) ;
2012-05-09 22:43:05 +02:00
2012-12-17 23:30:54 +01:00
pipeLiquidsSandstone = createPipe ( DefaultProps . PIPE_LIQUIDS_SANDSTONE_ID , PipeLiquidsSandstone . class , " Sandstone Waterproof Pipe " , pipeWaterproof ,
pipeItemsSandstone , null ) ;
2013-01-03 13:55:14 +01:00
Property redPipeWireId = BuildCraftCore . mainConfiguration . get ( Configuration . CATEGORY_ITEM , " redPipeWire.id " , DefaultProps . RED_PIPE_WIRE ) ;
2013-03-07 06:31:35 +01:00
redPipeWire = new ItemBuildCraft ( redPipeWireId . getInt ( ) ) ;
2013-03-07 00:22:17 +01:00
redPipeWire . setUnlocalizedName ( " redPipeWire " ) ;
2013-01-03 13:55:14 +01:00
LanguageRegistry . addName ( redPipeWire , " Red Pipe Wire " ) ;
AssemblyRecipe . assemblyRecipes . add ( new AssemblyRecipe ( new ItemStack [ ] { new ItemStack ( Item . dyePowder , 1 , 1 ) , new ItemStack ( Item . redstone , 1 ) ,
new ItemStack ( Item . ingotIron , 1 ) } , 500 , new ItemStack ( redPipeWire , 8 ) ) ) ;
Property bluePipeWireId = BuildCraftCore . mainConfiguration . get ( Configuration . CATEGORY_ITEM , " bluePipeWire.id " , DefaultProps . BLUE_PIPE_WIRE ) ;
2013-03-07 06:31:35 +01:00
bluePipeWire = new ItemBuildCraft ( bluePipeWireId . getInt ( ) ) ;
2013-03-07 00:22:17 +01:00
bluePipeWire . setUnlocalizedName ( " bluePipeWire " ) ;
2013-01-03 13:55:14 +01:00
LanguageRegistry . addName ( bluePipeWire , " Blue Pipe Wire " ) ;
AssemblyRecipe . assemblyRecipes . add ( new AssemblyRecipe ( new ItemStack [ ] { new ItemStack ( Item . dyePowder , 1 , 4 ) , new ItemStack ( Item . redstone , 1 ) ,
new ItemStack ( Item . ingotIron , 1 ) } , 500 , new ItemStack ( bluePipeWire , 8 ) ) ) ;
Property greenPipeWireId = BuildCraftCore . mainConfiguration . get ( Configuration . CATEGORY_ITEM , " greenPipeWire.id " , DefaultProps . GREEN_PIPE_WIRE ) ;
2013-03-07 06:31:35 +01:00
greenPipeWire = new ItemBuildCraft ( greenPipeWireId . getInt ( ) ) ;
2013-03-07 00:22:17 +01:00
greenPipeWire . setUnlocalizedName ( " greenPipeWire " ) ;
2013-01-03 13:55:14 +01:00
LanguageRegistry . addName ( greenPipeWire , " Green Pipe Wire " ) ;
AssemblyRecipe . assemblyRecipes . add ( new AssemblyRecipe ( new ItemStack [ ] { new ItemStack ( Item . dyePowder , 1 , 2 ) , new ItemStack ( Item . redstone , 1 ) ,
new ItemStack ( Item . ingotIron , 1 ) } , 500 , new ItemStack ( greenPipeWire , 8 ) ) ) ;
Property yellowPipeWireId = BuildCraftCore . mainConfiguration . get ( Configuration . CATEGORY_ITEM , " yellowPipeWire.id " , DefaultProps . YELLOW_PIPE_WIRE ) ;
2013-03-07 06:31:35 +01:00
yellowPipeWire = new ItemBuildCraft ( yellowPipeWireId . getInt ( ) ) ;
2013-03-07 00:22:17 +01:00
yellowPipeWire . setUnlocalizedName ( " yellowPipeWire " ) ;
2013-01-03 13:55:14 +01:00
LanguageRegistry . addName ( yellowPipeWire , " Yellow Pipe Wire " ) ;
AssemblyRecipe . assemblyRecipes . add ( new AssemblyRecipe ( new ItemStack [ ] { new ItemStack ( Item . dyePowder , 1 , 11 ) , new ItemStack ( Item . redstone , 1 ) ,
new ItemStack ( Item . ingotIron , 1 ) } , 500 , new ItemStack ( yellowPipeWire , 8 ) ) ) ;
Property pipeGateId = BuildCraftCore . mainConfiguration . get ( Configuration . CATEGORY_ITEM , " pipeGate.id " , DefaultProps . GATE_ID ) ;
2013-03-07 06:31:35 +01:00
pipeGate = new ItemGate ( pipeGateId . getInt ( ) , 0 ) ;
2013-03-07 00:22:17 +01:00
pipeGate . setUnlocalizedName ( " pipeGate " ) ;
2013-01-03 13:55:14 +01:00
Property pipeGateAutarchicId = BuildCraftCore . mainConfiguration . get ( Configuration . CATEGORY_ITEM , " pipeGateAutarchic.id " ,
DefaultProps . GATE_AUTARCHIC_ID ) ;
2013-03-07 06:31:35 +01:00
pipeGateAutarchic = new ItemGate ( pipeGateAutarchicId . getInt ( ) , 1 ) ;
2013-03-07 00:22:17 +01:00
pipeGateAutarchic . setUnlocalizedName ( " pipeGateAutarchic " ) ;
2013-01-03 13:55:14 +01:00
Property pipeFacadeId = BuildCraftCore . mainConfiguration . get ( Configuration . CATEGORY_ITEM , " pipeFacade.id " , DefaultProps . PIPE_FACADE_ID ) ;
2013-03-07 06:31:35 +01:00
facadeItem = new ItemFacade ( pipeFacadeId . getInt ( ) ) ;
2013-03-07 00:22:17 +01:00
facadeItem . setUnlocalizedName ( " pipeFacade " ) ;
2013-01-03 13:55:14 +01:00
2012-12-17 23:30:54 +01:00
} finally {
2012-08-24 19:25:54 +02:00
BuildCraftCore . mainConfiguration . save ( ) ;
}
}
2012-10-19 04:48:58 +02:00
2012-08-24 19:25:54 +02:00
@Init
public void load ( FMLInitializationEvent evt ) {
// Register connection handler
2012-12-17 23:30:54 +01:00
// MinecraftForge.registerConnectionHandler(new ConnectionHandler());
2012-05-09 22:43:05 +02:00
2012-08-24 19:25:54 +02:00
// Register gui handler
2012-12-17 23:30:54 +01:00
// MinecraftForge.setGuiHandler(mod_BuildCraftTransport.instance, new GuiHandler());
2012-05-09 22:43:05 +02:00
2012-08-24 15:20:43 +02:00
TransportProxy . proxy . registerTileEntities ( ) ;
2012-05-09 22:43:05 +02:00
2012-06-04 22:48:18 +02:00
// dockingStationBlock = new
// BlockDockingStation(Integer.parseInt(dockingStationId.value));
// ModLoader.registerBlock(dockingStationBlock);
// CoreProxy.addName(dockingStationBlock.setBlockName("dockingStation"),
// "Docking Station");
2012-05-09 22:43:05 +02:00
2012-06-04 22:48:18 +02:00
// ModLoader.RegisterTileEntity(TileDockingStation.class,
// "net.minecraft.src.buildcraft.TileDockingStation");
2012-05-09 22:43:05 +02:00
2012-06-04 22:48:18 +02:00
new BptBlockPipe ( genericPipeBlock . blockID ) ;
2012-05-09 22:43:05 +02:00
2012-12-28 21:29:35 +01:00
BuildCraftCore . itemBptProps [ pipeItemsWood . itemID ] = new BptItemPipeWooden ( ) ;
BuildCraftCore . itemBptProps [ pipeLiquidsWood . itemID ] = new BptItemPipeWooden ( ) ;
BuildCraftCore . itemBptProps [ pipeItemsIron . itemID ] = new BptItemPipeIron ( ) ;
BuildCraftCore . itemBptProps [ pipeLiquidsIron . itemID ] = new BptItemPipeIron ( ) ;
BuildCraftCore . itemBptProps [ pipeItemsDiamond . itemID ] = new BptItemPipeDiamond ( ) ;
2013-01-15 02:05:49 +01:00
BuildCraftCore . itemBptProps [ pipeItemsEmerald . itemID ] = new BptItemPipeEmerald ( ) ;
2012-05-09 22:43:05 +02:00
2012-07-20 20:13:05 +02:00
ActionManager . registerTriggerProvider ( new PipeTriggerProvider ( ) ) ;
2012-05-09 22:43:05 +02:00
2012-12-17 23:30:54 +01:00
if ( BuildCraftCore . loadDefaultRecipes ) {
2012-05-09 22:43:05 +02:00
loadRecipes ( ) ;
2012-08-24 19:25:54 +02:00
}
TransportProxy . proxy . registerRenderers ( ) ;
NetworkRegistry . instance ( ) . registerGuiHandler ( instance , new GuiHandler ( ) ) ;
2012-05-09 22:43:05 +02:00
}
2012-10-19 04:48:58 +02:00
@PostInit
public void postInit ( FMLPostInitializationEvent evt ) {
ItemFacade . initialize ( ) ;
}
public void loadRecipes ( ) {
2012-05-09 22:43:05 +02:00
// Add base recipe for pipe waterproof.
2012-08-24 19:25:54 +02:00
GameRegistry . addShapelessRecipe ( new ItemStack ( pipeWaterproof , 1 ) , new ItemStack ( Item . dyePowder , 1 , 2 ) ) ;
2012-05-09 22:43:05 +02:00
// Add pipe recipes
2012-12-17 23:30:54 +01:00
for ( PipeRecipe pipe : pipeRecipes ) {
if ( pipe . isShapeless ) {
2012-08-24 19:25:54 +02:00
GameRegistry . addShapelessRecipe ( pipe . result , pipe . input ) ;
2012-12-17 23:30:54 +01:00
} else {
2013-01-13 19:52:48 +01:00
CoreProxy . proxy . addCraftingRecipe ( pipe . result , pipe . input ) ;
2012-08-24 19:25:54 +02:00
}
}
2012-05-09 22:43:05 +02:00
}
2012-10-25 03:57:31 +02:00
@IMCCallback
2012-12-03 04:17:00 +01:00
public void processIMCRequests ( FMLInterModComms . IMCEvent event ) {
Splitter splitter = Splitter . on ( " @ " ) . trimResults ( ) ;
for ( IMCMessage m : event . getMessages ( ) ) {
if ( " add-facade " . equals ( m . key ) ) {
2012-12-18 20:43:22 +01:00
String [ ] array = Iterables . toArray ( splitter . split ( m . getStringValue ( ) ) , String . class ) ;
2012-12-03 04:17:00 +01:00
if ( array . length ! = 2 ) {
2013-01-03 13:55:14 +01:00
Logger . getLogger ( " Buildcraft " ) . log ( Level . INFO ,
String . format ( " Received an invalid add-facade request %s from mod %s " , m . getStringValue ( ) , m . getSender ( ) ) ) ;
2012-12-03 04:17:00 +01:00
continue ;
}
Integer blId = Ints . tryParse ( array [ 0 ] ) ;
Integer metaId = Ints . tryParse ( array [ 1 ] ) ;
if ( blId = = null | | metaId = = null ) {
2013-01-03 13:55:14 +01:00
Logger . getLogger ( " Buildcraft " ) . log ( Level . INFO ,
String . format ( " Received an invalid add-facade request %s from mod %s " , m . getStringValue ( ) , m . getSender ( ) ) ) ;
2012-12-03 04:17:00 +01:00
continue ;
}
ItemFacade . addFacade ( new ItemStack ( blId , 1 , metaId ) ) ;
}
}
2012-10-25 03:57:31 +02:00
}
2013-01-13 19:02:41 +01:00
public static Item createPipe ( int defaultID , Class < ? extends Pipe > clas , String descr , Object ingredient1 , Object ingredient2 , Object ingredient3 ) {
2012-06-08 02:13:31 +02:00
String name = Character . toLowerCase ( clas . getSimpleName ( ) . charAt ( 0 ) ) + clas . getSimpleName ( ) . substring ( 1 ) ;
2012-05-09 22:43:05 +02:00
2012-10-19 04:48:58 +02:00
Property prop = BuildCraftCore . mainConfiguration . getItem ( name + " .id " , defaultID ) ;
2012-05-09 22:43:05 +02:00
2012-08-24 19:25:54 +02:00
int id = prop . getInt ( defaultID ) ;
2012-07-16 01:23:19 +02:00
ItemPipe res = BlockGenericPipe . registerPipe ( id , clas ) ;
2013-03-07 00:22:17 +01:00
res . setUnlocalizedName ( clas . getSimpleName ( ) ) ;
2012-08-24 19:25:54 +02:00
LanguageRegistry . addName ( res , descr ) ;
2012-05-09 22:43:05 +02:00
// Add appropriate recipe to temporary list
2012-06-04 22:48:18 +02:00
PipeRecipe recipe = new PipeRecipe ( ) ;
2012-05-09 22:43:05 +02:00
if ( ingredient1 ! = null & & ingredient2 ! = null & & ingredient3 ! = null ) {
recipe . result = new ItemStack ( res , 8 ) ;
2012-09-09 12:29:55 +02:00
recipe . input = new Object [ ] { " ABC " , Character . valueOf ( 'A' ) , ingredient1 , Character . valueOf ( 'B' ) , ingredient2 , Character . valueOf ( 'C' ) , ingredient3 } ;
2012-05-09 22:43:05 +02:00
pipeRecipes . add ( recipe ) ;
} else if ( ingredient1 ! = null & & ingredient2 ! = null ) {
recipe . isShapeless = true ;
recipe . result = new ItemStack ( res , 1 ) ;
2012-06-04 22:48:18 +02:00
recipe . input = new Object [ ] { ingredient1 , ingredient2 } ;
2012-05-09 22:43:05 +02:00
pipeRecipes . add ( recipe ) ;
}
return res ;
}
}