More work on pipes

This commit is contained in:
DarkGuardsman 2013-09-19 10:55:08 -04:00
parent a5f9dbab87
commit 511306a4ed
9 changed files with 194 additions and 150 deletions

View file

@ -8,11 +8,11 @@ import cpw.mods.fml.relauncher.SideOnly;
import dark.fluid.client.render.BlockRenderHelper;
import dark.fluid.client.render.ItemRenderHelper;
import dark.fluid.client.render.RenderConstructionPump;
import dark.fluid.client.render.RenderPipe;
import dark.fluid.client.render.RenderPump;
import dark.fluid.client.render.RenderReleaseValve;
import dark.fluid.client.render.RenderSink;
import dark.fluid.client.render.RenderTank;
import dark.fluid.client.render.pipe.RenderPipe;
import dark.fluid.common.CommonProxy;
import dark.fluid.common.FMRecipeLoader;
import dark.fluid.common.machines.TileEntityReleaseValve;
@ -44,7 +44,6 @@ public class ClientProxy extends CommonProxy
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTank.class, new RenderTank());
MinecraftForgeClient.registerItemRenderer(FMRecipeLoader.blockPipe.blockID, new ItemRenderHelper());
MinecraftForgeClient.registerItemRenderer(FMRecipeLoader.blockGenPipe.blockID, new ItemRenderHelper());
MinecraftForgeClient.registerItemRenderer(FMRecipeLoader.blockReleaseValve.blockID, new ItemRenderHelper());
RenderingRegistry.registerBlockHandler(new BlockRenderHelper());

View file

@ -12,7 +12,6 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import dark.core.prefab.ModPrefab;
import dark.fluid.client.model.ModelReleaseValve;
import dark.fluid.client.render.pipe.RenderPipe;
import dark.fluid.common.FMRecipeLoader;
import dark.fluid.common.FluidMech;
@ -37,7 +36,7 @@ public class ItemRenderHelper implements IItemRenderer
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data)
{
if (item.itemID == FMRecipeLoader.blockPipe.blockID || item.itemID == FMRecipeLoader.blockGenPipe.blockID)
if (item.itemID == FMRecipeLoader.blockPipe.blockID)
{
this.renderPipeItem((RenderBlocks) data[0], item, type == ItemRenderType.EQUIPPED);
}

View file

@ -1,4 +1,4 @@
package dark.fluid.client.render.pipe;
package dark.fluid.client.render;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
@ -56,7 +56,7 @@ public class RenderPipe extends RenderTileMachine
public ResourceLocation getTexture(int block, int meta)
{
String name = "";
if (block == FMRecipeLoader.blockPipe.blockID)
if (meta < 16)
{
Fluid stack = FluidHelper.getStackForColor(ColorCode.get(meta));
name = stack != null ? stack.getName() : "";

View file

@ -9,12 +9,12 @@ 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.PipeData;
public class FMRecipeLoader extends RecipeLoader
{
public static Block blockPipe;
public static Block blockGenPipe;
public static Block blockTank;
public static Block blockMachine;
public static Block blockRod;
@ -31,24 +31,11 @@ public class FMRecipeLoader extends RecipeLoader
public static Block blockOilLiquid;
public static Block blockFuelLiquid;
/* ITEMS */
public static ItemStack ironPipe;
public static ItemStack bronzePipe;
public static ItemStack fuelPipe;
public static ItemStack lavePipe;
public static ItemStack oilPipe;
public static ItemStack bioPipe;
public static ItemStack wastePipe;
@Override
public void loadRecipes()
{
ironPipe = new ItemStack(blockGenPipe, 1, 15);
bronzePipe = new ItemStack(blockPipe, 4, ColorCode.ORANGE.ordinal());
this.registerPipes();
this.registerTanks();
@ -57,9 +44,6 @@ public class FMRecipeLoader extends RecipeLoader
// mechanical rod
GameRegistry.addRecipe(new ItemStack(blockRod, 1), new Object[] { "I@I", 'I', Item.ingotIron, '@', new ItemStack(CoreRecipeLoader.itemParts, 1, Parts.Iron.ordinal()) });
// white pipe crafting -- has to be separate since iron pipe is #15 instead of white
GameRegistry.addRecipe(new ItemStack(blockGenPipe, 4, ColorCode.WHITE.ordinal()), new Object[] { " P ", "PCP", " P ", 'P', blockGenPipe, 'C', new ItemStack(Item.dyePowder, 1, 15) });
// pump
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockMachine, 1, 0), new Object[] { "C@C", "BMB", "@X@", '@', "plateSteel", 'X', new ItemStack(blockPipe, 1), 'B', new ItemStack(CoreRecipeLoader.itemParts, 1, Parts.Valve.ordinal()), 'C', "basicCircuit", 'M', "motor" }));
// construction pump
@ -71,7 +55,6 @@ public class FMRecipeLoader extends RecipeLoader
GameRegistry.addRecipe(new ItemStack(blockReleaseValve, 1), new Object[] { "RPR", "PVP", "RPR", 'P', new ItemStack(blockPipe, 1), 'V', new ItemStack(CoreRecipeLoader.itemParts, 1, Parts.Valve.ordinal()), 'R', Item.redstone });
// sink
GameRegistry.addRecipe(new ItemStack(blockSink, 1), new Object[] { "I I", "SIS", "SPS", 'P', new ItemStack(blockPipe, 1), 'I', Item.ingotIron, 'S', Block.stone });
GameRegistry.addRecipe(new ItemStack(blockSink, 1), new Object[] { "I I", "SIS", "SPS", 'P', new ItemStack(blockGenPipe, 1), 'I', Item.ingotIron, 'S', Block.stone });
}
public void registerTanks()
@ -89,30 +72,27 @@ public class FMRecipeLoader extends RecipeLoader
public void registerPipes()
{
// Iron Pipe
GameRegistry.addShapelessRecipe(ironPipe, new Object[] { CoreRecipeLoader.ironTube, CoreRecipeLoader.leatherSeal });
GameRegistry.addShapelessRecipe(PipeData.IRON_PIPE.itemStack, new Object[] { CoreRecipeLoader.ironTube, CoreRecipeLoader.leatherSeal });
// Lava Tube
new RecipeGrid(new ItemStack(blockPipe, 1, ColorCode.RED.ordinal()), 3, 1).setRowOne(CoreRecipeLoader.netherTube, CoreRecipeLoader.obbyTube, CoreRecipeLoader.netherTube).RegisterRecipe();
// fuel pipe
GameRegistry.addShapelessRecipe(new ItemStack(blockPipe, 4, ColorCode.YELLOW.ordinal()), new Object[] { new ItemStack(blockGenPipe, 1, ColorCode.YELLOW.ordinal()), new ItemStack(blockGenPipe, 1, ColorCode.YELLOW.ordinal()), new ItemStack(blockGenPipe, 1, ColorCode.YELLOW.ordinal()), new ItemStack(blockGenPipe, 1, ColorCode.YELLOW.ordinal()), new ItemStack(CoreRecipeLoader.itemParts, 1, Parts.SlimeSeal.ordinal()) });
GameRegistry.addShapelessRecipe(new ItemStack(blockPipe, 4, ColorCode.YELLOW.ordinal()), new Object[] { PipeData.YELLOW_PIPE.itemStack, PipeData.YELLOW_PIPE.itemStack, PipeData.YELLOW_PIPE.itemStack, PipeData.YELLOW_PIPE.itemStack, new ItemStack(CoreRecipeLoader.itemParts, 1, Parts.SlimeSeal.ordinal()) });
// oil pipe
GameRegistry.addShapelessRecipe(new ItemStack(blockPipe, 4, ColorCode.BLACK.ordinal()), new Object[] { new ItemStack(blockGenPipe, 1, ColorCode.BLACK.ordinal()), new ItemStack(blockGenPipe, 1, ColorCode.BLACK.ordinal()), new ItemStack(blockGenPipe, 1, ColorCode.BLACK.ordinal()), new ItemStack(blockGenPipe, 1, ColorCode.BLACK.ordinal()), new ItemStack(CoreRecipeLoader.itemParts, 1, Parts.SlimeSeal.ordinal()) });
GameRegistry.addShapelessRecipe(new ItemStack(blockPipe, 4, ColorCode.BLACK.ordinal()), new Object[] { PipeData.BLACK_PIPE.itemStack, PipeData.BLACK_PIPE.itemStack, PipeData.BLACK_PIPE.itemStack, PipeData.BLACK_PIPE.itemStack, new ItemStack(CoreRecipeLoader.itemParts, 1, Parts.SlimeSeal.ordinal()) });
// water pipe
GameRegistry.addShapelessRecipe(new ItemStack(blockPipe, 4, ColorCode.BLUE.ordinal()), new Object[] { new ItemStack(blockGenPipe, 1, ColorCode.BLUE.ordinal()), new ItemStack(blockGenPipe, 1, ColorCode.BLUE.ordinal()), new ItemStack(blockGenPipe, 1, ColorCode.BLUE.ordinal()), new ItemStack(blockGenPipe, 1, ColorCode.BLUE.ordinal()), new ItemStack(CoreRecipeLoader.itemParts, 1, Parts.SlimeSeal.ordinal()) });
GameRegistry.addShapelessRecipe(new ItemStack(blockPipe, 4, ColorCode.BLUE.ordinal()), new Object[] { PipeData.BLUE_PIPE.itemStack, PipeData.BLUE_PIPE.itemStack, PipeData.BLUE_PIPE.itemStack, PipeData.BLUE_PIPE.itemStack, new ItemStack(CoreRecipeLoader.itemParts, 1, Parts.SlimeSeal.ordinal()) });
// bronze pipes
GameRegistry.addShapelessRecipe(bronzePipe, new Object[] { CoreRecipeLoader.bronzeTube, CoreRecipeLoader.slimeSeal });
//GameRegistry.addShapelessRecipe(PipeData., new Object[] { CoreRecipeLoader.bronzeTube, CoreRecipeLoader.slimeSeal });
// generic pipe crafting
for (int pipeMeta = 0; pipeMeta < 15; pipeMeta++)
{
if (pipeMeta != ColorCode.WHITE.ordinal() && pipeMeta != 15)
{
new RecipeGrid(new ItemStack(blockGenPipe, 4, pipeMeta)).setRowOne(null, blockGenPipe, null).setRowTwo(blockGenPipe, new ItemStack(Item.dyePowder, 1, pipeMeta), blockGenPipe).setRowOne(null, blockGenPipe, null).RegisterRecipe();
}
new RecipeGrid(new ItemStack(blockPipe, 4, pipeMeta)).setRowOne(null, blockPipe, null).setRowTwo(blockPipe, new ItemStack(Item.dyePowder, 1, pipeMeta), blockPipe).setRowOne(null, blockPipe, null).RegisterRecipe();
}
new RecipeGrid(ironPipe, 1, 1).setRowOne(blockGenPipe).RegisterRecipe();
new RecipeGrid(ironPipe, 1, 1).setRowOne(blockPipe).RegisterRecipe();
new RecipeGrid(PipeData.IRON_PIPE.itemStack, 1, 1).setRowOne(blockPipe).RegisterRecipe();
}
}

View file

@ -180,8 +180,7 @@ public class FluidMech extends ModPrefab
}
}
/* BLOCK DECLARATION -- CONFIG LOADER */
FMRecipeLoader.blockGenPipe = new BlockPipe(getNextID(), "GenericPipe");
FMRecipeLoader.blockPipe = new BlockPipe(getNextID(), "RestrictedPipe");
FMRecipeLoader.blockPipe = new BlockPipe(getNextID());
FMRecipeLoader.blockMachine = new BlockPumpMachine(getNextID());
FMRecipeLoader.blockRod = new BlockRod(getNextID());
FMRecipeLoader.blockGenerator = new BlockGenerator(getNextID());

View file

@ -145,7 +145,7 @@ public class TileEntityTank extends TileEntityFluidStorage implements IFluidHand
if (this.flagForColorCodeUpdate)
{
int meta = this.worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
if (meta == 15 || this.worldObj.getBlockId(xCoord, yCoord, zCoord) == FMRecipeLoader.blockGenPipe.blockID)
if (meta == 15)
{
this.colorCode = ColorCode.UNKOWN;
}

View file

@ -1,6 +1,6 @@
package dark.fluid.common.pipes;
import java.util.ArrayList;
import java.awt.Color;
import java.util.List;
import java.util.Set;
@ -18,8 +18,6 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import dark.api.ColorCode;
import dark.api.ColorCode.IColorCoded;
import dark.api.fluid.INetworkPipe;
import dark.core.prefab.IExtraObjectInfo;
import dark.core.prefab.helpers.FluidHelper;
import dark.core.prefab.helpers.Pair;
import dark.fluid.common.BlockFM;
@ -30,9 +28,9 @@ public class BlockPipe extends BlockFM
public static int waterFlowRate = 3000;
public BlockPipe(int id, String name)
public BlockPipe(int id)
{
super(name, id, Material.iron);
super("FluidPipe", id, Material.iron);
this.setBlockBounds(0.30F, 0.30F, 0.30F, 0.70F, 0.70F, 0.70F);
this.setHardness(1f);
this.setResistance(3f);
@ -69,21 +67,29 @@ public class BlockPipe extends BlockFM
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z)
{
int meta = world.getBlockMetadata(x, y, z);
int blockID = world.getBlockId(x, y, z);
return new ItemStack(blockID, 1, meta);
TileEntity tile = world.getBlockTileEntity(x, y, z);
if (tile instanceof TileEntityPipe)
{
meta = ((TileEntityPipe) tile).pipeData.ordinal();
}
return new ItemStack(blockID, 1, meta & 32);
}
@Override
public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
{
for (int i = 0; i < 32; i++)
for (PipeData data : PipeData.values())
{
if (this.blockID != FMRecipeLoader.blockGenPipe.blockID)
if (data.restrictedCode != null)
{
if (i >= 16 || i < 16 && FluidHelper.hasRestrictedStack(i))
{
par3List.add(new ItemStack(par1, 1, i));
}
data.enabled = FluidHelper.hasRestrictedStack(data.restrictedCode.ordinal());
}
if (data.enabled)
{
data.itemStack = new ItemStack(par1, 1, data.ordinal());
par3List.add(data.itemStack);
}
}
}
@ -113,7 +119,7 @@ public class BlockPipe extends BlockFM
@Override
public boolean recolourBlock(World world, int x, int y, int z, ForgeDirection side, int colour)
{
if (this.blockID == FMRecipeLoader.blockGenPipe.blockID)
if (world.getBlockMetadata(x, y, z) < 16)
{
if (world.getBlockTileEntity(x, y, z) instanceof IColorCoded)
{
@ -151,12 +157,83 @@ public class BlockPipe extends BlockFM
if (par1World.rand.nextFloat() <= par6)
{
int meta = 0;
if (par1World.getBlockTileEntity(par2, par3, par4) instanceof IColorCoded)
TileEntity tile = par1World.getBlockTileEntity(par2, par3, par4);
if (tile instanceof TileEntityPipe)
{
meta = ((IColorCoded) par1World.getBlockTileEntity(par2, par3, par4)).getColor().ordinal() & 15;
meta = ((TileEntityPipe) tile).pipeData.ordinal();
}
this.dropBlockAsItem_do(par1World, par2, par3, par4, new ItemStack(this.blockID, 1, meta));
}
}
}
public static enum PipeData
{
BLACK_PIPE(ColorCode.BLACK),
RED_PIPE(ColorCode.RED),
GREEN_PIPE(ColorCode.GREEN),
BROWN_PIPE(ColorCode.BROWN),
BLUE_PIPE(ColorCode.BLUE),
PURPLE_PIPE(ColorCode.PURPLE),
CYAN_PIPE(ColorCode.CYAN),
SILVER_PIPE(ColorCode.SILVER),
GREY_PIPE(ColorCode.GREY),
PINK_PIPE(ColorCode.PINK),
LIME_PIPE(ColorCode.LIME),
YELLOW_PIPE(ColorCode.YELLOW),
LIGHTBLUE_PIPE(ColorCode.LIGHTBLUE),
MAGENTA_PIPE(ColorCode.MAGENTA),
ORANGE_PIPE(ColorCode.ORANGE),
WHITE_PIPE(ColorCode.WHITE),
OIL_PIPE(true, ColorCode.BLACK),
FUEL_PIPE(true, ColorCode.YELLOW),
LAVA_PIPE(true, ColorCode.RED),
WATER_PIPE(true, ColorCode.BLUE),
WASTE_PIPE(true, ColorCode.BROWN),
PIPE6(false),
PIPE7(false),
PIPE8(false),
PIPE9(false),
PIPE10(false),
PIPE11(false),
PIPE12(false),
PIPE13(false),
PIPE14(false),
IRON_PIPE();
public boolean enabled = true;
public ColorCode colorCode, restrictedCode;
public ItemStack itemStack;
private PipeData(ColorCode color)
{
this.colorCode = color;
}
private PipeData()
{
this(ColorCode.UNKOWN);
}
private PipeData(Boolean enabled)
{
this(ColorCode.UNKOWN);
this.enabled = true;
}
private PipeData(Boolean enabled, ColorCode restrictedCode)
{
this(enabled);
this.restrictedCode = restrictedCode;
}
public static PipeData get(Object obj)
{
if (obj instanceof Integer && ((Integer) obj) < PipeData.values().length)
{
return PipeData.values()[((Integer) obj)];
}
return IRON_PIPE;
}
}
}

View file

@ -38,10 +38,14 @@ public class ItemBlockPipe extends ItemBlock
TileEntity tile = world.getBlockTileEntity(x, y, z);
if (tile instanceof IColorCoded)
{
((IColorCoded) tile).setColor((stack.getItemDamage() % 16) & 15);
if (tile instanceof TileEntityPipe && stack.getItemDamage() < 16)
if (tile instanceof TileEntityPipe)
{
((TileEntityPipe) tile).setRestricted(true);
((TileEntityPipe) tile).setPipeID(stack.getItemDamage());
}
else
{
((IColorCoded) tile).setColor((stack.getItemDamage() % 16) & 15);
}
}
return true;

View file

@ -41,6 +41,7 @@ import dark.core.prefab.helpers.FluidHelper;
import dark.core.prefab.tilenetwork.NetworkTileEntities;
import dark.core.prefab.tilenetwork.fluid.NetworkPipes;
import dark.fluid.common.FMRecipeLoader;
import dark.fluid.common.pipes.BlockPipe.PipeData;
public class TileEntityPipe extends TileEntityAdvanced implements IFluidHandler, IToolReadOut, IColorCoded, INetworkPipe, IPacketReceiver
{
@ -55,12 +56,12 @@ 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 ColorCode colorCode = ColorCode.UNKOWN;
protected boolean flagForColorCodeUpdate = false, isRestricted = false, resetting = false;
protected boolean flagForColorCodeUpdate = false, resetting = false;
protected int updateTick = 1;
String refClassID = "";
public enum PipePacketID
{
@ -77,32 +78,13 @@ public class TileEntityPipe extends TileEntityAdvanced implements IFluidHandler,
if (this.flagForColorCodeUpdate)
{
int meta = this.worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
if (meta == 15 || this.worldObj.getBlockId(xCoord, yCoord, zCoord) == FMRecipeLoader.blockGenPipe.blockID)
if (!this.refClassID.equalsIgnoreCase("ColoredPipe"))
{
this.colorCode = ColorCode.UNKOWN;
}
else
{
this.colorCode = ColorCode.get(meta);
meta += 16;
}
this.pipeData = PipeData.values()[meta & 31];
this.worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 3);
this.flagForColorCodeUpdate = false;
if (this.worldObj.getBlockId(xCoord, yCoord, zCoord) == FMRecipeLoader.blockPipe.blockID)
{
this.isRestricted = true;
}
}
if (this.worldObj.getBlockId(xCoord, yCoord, zCoord) == FMRecipeLoader.blockGenPipe.blockID)
{
this.resetting = true;
NBTTagCompound tag = new NBTTagCompound();
this.writeToNBT(tag);
this.worldObj.setBlock(xCoord, yCoord, zCoord, FMRecipeLoader.blockPipe.blockID, 0, 2);
TileEntity tile = this.worldObj.getBlockTileEntity(xCoord, yCoord, zCoord);
if (tile instanceof TileEntityPipe)
{
tile.readFromNBT(tag);
}
}
}
}
@ -139,8 +121,7 @@ public class TileEntityPipe extends TileEntityAdvanced implements IFluidHandler,
{
if (this.worldObj.isRemote)
{
this.colorCode = ColorCode.get(dataStream.readInt());
this.isRestricted = dataStream.readBoolean();
this.pipeData = PipeData.values()[dataStream.readInt()];
this.renderConnection[0] = dataStream.readBoolean();
this.renderConnection[1] = dataStream.readBoolean();
this.renderConnection[2] = dataStream.readBoolean();
@ -159,89 +140,31 @@ public class TileEntityPipe extends TileEntityAdvanced implements IFluidHandler,
@Override
public Packet getDescriptionPacket()
{
return PacketHandler.instance().getPacket(DarkMain.CHANNEL, this, this.colorCode.ordinal(), this.isRestricted(), this.renderConnection[0], this.renderConnection[1], this.renderConnection[2], this.renderConnection[3], this.renderConnection[4], this.renderConnection[5]);
}
/** Reads a tile entity from NBT. */
@Override
public void readFromNBT(NBTTagCompound nbt)
{
super.readFromNBT(nbt);
//Load color code from nbt
if (nbt.hasKey("ColorCode"))
{
this.colorCode = ColorCode.get(nbt.getInteger("ColorCode"));
}
else
{
this.flagForColorCodeUpdate = true;
}
this.isRestricted = nbt.getBoolean("isRestricted");
//Load fluid tank
FluidStack liquid = FluidStack.loadFluidStackFromNBT(nbt.getCompoundTag("FluidTank"));
if (nbt.hasKey("stored"))
{
NBTTagCompound tag = nbt.getCompoundTag("stored");
String name = tag.getString("LiquidName");
int amount = nbt.getInteger("Amount");
Fluid fluid = FluidRegistry.getFluid(name);
if (fluid != null)
{
liquid = new FluidStack(fluid, amount);
}
}
if (liquid != null)
{
this.tank.setFluid(liquid);
}
}
/** Writes a tile entity to NBT. */
@Override
public void writeToNBT(NBTTagCompound nbt)
{
super.writeToNBT(nbt);
nbt.setInteger("ColorCode", this.colorCode.ordinal());
nbt.setBoolean("isRestricted", this.isRestricted());
if (this.tank != null && this.tank.getFluid() != null)
{
nbt.setTag("FluidTank", this.tank.getFluid().writeToNBT(new NBTTagCompound()));
}
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]);
}
/** gets the current color mark of the pipe */
@Override
public ColorCode getColor()
{
return this.colorCode;
return this.pipeData.colorCode;
}
/** sets the current color mark of the pipe */
@Override
public void setColor(Object cc)
{
if (!worldObj.isRemote)
if (!worldObj.isRemote && (this.pipeData.colorCode != ColorCode.UNKOWN || this.pipeData == PipeData.IRON_PIPE))
{
this.colorCode = ColorCode.get(cc);
this.pipeData = PipeData.get(ColorCode.get(cc).ordinal());
}
}
public void setRestricted(boolean bo)
{
this.isRestricted = bo;
}
public boolean isRestricted()
{
return this.isRestricted;
}
@Override
public String getMeterReading(EntityPlayer user, ForgeDirection side, EnumTools tool)
{
/* DEBUG CODE ACTIVATERS */
boolean testConnections = false, testNetwork = true;
boolean testConnections = false, testNetwork = false;
/* NORMAL OUTPUT */
String string = ((NetworkPipes) this.getTileNetwork()).pressureProduced + "p " + ((NetworkPipes) this.getTileNetwork()).getNetworkFluid() + " Extra";
@ -301,8 +224,19 @@ public class TileEntityPipe extends TileEntityAdvanced implements IFluidHandler,
{
if (((INetworkPipe) tileEntity).getColor() == this.getColor())
{
this.getTileNetwork().merge(((INetworkPipe) tileEntity).getTileNetwork(), this);
return connectedBlocks.add(tileEntity);
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);
}
}
}
@ -370,7 +304,7 @@ public class TileEntityPipe extends TileEntityAdvanced implements IFluidHandler,
@Override
public boolean canTileConnect(Connection type, ForgeDirection dir)
{
return new Vector3(this).modifyPositionFromSide(dir).getTileEntity(this.worldObj) != null;
return new Vector3(this).modifyPositionFromSide(dir).getTileEntity(this.worldObj) instanceof IFluidHandler;
}
@Override
@ -510,4 +444,56 @@ public class TileEntityPipe extends TileEntityAdvanced implements IFluidHandler,
return 1;
}
/** Reads a tile entity from NBT. */
@Override
public void readFromNBT(NBTTagCompound nbt)
{
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;
}
//Load fluid tank
FluidStack liquid = FluidStack.loadFluidStackFromNBT(nbt.getCompoundTag("FluidTank"));
if (nbt.hasKey("stored"))
{
NBTTagCompound tag = nbt.getCompoundTag("stored");
String name = tag.getString("LiquidName");
int amount = nbt.getInteger("Amount");
Fluid fluid = FluidRegistry.getFluid(name);
if (fluid != null)
{
liquid = new FluidStack(fluid, amount);
}
}
if (liquid != null)
{
this.tank.setFluid(liquid);
}
}
/** Writes a tile entity to NBT. */
@Override
public void writeToNBT(NBTTagCompound nbt)
{
super.writeToNBT(nbt);
nbt.setInteger("PipeID", this.pipeData.ordinal());
if (this.tank != null && this.tank.getFluid() != null)
{
nbt.setTag("FluidTank", this.tank.getFluid().writeToNBT(new NBTTagCompound()));
}
}
public void setPipeID(int itemDamage)
{
this.pipeData = PipeData.get(itemDamage);
}
}