diff --git a/resources/assets/fm/languages/en_US.properties b/resources/assets/fm/languages/en_US.properties index 2dc38e4b2..af6746821 100644 --- a/resources/assets/fm/languages/en_US.properties +++ b/resources/assets/fm/languages/en_US.properties @@ -11,39 +11,223 @@ tile.ReleaseValve.0.name=Release Valve tile.FluidTank.name = Tank tile.FluidSink.name = Sink -tile.FluidPipe.0.name =Black Pipe -tile.FluidPipe.1.name =Red Pipe -tile.FluidPipe.2.name =Green Pipe -tile.FluidPipe.3.name =Brown Pipe -tile.FluidPipe.4.name =Blue Pipe -tile.FluidPipe.5.name =Purple Pipe -tile.FluidPipe.6.name =Cyan Pipe -tile.FluidPipe.7.name =Silver Pipe -tile.FluidPipe.8.name =Grey Pipe -tile.FluidPipe.9.name =Pink Pipe -tile.FluidPipe.10.name =Lime Pipe -tile.FluidPipe.11.name =Yellow Pipe -tile.FluidPipe.12.name =LightBlue Pipe -tile.FluidPipe.13.name =Mangenta Pipe -tile.FluidPipe.14.name =Orange Pipe -tile.FluidPipe.15.name =White Pipe +# Fluid pipes now have more than 32 sub types, currently there are only 160 sub types of pipe +tile.FluidPipe.0.name =Wood Trough +tile.FluidPipe.1.name =Black Wood Trough +tile.FluidPipe.2.name =Red Wood Trough +tile.FluidPipe.3.name =Green Wood Trough +tile.FluidPipe.4.name =Brown Wood Trough +tile.FluidPipe.5.name =Blue Wood Trough +tile.FluidPipe.6.name =Purple Wood Trough +tile.FluidPipe.7.name =Cyan Wood Trough +tile.FluidPipe.8.name =Silver Wood Trough +tile.FluidPipe.9.name =Grey Wood Trough +tile.FluidPipe.10.name =Pink Wood Trough +tile.FluidPipe.11.name =Lime Wood Trough +tile.FluidPipe.12.name =Yellow Wood Trough +tile.FluidPipe.13.name =Light Blue Wood Trough +tile.FluidPipe.14.name =Mangenta Wood Trough +tile.FluidPipe.15.name =Orange Wood Trough +tile.FluidPipe.16.name =White Wood Trough + +tile.FluidPipe.1000.name =Glass Tube +tile.FluidPipe.1001.name =Black Glass Tube +tile.FluidPipe.1002.name =Red Glass Tube +tile.FluidPipe.1003.name =Green Glass Tube +tile.FluidPipe.1004.name =Brown Glass Tube +tile.FluidPipe.1005.name =Blue Glass Tube +tile.FluidPipe.1006.name =Purple Glass Tube +tile.FluidPipe.1007.name =Cyan Glass Tube +tile.FluidPipe.1008.name =Silver Glass Tube +tile.FluidPipe.1009.name =Grey Glass Tube +tile.FluidPipe.1010.name =Pink Glass Tube +tile.FluidPipe.1011.name =Lime Glass Tube +tile.FluidPipe.1012.name =Yellow Glass Tube +tile.FluidPipe.1013.name =Light Blue Glass Tube +tile.FluidPipe.1014.name =Mangenta Glass Tube +tile.FluidPipe.1015.name =Orange Glass Tube +tile.FluidPipe.1016.name =White Glass Tube + +tile.FluidPipe.2000.name =Stone Trough +tile.FluidPipe.2001.name =Black Stone Trough +tile.FluidPipe.2002.name =Red Stone Trough +tile.FluidPipe.2003.name =Green Stone Trough +tile.FluidPipe.2004.name =Brown Stone Trough +tile.FluidPipe.2005.name =Blue Stone Trough +tile.FluidPipe.2006.name =Purple Stone Trough +tile.FluidPipe.2007.name =Cyan Stone Trough +tile.FluidPipe.2008.name =Silver Stone Trough +tile.FluidPipe.2009.name =Grey Stone Trough +tile.FluidPipe.2010.name =Pink Stone Trough +tile.FluidPipe.2011.name =Lime Stone Trough +tile.FluidPipe.2012.name =Yellow Stone Trough +tile.FluidPipe.2013.name =Light Stone Trough +tile.FluidPipe.2014.name =Mangenta Stone Trough +tile.FluidPipe.2015.name =Orange Stone Trough +tile.FluidPipe.2016.name =White Stone Trough + +tile.FluidPipe.2000.name =Tin Pipe +tile.FluidPipe.2001.name =Black Tin Pipe +tile.FluidPipe.2002.name =Red Tin Pipe +tile.FluidPipe.2003.name =Green Tin Pipe +tile.FluidPipe.2004.name =Brown Tin Pipe +tile.FluidPipe.2005.name =Blue Tin Pipe +tile.FluidPipe.2006.name =Purple Tin Pipe +tile.FluidPipe.2007.name =Cyan Tin Pipe +tile.FluidPipe.2008.name =Silver Tin Pipe +tile.FluidPipe.2009.name =Grey Tin Pipe +tile.FluidPipe.2010.name =Pink Tin Pipe +tile.FluidPipe.2011.name =Lime Tin Pipe +tile.FluidPipe.2012.name =Yellow Tin Pipe +tile.FluidPipe.2013.name =Light Tin Pipe +tile.FluidPipe.2014.name =Mangenta Tin Pipe +tile.FluidPipe.2015.name =Orange Tin Pipe +tile.FluidPipe.2016.name =White Tin Pipe + +tile.FluidPipe.3000.name =Tin Pipe +tile.FluidPipe.3001.name =Black Tin Pipe +tile.FluidPipe.3002.name =Red Tin Pipe +tile.FluidPipe.3003.name =Green Tin Pipe +tile.FluidPipe.3004.name =Brown Tin Pipe +tile.FluidPipe.3005.name =Blue Tin Pipe +tile.FluidPipe.3006.name =Purple Tin Pipe +tile.FluidPipe.3007.name =Cyan Tin Pipe +tile.FluidPipe.3008.name =Silver Tin Pipe +tile.FluidPipe.3009.name =Grey Tin Pipe +tile.FluidPipe.3010.name =Pink Tin Pipe +tile.FluidPipe.3011.name =Lime Tin Pipe +tile.FluidPipe.3012.name =Yellow Tin Pipe +tile.FluidPipe.3013.name =Light Tin Pipe +tile.FluidPipe.3014.name =Mangenta Tin Pipe +tile.FluidPipe.3015.name =Orange Tin Pipe +tile.FluidPipe.3016.name =White Tin Pipe + +tile.FluidPipe.4000.name =Copper Pipe +tile.FluidPipe.4001.name =Black Copper Pipe +tile.FluidPipe.4002.name =Red Copper Pipe +tile.FluidPipe.4003.name =Green Copper Pipe +tile.FluidPipe.4004.name =Brown Copper Pipe +tile.FluidPipe.4005.name =Blue Copper Pipe +tile.FluidPipe.4006.name =Purple Copper Pipe +tile.FluidPipe.4007.name =Cyan Copper Pipe +tile.FluidPipe.4008.name =Silver Copper Pipe +tile.FluidPipe.4009.name =Grey Copper Pipe +tile.FluidPipe.4010.name =Pink Copper Pipe +tile.FluidPipe.4011.name =Lime Copper Pipe +tile.FluidPipe.4012.name =Yellow Copper Pipe +tile.FluidPipe.4013.name =Light Copper Pipe +tile.FluidPipe.4014.name =Mangenta Copper Pipe +tile.FluidPipe.4015.name =Orange Copper Pipe +tile.FluidPipe.4016.name =White Copper Pipe + +tile.FluidPipe.5000.name =Iron Pipe +tile.FluidPipe.5001.name =Black Iron Pipe +tile.FluidPipe.5002.name =Red Iron Pipe +tile.FluidPipe.5003.name =Green Iron Pipe +tile.FluidPipe.5004.name =Brown Iron Pipe +tile.FluidPipe.5005.name =Blue Iron Pipe +tile.FluidPipe.5006.name =Purple Iron Pipe +tile.FluidPipe.5007.name =Cyan Iron Pipe +tile.FluidPipe.5008.name =Silver Iron Pipe +tile.FluidPipe.5009.name =Grey Iron Pipe +tile.FluidPipe.5010.name =Pink Iron Pipe +tile.FluidPipe.5011.name =Lime Iron Pipe +tile.FluidPipe.5012.name =Yellow Iron Pipe +tile.FluidPipe.5013.name =Light Iron Pipe +tile.FluidPipe.5014.name =Mangenta Iron Pipe +tile.FluidPipe.5015.name =Orange Iron Pipe +tile.FluidPipe.5016.name =White Iron Pipe + +tile.FluidPipe.6000.name =Gold Pipe +tile.FluidPipe.6001.name =Black Gold Pipe +tile.FluidPipe.6002.name =Red Gold Pipe +tile.FluidPipe.6003.name =Green Gold Pipe +tile.FluidPipe.6004.name =Brown Gold Pipe +tile.FluidPipe.6005.name =Blue Gold Pipe +tile.FluidPipe.6006.name =Purple Gold Pipe +tile.FluidPipe.6007.name =Cyan Gold Pipe +tile.FluidPipe.6008.name =Silver Gold Pipe +tile.FluidPipe.6009.name =Grey Gold Pipe +tile.FluidPipe.6010.name =Pink Gold Pipe +tile.FluidPipe.6011.name =Lime Gold Pipe +tile.FluidPipe.6012.name =Yellow Gold Pipe +tile.FluidPipe.6013.name =Light Gold Pipe +tile.FluidPipe.6014.name =Mangenta Gold Pipe +tile.FluidPipe.6015.name =Orange Gold Pipe +tile.FluidPipe.6016.name =White Gold Pipe + +tile.FluidPipe.7000.name =Obby Pipe +tile.FluidPipe.7001.name =Black Obby Pipe +tile.FluidPipe.7002.name =Red Obby Pipe +tile.FluidPipe.7003.name =Green Obby Pipe +tile.FluidPipe.7004.name =Brown Obby Pipe +tile.FluidPipe.7005.name =Blue Obby Pipe +tile.FluidPipe.7006.name =Purple Obby Pipe +tile.FluidPipe.7007.name =Cyan Obby Pipe +tile.FluidPipe.7008.name =Silver Obby Pipe +tile.FluidPipe.7009.name =Grey Obby Pipe +tile.FluidPipe.7010.name =Pink Obby Pipe +tile.FluidPipe.7011.name =Lime Obby Pipe +tile.FluidPipe.7012.name =Yellow Obby Pipe +tile.FluidPipe.7013.name =Light Obby Pipe +tile.FluidPipe.7014.name =Mangenta Obby Pipe +tile.FluidPipe.7015.name =Orange Obby Pipe +tile.FluidPipe.7016.name =White Obby Pipe + +tile.FluidPipe.8000.name =Steel Pipe +tile.FluidPipe.8001.name =Black Steel Pipe +tile.FluidPipe.8002.name =Red Steel Pipe +tile.FluidPipe.8003.name =Green Steel Pipe +tile.FluidPipe.8004.name =Brown Steel Pipe +tile.FluidPipe.8005.name =Blue Steel Pipe +tile.FluidPipe.8006.name =Purple Steel Pipe +tile.FluidPipe.8007.name =Cyan Steel Pipe +tile.FluidPipe.8008.name =Silver Steel Pipe +tile.FluidPipe.8009.name =Grey Steel Pipe +tile.FluidPipe.8010.name =Pink Steel Pipe +tile.FluidPipe.8011.name =Lime Steel Pipe +tile.FluidPipe.8012.name =Yellow Steel Pipe +tile.FluidPipe.8013.name =Light Steel Pipe +tile.FluidPipe.8014.name =Mangenta Steel Pipe +tile.FluidPipe.8015.name =Orange Steel Pipe +tile.FluidPipe.8016.name =White Steel Pipe + +tile.FluidPipe.9000.name =Bronze Pipe +tile.FluidPipe.9001.name =Black Bronze Pipe +tile.FluidPipe.9002.name =Red Bronze Pipe +tile.FluidPipe.9003.name =Green Bronze Pipe +tile.FluidPipe.9004.name =Brown Bronze Pipe +tile.FluidPipe.9005.name =Blue Bronze Pipe +tile.FluidPipe.9006.name =Purple Bronze Pipe +tile.FluidPipe.9007.name =Cyan Bronze Pipe +tile.FluidPipe.9008.name =Silver Bronze Pipe +tile.FluidPipe.9009.name =Grey Bronze Pipe +tile.FluidPipe.9010.name =Pink Bronze Pipe +tile.FluidPipe.9011.name =Lime Bronze Pipe +tile.FluidPipe.9012.name =Yellow Bronze Pipe +tile.FluidPipe.9013.name =Light Bronze Pipe +tile.FluidPipe.9014.name =Mangenta Bronze Pipe +tile.FluidPipe.9015.name =Orange Bronze Pipe +tile.FluidPipe.9016.name =White Bronze Pipe + +tile.FluidPipe.10000.name =Hell Pipe +tile.FluidPipe.10001.name =Black Hell Pipe +tile.FluidPipe.10002.name =Red Hell Pipe +tile.FluidPipe.10003.name =Green Hell Pipe +tile.FluidPipe.10004.name =Brown Hell Pipe +tile.FluidPipe.10005.name =Blue Hell Pipe +tile.FluidPipe.10006.name =Purple Hell Pipe +tile.FluidPipe.10007.name =Cyan Hell Pipe +tile.FluidPipe.10008.name =Silver Hell Pipe +tile.FluidPipe.10009.name =Grey Hell Pipe +tile.FluidPipe.10010.name =Pink Hell Pipe +tile.FluidPipe.10011.name =Lime Hell Pipe +tile.FluidPipe.10012.name =Yellow Hell Pipe +tile.FluidPipe.10013.name =Light Hell Pipe +tile.FluidPipe.10014.name =Mangenta Hell Pipe +tile.FluidPipe.10015.name =Orange Hell Pipe +tile.FluidPipe.10016.name =White Hell Pipe -tile.FluidPipe.16.name =Oil Pipe -tile.FluidPipe.17.name =Fuel Pipe -tile.FluidPipe.18.name =Lava Pipe -tile.FluidPipe.19.name =Water Pipe -tile.FluidPipe.20.name =Waste Pipe -tile.FluidPipe.21.name =P Pipe -tile.FluidPipe.22.name =C Pipe -tile.FluidPipe.23.name =S Pipe -tile.FluidPipe.24.name =G Pipe -tile.FluidPipe.25.name =P Pipe -tile.FluidPipe.26.name =W Pipe -tile.FluidPipe.27.name =G Pipe -tile.FluidPipe.28.name =S Pipe -tile.FluidPipe.29.name =v Pipe -tile.FluidPipe.30.name =B Pipe -tile.FluidPipe.31.name =Iron Pipe tile.FluidTank.0.name =Oil Tank tile.FluidTank.1.name =Lava Tank diff --git a/src/dark/core/prefab/tilenetwork/fluid/NetworkFluidTiles.java b/src/dark/core/prefab/tilenetwork/fluid/NetworkFluidTiles.java index cfebb002f..fbcd1b7a8 100644 --- a/src/dark/core/prefab/tilenetwork/fluid/NetworkFluidTiles.java +++ b/src/dark/core/prefab/tilenetwork/fluid/NetworkFluidTiles.java @@ -282,6 +282,6 @@ public class NetworkFluidTiles extends NetworkTileEntities String name = combinedStorage().getFluid().getFluid().getLocalizedName(); return String.format("%d/%d %S Stored", vol, cap, name); } - return ("As far as you can tell it is empty"); + return ("Empty"); } } diff --git a/src/dark/fluid/common/FMRecipeLoader.java b/src/dark/fluid/common/FMRecipeLoader.java index c5f7cfb91..7219ba70e 100644 --- a/src/dark/fluid/common/FMRecipeLoader.java +++ b/src/dark/fluid/common/FMRecipeLoader.java @@ -10,7 +10,7 @@ import dark.api.ColorCode; import dark.core.common.CoreRecipeLoader; import dark.core.common.RecipeLoader; import dark.core.common.items.ItemParts.Parts; -import dark.fluid.common.pipes.BlockPipe.PipeMaterial; +import dark.fluid.common.pipes.PipeMaterial; public class FMRecipeLoader extends RecipeLoader { diff --git a/src/dark/fluid/common/FluidMech.java b/src/dark/fluid/common/FluidMech.java index 789c1cac0..9baf0970c 100644 --- a/src/dark/fluid/common/FluidMech.java +++ b/src/dark/fluid/common/FluidMech.java @@ -4,7 +4,6 @@ import java.io.File; import java.util.Arrays; import java.util.logging.Logger; -import net.minecraft.item.ItemStack; import net.minecraftforge.common.Configuration; import net.minecraftforge.fluids.Fluid; @@ -31,8 +30,8 @@ import dark.fluid.common.machines.BlockReleaseValve; import dark.fluid.common.machines.BlockSink; import dark.fluid.common.machines.BlockTank; import dark.fluid.common.pipes.BlockPipe; -import dark.fluid.common.pipes.BlockPipe.PipeData; import dark.fluid.common.pipes.ItemBlockPipe; +import dark.fluid.common.pipes.PipeMaterial; import dark.fluid.common.pump.BlockConstructionPump; import dark.fluid.common.pump.BlockDrain; import dark.fluid.common.pump.BlockPumpMachine; @@ -103,7 +102,10 @@ public class FluidMech extends ModPrefab /* LANG LOADING */ FMLog.info(" Loaded: " + TranslationHelper.loadLanguages(LANGUAGE_PATH, LANGUAGES_SUPPORTED) + " Languages."); - DMCreativeTab.tabHydrualic.setIconItemStack(new ItemStack(FMRecipeLoader.blockPipe, 1, PipeData.IRON_PIPE.ordinal())); + if (FMRecipeLoader.blockPipe instanceof BlockPipe) + { + DMCreativeTab.tabHydrualic.setIconItemStack(PipeMaterial.IRON.getStack()); + } } @Override diff --git a/src/dark/fluid/common/machines/TileEntityBoiler.java b/src/dark/fluid/common/machines/TileEntityBoiler.java index c1d14ee91..51924a25d 100644 --- a/src/dark/fluid/common/machines/TileEntityBoiler.java +++ b/src/dark/fluid/common/machines/TileEntityBoiler.java @@ -107,9 +107,9 @@ public class TileEntityBoiler extends TileEntityFluidDevice implements IFluidHan } @Override - public void setColor(Object obj) + public boolean setColor(Object obj) { - // TODO Auto-generated method stub + return false; } diff --git a/src/dark/fluid/common/machines/TileEntitySink.java b/src/dark/fluid/common/machines/TileEntitySink.java index a4fa29cad..1870e7384 100644 --- a/src/dark/fluid/common/machines/TileEntitySink.java +++ b/src/dark/fluid/common/machines/TileEntitySink.java @@ -97,8 +97,9 @@ public class TileEntitySink extends TileEntityFluidStorage implements IPacketRec } @Override - public void setColor(Object obj) + public boolean setColor(Object obj) { + return false; } @Override diff --git a/src/dark/fluid/common/machines/TileEntityTank.java b/src/dark/fluid/common/machines/TileEntityTank.java index 8f4b851cd..6babc74ab 100644 --- a/src/dark/fluid/common/machines/TileEntityTank.java +++ b/src/dark/fluid/common/machines/TileEntityTank.java @@ -158,12 +158,14 @@ public class TileEntityTank extends TileEntityFluidStorage implements IFluidHand /** sets the current color mark of the pipe */ @Override - public void setColor(Object cc) + public boolean setColor(Object cc) { if (!worldObj.isRemote) { this.colorCode = ColorCode.get(cc); + return true; } + return false; } @Override @@ -220,7 +222,7 @@ public class TileEntityTank extends TileEntityFluidStorage implements IFluidHand } /** Checks to make sure the connection is valid to the tileEntity - * + * * @param tileEntity - the tileEntity being checked * @param side - side the connection is too */ public void validateConnectionSide(TileEntity tileEntity, ForgeDirection side) diff --git a/src/dark/fluid/common/pipes/BlockPipe.java b/src/dark/fluid/common/pipes/BlockPipe.java index bc7282b51..2642313ed 100644 --- a/src/dark/fluid/common/pipes/BlockPipe.java +++ b/src/dark/fluid/common/pipes/BlockPipe.java @@ -7,9 +7,13 @@ import java.util.Set; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.Configuration; import net.minecraftforge.common.ForgeDirection; @@ -21,9 +25,7 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import dark.api.ColorCode; import dark.api.ColorCode.IColorCoded; -import dark.core.prefab.helpers.FluidHelper; import dark.fluid.common.BlockFM; -import dark.fluid.common.FMRecipeLoader; public class BlockPipe extends BlockFM { @@ -39,6 +41,28 @@ public class BlockPipe extends BlockFM } + @Override + public void fillWithRain(World world, int x, int y, int z) + { + int meta = world.getBlockMetadata(x, y, z); + if (meta == PipeMaterial.WOOD.ordinal() || meta == PipeMaterial.STONE.ordinal()) + { + //TODO fill pipe since it will have an open top and can gather rain + } + } + + @Override + public ArrayList getBlockDropped(World world, int x, int y, int z, int metadata, int fortune) + { + ArrayList ret = new ArrayList(); + TileEntity entity = world.getBlockTileEntity(x, y, z); + if (entity instanceof TileEntityPipe) + { + ret.add(new ItemStack(this, 1, (world.getBlockMetadata(x, y, z) * PipeMaterial.spacing) + ((TileEntityPipe) entity).getPipeID())); + } + return ret; + } + @Override public boolean isOpaqueCube() { @@ -70,6 +94,28 @@ public class BlockPipe extends BlockFM return PipeMaterial.getDropItem(world, x, y, z); } + @Override + public boolean canSilkHarvest(World world, EntityPlayer player, int x, int y, int z, int metadata) + { + return false; + } + + @Override + public int getLightValue(IBlockAccess world, int x, int y, int z) + { + if (world.getBlockMetadata(x, y, z) == PipeMaterial.HELL.ordinal()) + { + return 5; + } + return super.getLightValue(world, x, y, z); + } + + @Override + public boolean isLadder(World world, int x, int y, int z, EntityLivingBase entity) + { + return true; + } + @Override public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List) { @@ -105,12 +151,9 @@ public class BlockPipe extends BlockFM @Override public boolean recolourBlock(World world, int x, int y, int z, ForgeDirection side, int colour) { - if (world.getBlockMetadata(x, y, z) < 16) + if (world.getBlockTileEntity(x, y, z) instanceof IColorCoded) { - if (world.getBlockTileEntity(x, y, z) instanceof IColorCoded) - { - ((IColorCoded) world.getBlockTileEntity(x, y, z)).setColor(ColorCode.get(colour)); - } + return ((IColorCoded) world.getBlockTileEntity(x, y, z)).setColor(ColorCode.get(colour)); } return false; } @@ -134,112 +177,4 @@ public class BlockPipe extends BlockFM BlockPipe.waterFlowRate = config.get("settings", "FlowRate", BlockPipe.waterFlowRate, "Base value for flow rate is based off of water. It is in milibuckets so 1000 equals one bucket of fluid").getInt(); } - - /** Enum to hold info about each pipe material. Values are by default and some can change with - * pipe upgrades. - * - * @Note unsupportedFluids should only be used by filters. All pipes should allow all fluid - * types. However, pipes that can't support the fluid should have an effect. Eg no gas support - * should cause the pipe to leak. No molten support should cause the pipe to take damage. - * - * @author DarkGuardsman */ - public static enum PipeMaterial - { - /** Simple water only pipe. Should render open toped when it can */ - WOOD("wood", false, true, false, 50, 200), - /** Gas only pipe */ - GLASS("wood", true, false, false, 100, 300), - /** Another version of the wooden pipe */ - STONE("wood", false, true, false, 200, 1000), - /** Cheap fluid pipe */ - TIN("wood", false, true, false, 300, 1000), - /** Cheap fluid pipe */ - COPPER("wood", false, true, false, 400, 1000), - /** First duel gas and fluid pipe */ - IRON("wood", true, true, false, 500, 1000), - /** Fluid movement pipe that doesn't work well with pressure */ - GOLD("wood", true, true, false, 200, 2000), - /** Cheap molten metal pipe */ - OBBY("wood", false, true, true, 1000, 1000), - /** Very strong fluid and gas support pipe. Should also support molten metal as long as they - * don't stay in the pipe too long. */ - STEEL("wood", true, true, false, 10000, 3000), - /** Weaker equal to steel pipes. Should also support steam very well */ - BRONZE("wood", true, true, false, 6000, 2000), - /** Hell fluids only. Meaning lava, and molten metals. Water should turn to steam, fuel and - * oil should cause an explosion around the pipe */ - HELL("wood", true, true, true, 10000, 5000, "water", "fuel", "oil"); - public String matName = "material"; - List unsupportedFluids = new ArrayList(); - public boolean supportsAllFluids = false; - public boolean supportsAllGas = false; - public boolean canSupportGas = false; - public boolean canSupportFluids = false; - public boolean canSupportMoltenFluids = false; - public int maxPressure = 1000; - public int maxVolume = 2000; - /** Materials are stored as meta were there sub types are stored by NBT. Item versions of the - * pipes are still meta so there is a set spacing to allow for a large but defined range of - * sub pipes */ - public static int spacing = 1000; - - private PipeMaterial() - { - supportsAllFluids = true; - supportsAllGas = true; - canSupportMoltenFluids = true; - } - - private PipeMaterial(String name, boolean gas, boolean fluid, boolean molten, String... strings) - { - this.matName = name; - this.canSupportGas = gas; - this.canSupportFluids = fluid; - this.canSupportMoltenFluids = molten; - } - - private PipeMaterial(String name, boolean gas, boolean fluid, boolean molten, int pressure, int volume, String... strings) - { - this(name, gas, fluid, molten, strings); - this.maxPressure = pressure; - this.maxVolume = volume; - } - - public ItemStack getStack() - { - return getStack(1); - } - - public ItemStack getStack(ColorCode color) - { - return getStack(1, color); - } - - public ItemStack getStack(int s) - { - return new ItemStack(FMRecipeLoader.blockPipe, s, (this.ordinal() * spacing)); - } - - public ItemStack getStack(int s, ColorCode color) - { - return new ItemStack(FMRecipeLoader.blockPipe, s, (this.ordinal() * spacing) + color.ordinal()); - } - - public static ItemStack getDropItem(World world, int x, int y, int z) - { - int meta = world.getBlockMetadata(x, y, z); - TileEntity ent = world.getBlockTileEntity(x, y, z); - if (ent instanceof IColorCoded) - { - meta += ((IColorCoded) ent).getColor().ordinal(); - } - return new ItemStack(FMRecipeLoader.blockPipe, 1, meta); - } - } - - public static enum PipeSubType - { - //TODO list sub types then create an enum interface to have each sub handle its own metadata - COLOR(); - } } diff --git a/src/dark/fluid/common/pipes/EnumPipeType.java b/src/dark/fluid/common/pipes/EnumPipeType.java new file mode 100644 index 000000000..cfa856517 --- /dev/null +++ b/src/dark/fluid/common/pipes/EnumPipeType.java @@ -0,0 +1,107 @@ +package dark.fluid.common.pipes; + +import dark.api.ColorCode; +import dark.api.ColorCode.IColoredId; + +public enum EnumPipeType implements IColoredId +{ + Base(0, 0, true), + COLOR(new IPipeType() + { + @Override + public ColorCode getColor(int meta) + { + return ColorCode.get(meta); + } + + @Override + public String getName() + { + return "Colored Pipe"; + } + }, 0, 15, true); + + private IPipeType type; + public int metaStart = 1; + public int metaEnd = 16; + public boolean canColor = false; + + private EnumPipeType() + { + this.metaStart = this.ordinal() * 16; + this.metaEnd = this.metaStart + 15; + } + + private EnumPipeType(int metaStart, int metaEnd, boolean canColor) + { + + } + + private EnumPipeType(IPipeType type, int metaStart, int metaEnd, boolean canColor) + { + this.type = type; + this.metaStart = metaStart; + this.metaEnd = metaEnd; + this.canColor = canColor; + } + + public static EnumPipeType get(int meta) + { + for (EnumPipeType type : EnumPipeType.values()) + { + if (meta >= type.metaStart && meta <= type.metaEnd) + { + return type; + } + } + return null; + } + + public static boolean canColor(int meta) + { + EnumPipeType type = get(meta); + if (type != null) + { + return type.canColor; + } + return false; + } + + public static int getUpdatedID(int pipeID, ColorCode newColor) + { + if(pipeID == 0) + { + return 1 + newColor.ordinal(); + } + return pipeID; + } + + public static ColorCode getColorCode(int meta) + { + EnumPipeType type = get(meta); + if (type != null) + { + return type.getColor(meta); + } + return ColorCode.UNKOWN; + } + + @Override + public ColorCode getColor(int meta) + { + if (type != null) + { + return type.getColor(meta); + } + return ColorCode.UNKOWN; + } + + public String getName() + { + if (type != null) + { + return type.getName(); + } + return "PipeType" + this.ordinal(); + } +} diff --git a/src/dark/fluid/common/pipes/IPipeType.java b/src/dark/fluid/common/pipes/IPipeType.java new file mode 100644 index 000000000..8d259936a --- /dev/null +++ b/src/dark/fluid/common/pipes/IPipeType.java @@ -0,0 +1,8 @@ +package dark.fluid.common.pipes; + +import dark.api.ColorCode.IColoredId; + +public interface IPipeType extends IColoredId +{ + public String getName(); +} diff --git a/src/dark/fluid/common/pipes/ItemBlockPipe.java b/src/dark/fluid/common/pipes/ItemBlockPipe.java index 74e9e698e..acdbbb801 100644 --- a/src/dark/fluid/common/pipes/ItemBlockPipe.java +++ b/src/dark/fluid/common/pipes/ItemBlockPipe.java @@ -33,20 +33,12 @@ public class ItemBlockPipe extends ItemBlock @Override public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) { - if (super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata)) + if (super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata / PipeMaterial.spacing)) { TileEntity tile = world.getBlockTileEntity(x, y, z); - if (tile instanceof IColorCoded) + if (tile instanceof TileEntityPipe) { - - if (tile instanceof TileEntityPipe) - { - ((TileEntityPipe) tile).setPipeID(stack.getItemDamage()); - } - else - { - ((IColorCoded) tile).setColor((stack.getItemDamage() % 16) & 15); - } + ((TileEntityPipe) tile).setPipeID(stack.getItemDamage()); } return true; } diff --git a/src/dark/fluid/common/pipes/PipeMaterial.java b/src/dark/fluid/common/pipes/PipeMaterial.java new file mode 100644 index 000000000..4c2f2ffe0 --- /dev/null +++ b/src/dark/fluid/common/pipes/PipeMaterial.java @@ -0,0 +1,151 @@ +package dark.fluid.common.pipes; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import dark.api.ColorCode; +import dark.fluid.common.FMRecipeLoader; + +/** Enum to hold info about each pipe material. Values are by default and some can change with pipe + * upgrades. + * + * @Note unsupportedFluids should only be used by filters. All pipes should allow all fluid types. + * However, pipes that can't support the fluid should have an effect. Eg no gas support should cause + * the pipe to leak. No molten support should cause the pipe to take damage. + * + * @author DarkGuardsman */ +public enum PipeMaterial +{ + /** Simple water only pipe. Should render open toped when it can */ + WOOD("wood", false, true, false, 50, 200), + /** Gas only pipe */ + GLASS("wood", true, false, false, 100, 300), + /** Another version of the wooden pipe */ + STONE("wood", false, true, false, 200, 1000), + /** Cheap fluid pipe */ + TIN("wood", false, true, false, 300, 1000), + /** Cheap fluid pipe */ + COPPER("wood", false, true, false, 400, 1000), + /** First duel gas and fluid pipe */ + IRON("wood", true, true, false, 500, 1000), + /** Fluid movement pipe that doesn't work well with pressure */ + GOLD("wood", true, true, false, 200, 2000), + /** Cheap molten metal pipe */ + OBBY("wood", false, true, true, 1000, 1000), + /** Very strong fluid and gas support pipe. Should also support molten metal as long as they + * don't stay in the pipe too long. */ + STEEL("wood", true, true, false, 10000, 3000), + /** Weaker equal to steel pipes. Should also support steam very well */ + BRONZE("wood", true, true, false, 6000, 2000), + /** Hell fluids only. Meaning lava, and molten metals. Water should turn to steam, fuel and oil + * should cause an explosion around the pipe */ + HELL("wood", true, true, true, 10000, 5000, "water", "fuel", "oil"); + public String matName = "material"; + List unsupportedFluids = new ArrayList(); + public boolean supportsAllFluids = false; + public boolean supportsAllGas = false; + public boolean canSupportGas = false; + public boolean canSupportFluids = false; + public boolean canSupportMoltenFluids = false; + public int maxPressure = 1000; + public int maxVolume = 2000; + /** Materials are stored as meta were there sub types are stored by NBT. Item versions of the + * pipes are still meta so there is a set spacing to allow for a large but defined range of sub + * pipes */ + public static int spacing = 1000; + + private PipeMaterial() + { + supportsAllFluids = true; + supportsAllGas = true; + canSupportMoltenFluids = true; + } + + private PipeMaterial(String name, boolean gas, boolean fluid, boolean molten, String... strings) + { + this.matName = name; + this.canSupportGas = gas; + this.canSupportFluids = fluid; + this.canSupportMoltenFluids = molten; + } + + private PipeMaterial(String name, boolean gas, boolean fluid, boolean molten, int pressure, int volume, String... strings) + { + this(name, gas, fluid, molten, strings); + this.maxPressure = pressure; + this.maxVolume = volume; + } + + public static PipeMaterial get(World world, int x, int y, int z) + { + return get(world.getBlockMetadata(x, y, z)); + } + + public static PipeMaterial get(ItemStack stack) + { + if (stack != null) + { + return get(stack.getItemDamage()); + } + return null; + } + + public static PipeMaterial get(int meta) + { + meta = meta / spacing; + if (meta < PipeMaterial.values().length) + { + return PipeMaterial.values()[meta]; + } + return null; + } + + public ItemStack getStack() + { + return getStack(1); + } + + public ItemStack getStack(ColorCode color) + { + return getStack(1, color); + } + + public ItemStack getStack(int s) + { + return new ItemStack(FMRecipeLoader.blockPipe, s, (this.ordinal() * spacing)); + } + + public ItemStack getStack(int s, ColorCode color) + { + return new ItemStack(FMRecipeLoader.blockPipe, s, (this.ordinal() * spacing) + color.ordinal() + 1); + } + + public static ItemStack getDropItem(World world, int x, int y, int z) + { + int meta = world.getBlockMetadata(x, y, z); + TileEntity ent = world.getBlockTileEntity(x, y, z); + meta *= spacing; + if (ent instanceof TileEntityPipe) + { + meta += ((TileEntityPipe) ent).getPipeID(); + } + return new ItemStack(FMRecipeLoader.blockPipe, 1, meta); + } + + public static ColorCode getColor(int pipeID) + { + return EnumPipeType.getColorCode(pipeID % spacing); + } + + public static int updateColor(Object cc, int pipeID) + { + if(EnumPipeType.canColor(pipeID)) + { + return EnumPipeType.getUpdatedID(pipeID, ColorCode.get(cc)); + } + return pipeID; + } +} diff --git a/src/dark/fluid/common/pipes/TileEntityPipe.java b/src/dark/fluid/common/pipes/TileEntityPipe.java index 9507e1f17..1563ed07b 100644 --- a/src/dark/fluid/common/pipes/TileEntityPipe.java +++ b/src/dark/fluid/common/pipes/TileEntityPipe.java @@ -40,7 +40,6 @@ import dark.core.network.PacketHandler; import dark.core.prefab.helpers.FluidHelper; import dark.core.prefab.tilenetwork.NetworkTileEntities; import dark.core.prefab.tilenetwork.fluid.NetworkPipes; -import dark.fluid.common.pipes.BlockPipe.PipeData; public class TileEntityPipe extends TileEntityAdvanced implements IFluidHandler, IToolReadOut, IColorCoded, INetworkPipe, IPacketReceiver { @@ -55,11 +54,9 @@ public class TileEntityPipe extends TileEntityAdvanced implements IFluidHandler, /** Network that links the collective pipes together to work */ private NetworkPipes pipeNetwork; - protected PipeData pipeData = PipeData.IRON_PIPE; - - protected boolean flagForColorCodeUpdate = false, resetting = false; protected int updateTick = 1; + protected int pipeID = 0; String refClassID = ""; public enum PipePacketID @@ -69,25 +66,6 @@ public class TileEntityPipe extends TileEntityAdvanced implements IFluidHandler, EXTENTION_UPDATE; } - @Override - public void initiate() - { - if (!this.worldObj.isRemote) - { - if (this.flagForColorCodeUpdate) - { - int meta = this.worldObj.getBlockMetadata(xCoord, yCoord, zCoord); - if (!this.refClassID.equalsIgnoreCase("ColoredPipe")) - { - meta += 16; - } - this.pipeData = PipeData.values()[meta & 31]; - this.worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 3); - this.flagForColorCodeUpdate = false; - } - } - } - @Override public void updateEntity() { @@ -106,7 +84,7 @@ public class TileEntityPipe extends TileEntityAdvanced implements IFluidHandler, public void invalidate() { super.invalidate(); - if (!this.worldObj.isRemote && !this.resetting) + if (!this.worldObj.isRemote) { this.getTileNetwork().splitNetwork(this.worldObj, this); } @@ -120,7 +98,7 @@ public class TileEntityPipe extends TileEntityAdvanced implements IFluidHandler, { if (this.worldObj.isRemote) { - this.pipeData = PipeData.values()[dataStream.readInt()]; + this.pipeID = dataStream.readInt(); this.renderConnection[0] = dataStream.readBoolean(); this.renderConnection[1] = dataStream.readBoolean(); this.renderConnection[2] = dataStream.readBoolean(); @@ -139,49 +117,53 @@ public class TileEntityPipe extends TileEntityAdvanced implements IFluidHandler, @Override public Packet getDescriptionPacket() { - return PacketHandler.instance().getPacket(DarkMain.CHANNEL, this, this.pipeData.ordinal(), this.renderConnection[0], this.renderConnection[1], this.renderConnection[2], this.renderConnection[3], this.renderConnection[4], this.renderConnection[5]); + return PacketHandler.instance().getPacket(DarkMain.CHANNEL, this, this.pipeID, this.renderConnection[0], this.renderConnection[1], this.renderConnection[2], this.renderConnection[3], this.renderConnection[4], this.renderConnection[5]); } /** gets the current color mark of the pipe */ @Override public ColorCode getColor() { - return this.pipeData.colorCode; + return PipeMaterial.getColor(this.pipeID); } /** sets the current color mark of the pipe */ @Override - public void setColor(Object cc) + public boolean setColor(Object cc) { - if (!worldObj.isRemote && (this.pipeData.colorCode != ColorCode.UNKOWN || this.pipeData == PipeData.IRON_PIPE)) + if (!worldObj.isRemote) { - this.pipeData = PipeData.get(ColorCode.get(cc).ordinal()); + int p = this.pipeID; + this.pipeID = PipeMaterial.updateColor(cc, pipeID); + return p != this.pipeID; } + return false; } @Override public String getMeterReading(EntityPlayer user, ForgeDirection side, EnumTools tool) { - /* DEBUG CODE ACTIVATERS */ - boolean testConnections = false, testNetwork = false; - - /* NORMAL OUTPUT */ - String string = ((NetworkPipes) this.getTileNetwork()).pressureProduced + "p " + ((NetworkPipes) this.getTileNetwork()).getNetworkFluid() + " Extra"; - - /* DEBUG CODE */ - if (testConnections) + if (tool == EnumTools.PIPE_GUAGE) { - for (int i = 0; i < 6; i++) + /* DEBUG CODE ACTIVATERS */ + boolean testConnections = true; + + /* NORMAL OUTPUT */ + String string = ((NetworkPipes) this.getTileNetwork()).pressureProduced + "p " + ((NetworkPipes) this.getTileNetwork()).getNetworkFluid(); + + /* DEBUG CODE */ + if (testConnections) { - string += ":" + (this.renderConnection[i] ? "T" : "F") + (this.renderConnection[i] ? "T" : "F"); + for (int i = 0; i < 6; i++) + { + string += "||" + (this.renderConnection[i] ? "T" : "F"); + } } - } - if (testNetwork) - { string += " " + this.getTileNetwork().toString(); - } - return string; + return string; + } + return null; } @Override @@ -207,7 +189,7 @@ public class TileEntityPipe extends TileEntityAdvanced implements IFluidHandler, } /** Checks to make sure the connection is valid to the tileEntity - * + * * @param tileEntity - the tileEntity being checked * @param side - side the connection is too * @return */ @@ -217,26 +199,14 @@ public class TileEntityPipe extends TileEntityAdvanced implements IFluidHandler, { if (tileEntity instanceof ITileConnector) { - if (((ITileConnector) tileEntity).canTileConnect(Connection.NETWORK, side.getOpposite())) + if (((ITileConnector) tileEntity).canTileConnect(Connection.FLUIDS, side.getOpposite())) { if (tileEntity instanceof INetworkPipe) { - if (((INetworkPipe) tileEntity).getColor() == this.getColor()) + if (((INetworkPipe) tileEntity).canTileConnect(Connection.NETWORK, side.getOpposite())) { - if (tileEntity instanceof TileEntityPipe) - { - if (((TileEntityPipe) tileEntity).pipeData == this.pipeData) - { - this.getTileNetwork().merge(((INetworkPipe) tileEntity).getTileNetwork(), this); - return connectedBlocks.add(tileEntity); - } - } - else - { - this.getTileNetwork().merge(((INetworkPipe) tileEntity).getTileNetwork(), this); - return connectedBlocks.add(tileEntity); - } - + this.getTileNetwork().merge(((INetworkPipe) tileEntity).getTileNetwork(), this); + return connectedBlocks.add(tileEntity); } } else @@ -260,10 +230,54 @@ public class TileEntityPipe extends TileEntityAdvanced implements IFluidHandler, return false; } + @Override + public boolean canTileConnect(Connection type, ForgeDirection dir) + { + Vector3 connection = new Vector3(this).modifyPositionFromSide(dir.getOpposite()); + TileEntity entity = connection.getTileEntity(this.worldObj); + //Unknown color codes can connect to any color, however two different colors can connect to support better pipe layouts + if (entity instanceof IColorCoded && ((IColorCoded) entity).getColor() != this.getColor() && ((IColorCoded) entity).getColor() != ColorCode.UNKOWN) + { + return false; + }//All Fluid connections are supported + else if (type == Connection.FLUIDS) + { + return true; + }//Network connections are only supported for if pipe materials match + else if (type == Connection.NETWORK && entity instanceof INetworkPipe) + { + if (entity instanceof TileEntityPipe) + { + int meta = new Vector3(this).getBlockMetadata(this.worldObj); + int metaOther = connection.getBlockMetadata(this.worldObj); + if (meta < PipeMaterial.values().length && metaOther < PipeMaterial.values().length) + { + PipeMaterial pipeMat = PipeMaterial.values()[meta]; + PipeMaterial pipeMatOther = PipeMaterial.values()[metaOther]; + //Same pipe types can connect + if (pipeMat == pipeMatOther) + { + return true; + }//Wood and stone pipes can connect to each other but not other pipe types since they are more like a trough than a pipe + else if ((pipeMat == PipeMaterial.WOOD || pipeMat == PipeMaterial.STONE) && (pipeMatOther == PipeMaterial.WOOD || pipeMatOther == PipeMaterial.STONE)) + { + return true; + }//Any other pipe can connect to each other as long as the color matches except for glass which only works with itself at the moment + else if (pipeMat != PipeMaterial.WOOD && pipeMat != PipeMaterial.STONE && pipeMatOther != PipeMaterial.WOOD && pipeMatOther != PipeMaterial.STONE && pipeMat != PipeMaterial.GLASS && pipeMatOther != PipeMaterial.GLASS) + { + return true; + } + } + return false; + } + return true; + } + return false; + } + @Override public void refresh() { - if (this.worldObj != null && !this.worldObj.isRemote) { @@ -300,12 +314,6 @@ public class TileEntityPipe extends TileEntityAdvanced implements IFluidHandler, } } - @Override - public boolean canTileConnect(Connection type, ForgeDirection dir) - { - return new Vector3(this).modifyPositionFromSide(dir).getTileEntity(this.worldObj) instanceof IFluidHandler; - } - @Override public double getMaxPressure(ForgeDirection side) { @@ -342,7 +350,7 @@ public class TileEntityPipe extends TileEntityAdvanced implements IFluidHandler, } /** Calculates flow rate based on viscosity & temp of the fluid as all other factors are know - * + * * @param fluid - fluidStack * @param temp = tempature of the fluid * @param pressure - pressure difference of were the fluid is flowing too. @@ -450,14 +458,8 @@ public class TileEntityPipe extends TileEntityAdvanced implements IFluidHandler, super.readFromNBT(nbt); //Load color code from nbt this.refClassID = nbt.getString("id"); - if (nbt.hasKey("PipeID")) - { - this.pipeData = PipeData.get(nbt.getInteger("PipeID")); - } - else - { - this.flagForColorCodeUpdate = true; - } + + this.pipeID = nbt.getInteger("PipeItemId"); //Load fluid tank FluidStack liquid = FluidStack.loadFluidStackFromNBT(nbt.getCompoundTag("FluidTank")); @@ -483,7 +485,7 @@ public class TileEntityPipe extends TileEntityAdvanced implements IFluidHandler, public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); - nbt.setInteger("PipeID", this.pipeData.ordinal()); + nbt.setInteger("PipeItemId", this.pipeID); if (this.tank != null && this.tank.getFluid() != null) { nbt.setTag("FluidTank", this.tank.getFluid().writeToNBT(new NBTTagCompound())); @@ -492,7 +494,11 @@ public class TileEntityPipe extends TileEntityAdvanced implements IFluidHandler, public void setPipeID(int itemDamage) { - this.pipeData = PipeData.get(itemDamage); + this.pipeID = itemDamage; } + public int getPipeID() + { + return this.pipeID; + } }