From 30fc0c091441b082050e602ed6bb7f74a4bb6182 Mon Sep 17 00:00:00 2001 From: DarkGuardsman Date: Sun, 30 Jun 2013 19:23:37 -0400 Subject: [PATCH] cleanup --- .../network/fluid/NetworkFluidContainers.java | 4 +- .../core/network/fluid/NetworkFluidTiles.java | 6 +- .../dark/core/network/fluid/NetworkPipes.java | 6 +- .../dark/fluid/common/machines/BlockTank.java | 61 ++++++++++++------- .../fluid/common/machines/TileEntityTank.java | 42 ++++++++----- 5 files changed, 74 insertions(+), 45 deletions(-) diff --git a/src/minecraft/dark/core/network/fluid/NetworkFluidContainers.java b/src/minecraft/dark/core/network/fluid/NetworkFluidContainers.java index 8984721b..92d8a9df 100644 --- a/src/minecraft/dark/core/network/fluid/NetworkFluidContainers.java +++ b/src/minecraft/dark/core/network/fluid/NetworkFluidContainers.java @@ -55,7 +55,7 @@ public class NetworkFluidContainers extends NetworkFluidTiles } if (this.combinedStorage().getLiquid() != null && this.getNetworkMemebers().size() > 0) { - this.cleanUpConductors(); + this.cleanUpMembers(); int lowestY = 255; int highestY = 0; @@ -159,7 +159,7 @@ public class NetworkFluidContainers extends NetworkFluidTiles newNetwork.getNetworkMemebers().addAll(this.getNetworkMemebers()); newNetwork.getNetworkMemebers().addAll(network.getNetworkMemebers()); - newNetwork.cleanUpConductors(); + newNetwork.cleanUpMembers(); newNetwork.balanceColletiveTank(true); } } diff --git a/src/minecraft/dark/core/network/fluid/NetworkFluidTiles.java b/src/minecraft/dark/core/network/fluid/NetworkFluidTiles.java index 78812fbb..7019f28d 100644 --- a/src/minecraft/dark/core/network/fluid/NetworkFluidTiles.java +++ b/src/minecraft/dark/core/network/fluid/NetworkFluidTiles.java @@ -246,7 +246,7 @@ public class NetworkFluidTiles extends NetworkTileEntities } } - newNetwork.cleanUpConductors(); + newNetwork.cleanUpMembers(); newNetwork.balanceColletiveTank(true); } } @@ -293,12 +293,12 @@ public class NetworkFluidTiles extends NetworkTileEntities newNetwork.getNetworkMemebers().addAll(this.getNetworkMemebers()); newNetwork.getNetworkMemebers().addAll(network.getNetworkMemebers()); - newNetwork.cleanUpConductors(); + newNetwork.cleanUpMembers(); newNetwork.balanceColletiveTank(true); } @Override - public void cleanUpConductors() + public void cleanUpMembers() { if (!loadedLiquids) { diff --git a/src/minecraft/dark/core/network/fluid/NetworkPipes.java b/src/minecraft/dark/core/network/fluid/NetworkPipes.java index 25d963ef..69e2803e 100644 --- a/src/minecraft/dark/core/network/fluid/NetworkPipes.java +++ b/src/minecraft/dark/core/network/fluid/NetworkPipes.java @@ -349,7 +349,7 @@ public class NetworkPipes extends NetworkFluidTiles */ public void onPresureChange() { - this.cleanUpConductors(); + this.cleanUpMembers(); for (int i = 0; i < networkMember.size(); i++) { @@ -359,7 +359,7 @@ public class NetworkPipes extends NetworkFluidTiles if (part.getMaxPressure(ForgeDirection.UNKNOWN) < this.pressureProduced && part.onOverPressure(true)) { this.networkMember.remove(part); - this.cleanUpConductors(); + this.cleanUpMembers(); } } @@ -373,7 +373,7 @@ public class NetworkPipes extends NetworkFluidTiles newNetwork.getNetworkMemebers().addAll(this.getNetworkMemebers()); newNetwork.getNetworkMemebers().addAll(network.getNetworkMemebers()); - newNetwork.cleanUpConductors(); + newNetwork.cleanUpMembers(); newNetwork.balanceColletiveTank(true); } diff --git a/src/minecraft/dark/fluid/common/machines/BlockTank.java b/src/minecraft/dark/fluid/common/machines/BlockTank.java index 83dfe391..3ea31d9c 100644 --- a/src/minecraft/dark/fluid/common/machines/BlockTank.java +++ b/src/minecraft/dark/fluid/common/machines/BlockTank.java @@ -1,6 +1,5 @@ package dark.fluid.common.machines; - import java.util.List; import net.minecraft.block.material.Material; @@ -146,27 +145,6 @@ public class BlockTank extends BlockAdvanced return new TileEntityTank(); } - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) - { - int meta = world.getBlockMetadata(x, y, z); - - return new ItemStack(this, 1, meta); - - } - - @Override - public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List) - { - for (int i = 0; i < 16; i++) - { - if (FluidRestrictionHandler.hasRestrictedStack(i)) - { - par3List.add(new ItemStack(par1, 1, i)); - } - } - } - @Override public void onBlockAdded(World world, int x, int y, int z) { @@ -190,4 +168,43 @@ public class BlockTank extends BlockAdvanced ((INetworkPart) tileEntity).updateNetworkConnections(); } } + + @Override + public boolean hasComparatorInputOverride() + { + return true; + } + + @Override + public int getComparatorInputOverride(World world, int x, int y, int z, int par5) + { + TileEntityTank tileEntity = (TileEntityTank) world.getBlockTileEntity(x, y, z); + if (tileEntity != null) + { + return tileEntity.getRedstoneLevel(); + } + return 0; + } + + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) + { + int meta = world.getBlockMetadata(x, y, z); + + return new ItemStack(this, 1, meta); + + } + + @Override + public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List) + { + for (int i = 0; i < 16; i++) + { + if (FluidRestrictionHandler.hasRestrictedStack(i)) + { + par3List.add(new ItemStack(par1, 1, i)); + } + } + } + } diff --git a/src/minecraft/dark/fluid/common/machines/TileEntityTank.java b/src/minecraft/dark/fluid/common/machines/TileEntityTank.java index dd552ad4..34b968d0 100644 --- a/src/minecraft/dark/fluid/common/machines/TileEntityTank.java +++ b/src/minecraft/dark/fluid/common/machines/TileEntityTank.java @@ -6,6 +6,7 @@ import net.minecraft.network.INetworkManager; import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.Packet250CustomPayload; import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityComparator; import net.minecraft.util.AxisAlignedBB; import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.liquids.ILiquidTank; @@ -26,7 +27,6 @@ import cpw.mods.fml.relauncher.SideOnly; import dark.core.api.ColorCode; import dark.core.api.IColorCoded; import dark.core.api.IToolReadOut; -import dark.core.api.IToolReadOut.EnumTools; import dark.core.hydraulic.helpers.FluidRestrictionHandler; import dark.core.network.fluid.NetworkFluidContainers; import dark.core.network.fluid.NetworkFluidTiles; @@ -107,9 +107,7 @@ public class TileEntityTank extends TileEntityFluidDevice implements ITankContai return PacketManager.getPacket(FluidMech.CHANNEL, this, 0, stack.itemID, stack.amount, stack.itemMeta, 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 - */ + /** gets the current color mark of the pipe */ @Override public ColorCode getColor() { @@ -120,9 +118,7 @@ public class TileEntityTank extends TileEntityFluidDevice implements ITankContai return ColorCode.get(worldObj.getBlockMetadata(xCoord, yCoord, zCoord)); } - /** - * sets the current color mark of the pipe - */ + /** sets the current color mark of the pipe */ @Override public void setColor(Object cc) { @@ -186,19 +182,17 @@ public class TileEntityTank extends TileEntityFluidDevice implements ITankContai @Override public ILiquidTank getTank(ForgeDirection direction, LiquidStack type) { - if (FluidRestrictionHandler.isValidLiquid(this.getColor(),type)) + if (FluidRestrictionHandler.isValidLiquid(this.getColor(), type)) { return ((NetworkFluidContainers) this.getTileNetwork()).combinedStorage(); } return null; } - /** - * Checks to make sure the connection is valid to the tileEntity + /** Checks to make sure the connection is valid to the tileEntity * * @param tileEntity - the tileEntity being checked - * @param side - side the connection is too - */ + * @param side - side the connection is too */ public void validateConnectionSide(TileEntity tileEntity, ForgeDirection side) { if (!this.worldObj.isRemote) @@ -215,6 +209,10 @@ public class TileEntityTank extends TileEntityFluidDevice implements ITankContai connectedBlocks[side.ordinal()] = tileEntity; } } + if(tileEntity instanceof TileEntityComparator) + { + this.worldObj.markBlockForUpdate(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord); + } } } } @@ -234,9 +232,7 @@ public class TileEntityTank extends TileEntityFluidDevice implements ITankContai this.validateConnectionSide(this.worldObj.getBlockTileEntity(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ), dir); } - /** - * Only send packet updates if visuallyConnected changed. - */ + /** Only send packet updates if visuallyConnected changed. */ if (!Arrays.areEqual(previousConnections, this.renderConnection)) { this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); @@ -327,4 +323,20 @@ public class TileEntityTank extends TileEntityFluidDevice implements ITankContai } this.tank.setLiquid(stack); } + + public int getRedstoneLevel() + { + if (this.getTileNetwork() != null && this.getTileNetwork() instanceof NetworkFluidTiles) + { + ILiquidTank tank = ((NetworkFluidTiles) this.getTileNetwork()).combinedStorage(); + if (tank != null && tank.getLiquid() != null) + { + int max = tank.getCapacity(); + int current = tank.getLiquid().amount; + double percent = current / max; + return ((int) (15 * percent)); + } + } + return 0; + } }