From 7aed9a4618def52b028170474807f667b0cd971b Mon Sep 17 00:00:00 2001 From: Rseifert Date: Fri, 29 Mar 2013 18:00:37 -0400 Subject: [PATCH] Working out how to do pressure At this point i'm a bit lost on how to do pressure in the system. I know that the pressure will decrease with each part in the system it pass threw. Which means later i'll need to add a path finder to simulate this. However, right now i can't figure out how to do pressure produced and pressure load needed. The only way i know is with one source of pressure but in minecraft people will not just add one source of pressure for a system. --- .../common/machines/TileEntityMinorPump.java | 21 +- .../machines/TileEntityReleaseValve.java | 12 +- .../common/machines/TileEntitySink.java | 250 +++++++++--------- .../common/machines/TileEntityTank.java | 29 +- src/minecraft/hydraulic/api/IPsiCreator.java | 18 -- .../core/liquidNetwork/FluidPressurePack.java | 31 +++ .../core/liquidNetwork/HydraulicNetwork.java | 184 ++++++++++--- 7 files changed, 324 insertions(+), 221 deletions(-) delete mode 100644 src/minecraft/hydraulic/api/IPsiCreator.java create mode 100644 src/minecraft/hydraulic/core/liquidNetwork/FluidPressurePack.java diff --git a/src/minecraft/fluidmech/common/machines/TileEntityMinorPump.java b/src/minecraft/fluidmech/common/machines/TileEntityMinorPump.java index 5646f235..c8615b79 100644 --- a/src/minecraft/fluidmech/common/machines/TileEntityMinorPump.java +++ b/src/minecraft/fluidmech/common/machines/TileEntityMinorPump.java @@ -3,7 +3,7 @@ package fluidmech.common.machines; import fluidmech.common.FluidMech; import hydraulic.api.ColorCode; import hydraulic.api.IColorCoded; -import hydraulic.api.IPsiCreator; +import hydraulic.api.IPipeConnection; import hydraulic.api.IReadOut; import hydraulic.core.liquidNetwork.LiquidData; import hydraulic.core.liquidNetwork.LiquidHandler; @@ -26,12 +26,11 @@ import universalelectricity.prefab.tile.TileEntityElectricityRunnable; import com.google.common.io.ByteArrayDataInput; -public class TileEntityMinorPump extends TileEntityElectricityRunnable implements IPacketReceiver, IReadOut, IPsiCreator +public class TileEntityMinorPump extends TileEntityElectricityRunnable implements IPacketReceiver, IReadOut, IPipeConnection { public final double WATTS_PER_TICK = (400 / 20); - double percentPumped = 0.0; + private double percentPumped = 0.0; - int disableTimer = 0; public int pos = 0; public ColorCode color = ColorCode.BLUE; @@ -73,7 +72,8 @@ public class TileEntityMinorPump extends TileEntityElectricityRunnable implement percentPumped = 0; this.drainBlock(new Vector3(xCoord, yCoord - 1, zCoord)); } - // // Do animation to simulate life // + + /* DO ANIMATION CHANGE */ this.pos++; if (pos >= 8) { @@ -82,7 +82,6 @@ public class TileEntityMinorPump extends TileEntityElectricityRunnable implement } if (this.ticks % 10 == 0) { - // TODO fix this to tell the client its running Packet packet = PacketManager.getPacket(FluidMech.CHANNEL, this, color.ordinal(), this.wattsReceived); PacketManager.sendPacketToClients(packet, worldObj, new Vector3(this), 60); } @@ -198,16 +197,6 @@ public class TileEntityMinorPump extends TileEntityElectricityRunnable implement return this.wattsReceived + "/" + this.WATTS_PER_TICK + "W " + this.percentPumped + "% DONE"; } - @Override - public int getPressureOut(LiquidStack type, ForgeDirection dir) - { - if (type != null && this.color.isValidLiquid(type)) - { - return LiquidHandler.get(type).getPressure(); - } - return 0; - } - @Override public boolean canConnect(ForgeDirection direction) { diff --git a/src/minecraft/fluidmech/common/machines/TileEntityReleaseValve.java b/src/minecraft/fluidmech/common/machines/TileEntityReleaseValve.java index abfd344c..ad229bd5 100644 --- a/src/minecraft/fluidmech/common/machines/TileEntityReleaseValve.java +++ b/src/minecraft/fluidmech/common/machines/TileEntityReleaseValve.java @@ -3,7 +3,7 @@ package fluidmech.common.machines; import fluidmech.common.machines.pipes.TileEntityPipe; import hydraulic.api.ColorCode; import hydraulic.api.IColorCoded; -import hydraulic.api.IPsiCreator; +import hydraulic.api.IPipeConnection; import hydraulic.api.IReadOut; import hydraulic.core.liquidNetwork.LiquidHandler; import hydraulic.helpers.connectionHelper; @@ -22,7 +22,7 @@ import net.minecraftforge.liquids.LiquidContainerRegistry; import net.minecraftforge.liquids.LiquidStack; import universalelectricity.prefab.tile.TileEntityAdvanced; -public class TileEntityReleaseValve extends TileEntityAdvanced implements IPsiCreator, IReadOut +public class TileEntityReleaseValve extends TileEntityAdvanced implements IPipeConnection, IReadOut { public boolean[] allowed = new boolean[ColorCode.values().length - 1]; public TileEntity[] connected = new TileEntity[6]; @@ -73,7 +73,7 @@ public class TileEntityReleaseValve extends TileEntityAdvanced implements IPsiCr if (inputPipe != null) { ILiquidTank pipeVolume = inputPipe.getTanks(ForgeDirection.UNKNOWN)[0]; - int ammountFilled = inputPipe.fill(ForgeDirection.UNKNOWN, stack, true); + int ammountFilled = inputPipe.getNetwork().addFluidToNetwork(stack, 100, true); drainedTank.drain(ForgeDirection.UNKNOWN, ammountFilled, true); } } @@ -207,12 +207,6 @@ public class TileEntityReleaseValve extends TileEntityAdvanced implements IPsiCr } } - @Override - public int getPressureOut(LiquidStack type, ForgeDirection dir) - { - return (type != null && this.canConnect(ColorCode.get(type)) ? LiquidHandler.get(type).getPressure() : 0); - } - @Override public boolean canConnect(TileEntity entity, ForgeDirection dir) { diff --git a/src/minecraft/fluidmech/common/machines/TileEntitySink.java b/src/minecraft/fluidmech/common/machines/TileEntitySink.java index c1fc393a..4d3890bd 100644 --- a/src/minecraft/fluidmech/common/machines/TileEntitySink.java +++ b/src/minecraft/fluidmech/common/machines/TileEntitySink.java @@ -1,5 +1,7 @@ package fluidmech.common.machines; +import java.util.Random; + import fluidmech.common.FluidMech; import hydraulic.api.ColorCode; import hydraulic.api.IColorCoded; @@ -19,148 +21,150 @@ import net.minecraftforge.liquids.LiquidTank; import universalelectricity.core.vector.Vector3; import universalelectricity.prefab.network.IPacketReceiver; import universalelectricity.prefab.network.PacketManager; +import universalelectricity.prefab.tile.TileEntityAdvanced; import com.google.common.io.ByteArrayDataInput; -public class TileEntitySink extends TileEntity implements IPacketReceiver, ITankContainer, IColorCoded +public class TileEntitySink extends TileEntityAdvanced implements IPacketReceiver, ITankContainer, IColorCoded { - public TileEntity[] cc = { null, null, null, null, null, null }; + public TileEntity[] cc = { null, null, null, null, null, null }; - private ColorCode color = ColorCode.BLUE; + public static final int LMax = 2; + private int count = 100; + private Random random = new Random(); + private LiquidTank tank = new LiquidTank(LiquidContainerRegistry.BUCKET_VOLUME * LMax); - public static final int LMax = 2; - private int count = 100; - private LiquidTank tank = new LiquidTank(LiquidContainerRegistry.BUCKET_VOLUME * LMax); + @Override + public void updateEntity() + { + if (!worldObj.isRemote) + { + if (ticks % (random.nextInt(5) * 10 + 20) == 0) + { + this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); + } + } + } - @Override - public void updateEntity() - { - if (count++ >= 100) - { - triggerUpdate(); - } - } + @Override + public Packet getDescriptionPacket() + { + if (this.getStack() != null) + { + return PacketManager.getPacket(FluidMech.CHANNEL, this, this.getStack().itemID, this.getStack().amount, this.getStack().itemMeta); + } + else + { + return PacketManager.getPacket(FluidMech.CHANNEL, this, 0, 0, 0); + } + } - /** - */ - public void triggerUpdate() - { - if (!worldObj.isRemote) - { - LiquidStack stack = new LiquidStack(0, 0, 0); - if (this.tank.getLiquid() != null) - { - stack = this.tank.getLiquid(); - } - Packet packet = PacketManager.getPacket(FluidMech.CHANNEL, this, new Object[] { stack.itemID, stack.amount, stack.itemMeta }); - PacketManager.sendPacketToClients(packet, worldObj, new Vector3(this), 20); + public LiquidStack getStack() + { + return tank.getLiquid(); + } - } - } + @Override + public void readFromNBT(NBTTagCompound nbt) + { + super.readFromNBT(nbt); - public LiquidStack getStack() - { - return tank.getLiquid(); - } + LiquidStack liquid = new LiquidStack(0, 0, 0); + liquid.readFromNBT(nbt.getCompoundTag("stored")); + tank.setLiquid(liquid); + } - @Override - public void readFromNBT(NBTTagCompound nbt) - { - super.readFromNBT(nbt); + @Override + public void writeToNBT(NBTTagCompound nbt) + { + super.writeToNBT(nbt); + if (tank.getLiquid() != null) + { + nbt.setTag("stored", tank.getLiquid().writeToNBT(new NBTTagCompound())); + } + } - LiquidStack liquid = new LiquidStack(0, 0, 0); - liquid.readFromNBT(nbt.getCompoundTag("stored")); - tank.setLiquid(liquid); - } + @Override + public void handlePacketData(INetworkManager network, int packetType, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput data) + { + try + { + this.tank.setLiquid(new LiquidStack(data.readInt(), data.readInt(), data.readInt())); + } + catch (Exception e) + { + e.printStackTrace(); + System.out.print("Fail reading data for Storage tank \n"); + } - @Override - public void writeToNBT(NBTTagCompound nbt) - { - super.writeToNBT(nbt); - if (tank.getLiquid() != null) - { - nbt.setTag("stored", tank.getLiquid().writeToNBT(new NBTTagCompound())); - } - } + } - @Override - public void handlePacketData(INetworkManager network, int packetType, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput data) - { - try - { - this.tank.setLiquid(new LiquidStack(data.readInt(), data.readInt(), data.readInt())); - } - catch (Exception e) - { - e.printStackTrace(); - System.out.print("Fail reading data for Storage tank \n"); - } + @Override + public int fill(ForgeDirection from, LiquidStack resource, boolean doFill) + { + return (resource == null || (!this.getColor().getLiquidData().getStack().isLiquidEqual(resource))) ? 0 : this.fill(0, resource, doFill); + } - } + @Override + public int fill(int tankIndex, LiquidStack resource, boolean doFill) + { + if (resource == null || tankIndex != 0) + { + return 0; + } + if (doFill) + { + this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); + } + return this.tank.fill(resource, doFill); + } - @Override - public int fill(ForgeDirection from, LiquidStack resource, boolean doFill) - { - if (resource == null || (!color.getLiquidData().getStack().isLiquidEqual(resource))) { return 0; } - return this.fill(0, resource, doFill); - } + @Override + public LiquidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) + { + return this.drain(0, maxDrain, doDrain); + } - @Override - public int fill(int tankIndex, LiquidStack resource, boolean doFill) - { - if (resource == null || tankIndex != 0) { return 0; } - if (doFill) - { - triggerUpdate(); - } - return this.tank.fill(resource, doFill); - } + @Override + public LiquidStack drain(int tankIndex, int maxDrain, boolean doDrain) + { + if (tankIndex != 0 || this.tank.getLiquid() == null) + { + return null; + } + LiquidStack stack = this.tank.getLiquid(); + if (maxDrain < this.tank.getLiquid().amount) + { + stack = LiquidHandler.getStack(stack, maxDrain); + } + if (doDrain) + { + this.tank.drain(maxDrain, doDrain); + this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); + } + return stack; + } - @Override - public LiquidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) - { - return this.drain(0, maxDrain, doDrain); - } + @Override + public ILiquidTank[] getTanks(ForgeDirection direction) + { + return new ILiquidTank[] { tank }; + } - @Override - public LiquidStack drain(int tankIndex, int maxDrain, boolean doDrain) - { - if (tankIndex != 0 || this.tank.getLiquid() == null) { return null; } - LiquidStack stack = this.tank.getLiquid(); - if (maxDrain < this.tank.getLiquid().amount) - { - stack = LiquidHandler.getStack(stack, maxDrain); - } - if (doDrain) - { - triggerUpdate(); - this.tank.drain(maxDrain, doDrain); + @Override + public ILiquidTank getTank(ForgeDirection direction, LiquidStack type) + { + return tank; + } - } - return stack; - } + @Override + public void setColor(Object obj) + { + } - @Override - public ILiquidTank[] getTanks(ForgeDirection direction) - { - return new ILiquidTank[] { tank }; - } - - @Override - public ILiquidTank getTank(ForgeDirection direction, LiquidStack type) - { - return null; - } - - @Override - public void setColor(Object obj) - { - // this.color = ColorCode.get(cc); - } - - @Override - public ColorCode getColor() - { - return color; - } + @Override + public ColorCode getColor() + { + return ColorCode.BLUE; + } } diff --git a/src/minecraft/fluidmech/common/machines/TileEntityTank.java b/src/minecraft/fluidmech/common/machines/TileEntityTank.java index 1a277801..23bc24cc 100644 --- a/src/minecraft/fluidmech/common/machines/TileEntityTank.java +++ b/src/minecraft/fluidmech/common/machines/TileEntityTank.java @@ -1,16 +1,16 @@ package fluidmech.common.machines; -import java.util.Random; - import fluidmech.common.FluidMech; -import fluidmech.common.machines.pipes.TileEntityPipe; import hydraulic.api.ColorCode; import hydraulic.api.IColorCoded; -import hydraulic.api.IPsiCreator; +import hydraulic.api.IPipeConnection; import hydraulic.api.IReadOut; import hydraulic.core.liquidNetwork.LiquidData; import hydraulic.core.liquidNetwork.LiquidHandler; import hydraulic.helpers.connectionHelper; + +import java.util.Random; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.INetworkManager; @@ -25,14 +25,13 @@ import net.minecraftforge.liquids.LiquidStack; import net.minecraftforge.liquids.LiquidTank; import universalelectricity.core.block.IConductor; import universalelectricity.core.block.IConnectionProvider; -import universalelectricity.core.vector.Vector3; import universalelectricity.prefab.network.IPacketReceiver; import universalelectricity.prefab.network.PacketManager; import universalelectricity.prefab.tile.TileEntityAdvanced; import com.google.common.io.ByteArrayDataInput; -public class TileEntityTank extends TileEntityAdvanced implements IPacketReceiver, IReadOut, IPsiCreator, ITankContainer, IColorCoded, IConnectionProvider +public class TileEntityTank extends TileEntityAdvanced implements IPacketReceiver, IReadOut, IPipeConnection, ITankContainer, IColorCoded, IConnectionProvider { public TileEntity[] connectedBlocks = { null, null, null, null, null, null }; @@ -252,24 +251,6 @@ public class TileEntityTank extends TileEntityAdvanced implements IPacketReceive } - @Override - public int getPressureOut(LiquidStack type, ForgeDirection dir) - { - if (getColor().isValidLiquid(type)) - { - LiquidData data = LiquidHandler.get(type); - if (data.getCanFloat() && dir == ForgeDirection.DOWN) - { - return data.getPressure(); - } - if (!data.getCanFloat() && dir == ForgeDirection.UP) - { - return data.getPressure(); - } - } - return 0; - } - /** Cause this TE to trade liquid with the Tanks around it to level off */ public void fillTanksAround() { diff --git a/src/minecraft/hydraulic/api/IPsiCreator.java b/src/minecraft/hydraulic/api/IPsiCreator.java deleted file mode 100644 index 1f450f35..00000000 --- a/src/minecraft/hydraulic/api/IPsiCreator.java +++ /dev/null @@ -1,18 +0,0 @@ -package hydraulic.api; - -import net.minecraftforge.common.ForgeDirection; -import net.minecraftforge.liquids.LiquidStack; - -public interface IPsiCreator extends IPipeConnection -{ - /** - * gets the pressure produced from that side of the machine. Use canConnect method to allow a - * pipe to connect to the side first. - * - * @param stack - liquid stack that the pressure is being requested for - * @param dir - side being pressured - * @return - amount of pressure produced - */ - public int getPressureOut(LiquidStack stack, ForgeDirection dir); - -} diff --git a/src/minecraft/hydraulic/core/liquidNetwork/FluidPressurePack.java b/src/minecraft/hydraulic/core/liquidNetwork/FluidPressurePack.java new file mode 100644 index 00000000..259ea373 --- /dev/null +++ b/src/minecraft/hydraulic/core/liquidNetwork/FluidPressurePack.java @@ -0,0 +1,31 @@ +package hydraulic.core.liquidNetwork; + +import net.minecraftforge.liquids.LiquidStack; + +public class FluidPressurePack implements Cloneable +{ + public LiquidStack liquidStack; + public double pressure; + + public FluidPressurePack(LiquidStack liquidStack, double voltage) + { + this.liquidStack = liquidStack; + this.pressure = voltage; + } + + public FluidPressurePack() + { + this(new LiquidStack(0, 0, 0), 0); + } + + @Override + public FluidPressurePack clone() + { + return new FluidPressurePack(this.liquidStack, this.pressure); + } + + public boolean isEqual(FluidPressurePack electricityPack) + { + return this.liquidStack.isLiquidEqual(electricityPack.liquidStack) && this.pressure == electricityPack.pressure; + } +} diff --git a/src/minecraft/hydraulic/core/liquidNetwork/HydraulicNetwork.java b/src/minecraft/hydraulic/core/liquidNetwork/HydraulicNetwork.java index b005c10e..338e213a 100644 --- a/src/minecraft/hydraulic/core/liquidNetwork/HydraulicNetwork.java +++ b/src/minecraft/hydraulic/core/liquidNetwork/HydraulicNetwork.java @@ -2,15 +2,14 @@ package hydraulic.core.liquidNetwork; import hydraulic.api.ColorCode; import hydraulic.api.IFluidNetworkPart; -import hydraulic.api.IPipeConnection; -import hydraulic.api.IPsiCreator; -import hydraulic.api.IPsiReciever; import hydraulic.helpers.connectionHelper; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.Iterator; import java.util.List; +import java.util.Map; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.ForgeDirection; @@ -33,10 +32,12 @@ import cpw.mods.fml.common.FMLLog; public class HydraulicNetwork { /* BLOCK THAT ACT AS FLUID CONVEYORS ** */ - public final List conductors = new ArrayList(); - + public final List fluidParts = new ArrayList(); /* MACHINES THAT USE THE FORGE LIQUID API TO RECEIVE LIQUID ** */ - public final List receivers = new ArrayList(); + public final List fluidTanks = new ArrayList(); + /* MACHINES THAT USE THE PRESSURE SYSTEM TO DO WORK ** */ + private final HashMap pressureProducers = new HashMap(); + private final HashMap pressureLoads = new HashMap(); public ColorCode color = ColorCode.NONE; /* PRESSURE OF THE NETWORK AS A TOTAL. ZERO AS IN NO PRODUCTION */ @@ -48,18 +49,139 @@ public class HydraulicNetwork public HydraulicNetwork(ColorCode color, IFluidNetworkPart... parts) { - this.conductors.addAll(Arrays.asList(parts)); + this.fluidParts.addAll(Arrays.asList(parts)); this.color = color; } - public void registerLoad(TileEntity entity) + /** + * sets this tileEntity to produce a pressure and flow rate in the network + */ + public void startProducingPressure(TileEntity tileEntity, FluidPressurePack fluidPack) { - + if (tileEntity != null && fluidPack.liquidStack != null && fluidPack.liquidStack.amount > 0) + { + this.pressureProducers.put(tileEntity, fluidPack); + } } - public void registerProducer(TileEntity entity) + /** + * sets this tileEntity to produce a pressure and flow rate in the network + */ + public void startProducingPressure(TileEntity tileEntity, LiquidStack stack, double pressure) { + this.startProducingPressure(tileEntity, new FluidPressurePack(stack, pressure)); + } + /** + * is this tile entity producing a pressure + */ + public boolean isProducingPressure(TileEntity tileEntity) + { + return this.pressureProducers.containsKey(tileEntity); + } + + /** + * Sets this tile entity to stop producing pressure and flow in this network + */ + public void stopProducing(TileEntity tileEntity) + { + this.pressureProducers.remove(tileEntity); + } + + /** + * Sets this tile entity to act as a load on the system + */ + public void addLoad(TileEntity tileEntity, FluidPressurePack fluidPack) + { + if (tileEntity != null && fluidPack.liquidStack != null && fluidPack.liquidStack.amount > 0) + { + this.pressureLoads.put(tileEntity, fluidPack); + } + } + + /** + * Sets this tile entity to act as a load on the system + */ + public void addLoad(TileEntity tileEntity, LiquidStack stack, double pressure) + { + this.addLoad(tileEntity, new FluidPressurePack(stack, pressure)); + } + + /** + * is this tileEntity a load in the network + */ + public boolean isLoad(TileEntity tileEntity) + { + return this.pressureLoads.containsKey(tileEntity); + } + + /** + * removes this tileEntity from being a load on the network + */ + public void removeLoad(TileEntity tileEntity) + { + this.pressureLoads.remove(tileEntity); + } + + /** + * @param ignoreTiles The TileEntities to ignore during this calculation. Null will make it not + * ignore any. + * @return The electricity produced in this electricity network + */ + public double getPressureProduced(TileEntity... ignoreTiles) + { + int totalPressure = 0; + + Iterator it = this.pressureProducers.entrySet().iterator(); + + loop: + while (it.hasNext()) + { + Map.Entry pairs = (Map.Entry) it.next(); + + if (pairs != null) + { + TileEntity tileEntity = (TileEntity) pairs.getKey(); + + if (tileEntity == null) + { + it.remove(); + continue; + } + + if (tileEntity.isInvalid()) + { + it.remove(); + continue; + } + + if (tileEntity.worldObj.getBlockTileEntity(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord) != tileEntity) + { + it.remove(); + continue; + } + + if (ignoreTiles != null) + { + for (TileEntity ignoreTile : ignoreTiles) + { + if (tileEntity == ignoreTile) + { + continue loop; + } + } + } + + FluidPressurePack pack = (FluidPressurePack) pairs.getValue(); + + if (pairs.getKey() != null && pairs.getValue() != null && pack != null) + { + totalPressure += pack.pressure; + } + } + } + + return totalPressure; } /** @@ -91,7 +213,7 @@ public class HydraulicNetwork boolean found = false; - for (ITankContainer tankContainer : receivers) + for (ITankContainer tankContainer : fluidTanks) { if (tankContainer instanceof TileEntity) { @@ -165,7 +287,7 @@ public class HydraulicNetwork public int getMaxFlow(LiquidStack stack) { int flow = 1000; - for (IFluidNetworkPart conductor : this.conductors) + for (IFluidNetworkPart conductor : this.fluidParts) { // TODO change the direction to actual look for connected only directions and pipes // along @@ -192,9 +314,9 @@ public class HydraulicNetwork */ public void removeEntity(TileEntity ent) { - if (receivers.contains(ent)) + if (fluidTanks.contains(ent)) { - receivers.remove(ent); + fluidTanks.remove(ent); } } @@ -207,9 +329,9 @@ public class HydraulicNetwork { return; } - if (!receivers.contains(ent)) + if (!fluidTanks.contains(ent)) { - receivers.add(ent); + fluidTanks.add(ent); } } @@ -217,24 +339,24 @@ public class HydraulicNetwork { this.cleanConductors(); - if (code == this.color && !conductors.contains(newConductor)) + if (code == this.color && !fluidParts.contains(newConductor)) { - conductors.add(newConductor); + fluidParts.add(newConductor); newConductor.setNetwork(this); } } public void cleanConductors() { - for (int i = 0; i < conductors.size(); i++) + for (int i = 0; i < fluidParts.size(); i++) { - if (conductors.get(i) == null) + if (fluidParts.get(i) == null) { - conductors.remove(i); + fluidParts.remove(i); } - else if (((TileEntity) conductors.get(i)).isInvalid()) + else if (((TileEntity) fluidParts.get(i)).isInvalid()) { - conductors.remove(i); + fluidParts.remove(i); } } } @@ -243,7 +365,7 @@ public class HydraulicNetwork { this.cleanConductors(); - for (IFluidNetworkPart conductor : this.conductors) + for (IFluidNetworkPart conductor : this.fluidParts) { conductor.setNetwork(this); } @@ -253,13 +375,13 @@ public class HydraulicNetwork { this.cleanConductors(); - for (int i = 0; i < conductors.size(); i++) + for (int i = 0; i < fluidParts.size(); i++) { // TODO change to actual check connected sides only && get true value from settings file - IFluidNetworkPart part = conductors.get(i); + IFluidNetworkPart part = fluidParts.get(i); if (part.getMaxPressure(ForgeDirection.UNKNOWN) < this.pressureProduced && part.onOverPressure(true)) { - this.conductors.remove(part); + this.fluidParts.remove(part); this.cleanConductors(); } @@ -268,7 +390,7 @@ public class HydraulicNetwork public void cleanUpConductors() { - Iterator it = this.conductors.iterator(); + Iterator it = this.fluidParts.iterator(); while (it.hasNext()) { @@ -302,7 +424,7 @@ public class HydraulicNetwork try { - Iterator it = this.conductors.iterator(); + Iterator it = this.fluidParts.iterator(); while (it.hasNext()) { @@ -319,7 +441,7 @@ public class HydraulicNetwork public List getFluidNetworkParts() { - return this.conductors; + return this.fluidParts; } public void mergeNetworks(HydraulicNetwork network) @@ -411,6 +533,6 @@ public class HydraulicNetwork @Override public String toString() { - return "hydraulicNetwork[" + this.hashCode() + "|parts:" + this.conductors.size() + "]"; + return "hydraulicNetwork[" + this.hashCode() + "|parts:" + this.fluidParts.size() + "]"; } }