This commit is contained in:
DarkGuardsman 2013-06-30 19:23:37 -04:00
parent 50c1f30793
commit 30fc0c0914
5 changed files with 74 additions and 45 deletions

View file

@ -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);
}
}

View file

@ -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)
{

View file

@ -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);
}

View file

@ -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));
}
}
}
}

View file

@ -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;
}
}