cleanup + possible bug fixes

This commit is contained in:
Rseifert 2013-03-31 03:12:41 -04:00
parent 557d3f1ea8
commit 5af51d85dc
8 changed files with 44 additions and 45 deletions

View file

@ -82,10 +82,6 @@ public class BlockPumpMachine extends BlockAdvanced
TileEntity ent = world.getBlockTileEntity(x, y, z); TileEntity ent = world.getBlockTileEntity(x, y, z);
world.setBlockMetadataWithNotify(x, y, z, angle + MetaGroup.getGroupStartMeta(MetaGroup.getGrouping(meta)), 3); world.setBlockMetadataWithNotify(x, y, z, angle + MetaGroup.getGroupStartMeta(MetaGroup.getGrouping(meta)), 3);
if (ent instanceof TileEntityAdvanced)
{
((TileEntityAdvanced) world.getBlockTileEntity(x, y, z)).initiate();
}
world.notifyBlocksOfNeighborChange(x, y, z, this.blockID); world.notifyBlocksOfNeighborChange(x, y, z, this.blockID);
if (p instanceof EntityPlayer) if (p instanceof EntityPlayer)
@ -132,13 +128,15 @@ public class BlockPumpMachine extends BlockAdvanced
if (meta == (g * 4) + 3) if (meta == (g * 4) + 3)
{ {
par1World.setBlockMetadataWithNotify(x, y, z, (g * 4), 3); par1World.setBlockMetadataWithNotify(x, y, z, (g * 4), 3);
return true;
} }
else else
{ {
par1World.setBlockMetadataWithNotify(x, y, z, meta + 1, 3); par1World.setBlockMetadataWithNotify(x, y, z, meta + 1, 3);
}
if (ent instanceof TileEntityMinorPump)
{
((TileEntityMinorPump) ent).getConnections();
}
return true; return true;
} }
// return false;
}
} }

View file

@ -53,6 +53,12 @@ public class TileEntityMinorPump extends TileEntityElectricityRunnable implement
} }
} }
@Override
public void initiate()
{
this.getConnections();
}
@Override @Override
public void updateEntity() public void updateEntity()
{ {
@ -65,11 +71,13 @@ public class TileEntityMinorPump extends TileEntityElectricityRunnable implement
if (this.canPump(xCoord, yCoord - 1, zCoord) && this.wattsReceived >= this.WATTS_PER_TICK) if (this.canPump(xCoord, yCoord - 1, zCoord) && this.wattsReceived >= this.WATTS_PER_TICK)
{ {
wattsReceived -= this.WATTS_PER_TICK; wattsReceived -= this.WATTS_PER_TICK;
if (percentPumped < 10)
if (percentPumped++ >= 10) {
percentPumped++;
}
else if (percentPumped >= 10 && this.drainBlock(new Vector3(xCoord, yCoord - 1, zCoord)))
{ {
percentPumped = 0; percentPumped = 0;
this.drainBlock(new Vector3(xCoord, yCoord - 1, zCoord));
} }
/* DO ANIMATION CHANGE */ /* DO ANIMATION CHANGE */
@ -81,8 +89,9 @@ public class TileEntityMinorPump extends TileEntityElectricityRunnable implement
} }
if (this.ticks % 10 == 0) if (this.ticks % 10 == 0)
{ {
Packet packet = PacketManager.getPacket(FluidMech.CHANNEL, this, color.ordinal(), this.wattsReceived); // Packet packet = PacketManager.getPacket(FluidMech.CHANNEL, this, color.ordinal(),
PacketManager.sendPacketToClients(packet, worldObj, new Vector3(this), 60); // this.wattsReceived);
// PacketManager.sendPacketToClients(packet, worldObj, new Vector3(this), 60);
} }
} }
@ -181,7 +190,7 @@ public class TileEntityMinorPump extends TileEntityElectricityRunnable implement
@Override @Override
public String getMeterReading(EntityPlayer user, ForgeDirection side) public String getMeterReading(EntityPlayer user, ForgeDirection side)
{ {
return this.wattsReceived + "/" + this.WATTS_PER_TICK + "W " + this.percentPumped + "% DONE"; return String.format("%.2f/%.2f %f Done", this.wattsReceived,this.WATTS_PER_TICK,this.percentPumped);
} }
@Override @Override

View file

@ -98,16 +98,6 @@ public class TileEntityTank extends TileEntityFluidStorage implements IPacketRec
} }
@Override
public int fill(ForgeDirection from, LiquidStack resource, boolean doFill)
{
if (resource == null || (this.getColor() != ColorCode.NONE && !getColor().isValidLiquid(resource)))
{
return 0;
}
return this.fill(0, resource, doFill);
}
@Override @Override
public int fill(int tankIndex, LiquidStack resource, boolean doFill) public int fill(int tankIndex, LiquidStack resource, boolean doFill)
{ {
@ -116,7 +106,7 @@ public class TileEntityTank extends TileEntityFluidStorage implements IPacketRec
TileEntity tank = worldObj.getBlockTileEntity(xCoord, yCoord + 1, zCoord); TileEntity tank = worldObj.getBlockTileEntity(xCoord, yCoord + 1, zCoord);
if (tank instanceof TileEntityTank) if (tank instanceof TileEntityTank)
{ {
return ((TileEntityTank) tank).fill(0, resource, doFill); return ((TileEntityTank) tank).fill(tankIndex, resource, doFill);
} }
} }
return super.fill(tankIndex, resource, doFill); return super.fill(tankIndex, resource, doFill);
@ -125,7 +115,7 @@ public class TileEntityTank extends TileEntityFluidStorage implements IPacketRec
@Override @Override
public LiquidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) public LiquidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
{ {
if (from != ForgeDirection.UP && from != ForgeDirection.DOWN) if (from != ForgeDirection.DOWN)
{ {
return super.drain(from, maxDrain, doDrain); return super.drain(from, maxDrain, doDrain);
} }
@ -264,6 +254,6 @@ public class TileEntityTank extends TileEntityFluidStorage implements IPacketRec
@Override @Override
public int getTankSize() public int getTankSize()
{ {
return LiquidContainerRegistry.BUCKET_VOLUME * 4; return (LiquidContainerRegistry.BUCKET_VOLUME * 4);
} }
} }

View file

@ -7,6 +7,7 @@ import hydraulic.api.IPipeConnection;
import hydraulic.api.IReadOut; import hydraulic.api.IReadOut;
import hydraulic.fluidnetwork.HydraulicNetwork; import hydraulic.fluidnetwork.HydraulicNetwork;
import hydraulic.fluidnetwork.IFluidNetworkPart; import hydraulic.fluidnetwork.IFluidNetworkPart;
import hydraulic.helpers.FluidHelper;
import java.util.Random; import java.util.Random;
@ -337,7 +338,7 @@ public class TileEntityPipe extends TileEntityAdvanced implements ITankContainer
@Override @Override
public int getMaxFlowRate(LiquidStack stack, ForgeDirection side) public int getMaxFlowRate(LiquidStack stack, ForgeDirection side)
{ {
return LiquidContainerRegistry.BUCKET_VOLUME * 2; return FluidHelper.getDefaultFlowRate(stack) * 2;
} }
@Override @Override

View file

@ -5,6 +5,8 @@ import hydraulic.helpers.FluidHelper;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.minecraft.block.Block;
import net.minecraftforge.liquids.LiquidContainerRegistry;
import net.minecraftforge.liquids.LiquidDictionary; import net.minecraftforge.liquids.LiquidDictionary;
import net.minecraftforge.liquids.LiquidStack; import net.minecraftforge.liquids.LiquidStack;
@ -66,11 +68,11 @@ public enum ColorCode
{ {
return false; return false;
} }
else if (this == BLUE && stack.isLiquidEqual(LiquidDictionary.getCanonicalLiquid("Water"))) else if (this == BLUE && stack.isLiquidEqual(new LiquidStack(Block.waterStill, LiquidContainerRegistry.BUCKET_VOLUME)))
{ {
return true; return true;
} }
else if (this == RED && stack.isLiquidEqual(LiquidDictionary.getCanonicalLiquid("Lava"))) else if (this == RED && stack.isLiquidEqual(new LiquidStack(Block.lavaStill, LiquidContainerRegistry.BUCKET_VOLUME)))
{ {
return true; return true;
} }

View file

@ -317,17 +317,17 @@ public class HydraulicNetwork
if (primaryFill != null) if (primaryFill != null)
{ {
used = primaryFill.fill(fillDir, stack, doFill); used = primaryFill.fill(fillDir, stack, doFill);
// System.out.println("Primary Target " + used); System.out.println("Primary Target " + used + doFill);
} }
else if (secondayFill != null) else if (secondayFill != null)
{ {
used = secondayFill.fill(fillDir, stack, doFill); used = secondayFill.fill(fillDir, stack, doFill);
// System.out.println("Seconday Target " + used); System.out.println("Seconday Target " + used + doFill);
} }
else if (this.combinedStorage.getLiquid() == null || this.combinedStorage.getLiquid().amount < this.combinedStorage.getCapacity()) else if (this.combinedStorage.getLiquid() == null || this.combinedStorage.getLiquid().amount < this.combinedStorage.getCapacity())
{ {
used = this.combinedStorage.fill(stack, doFill); used = this.combinedStorage.fill(stack, doFill);
// System.out.println("Network Target filled for " + used); System.out.println("Network Target filled for " + used + doFill);
filledMain = true; filledMain = true;
} }
/* IF THE COMBINED STORAGE OF THE PIPES HAS LIQUID MOVE IT FIRST */ /* IF THE COMBINED STORAGE OF THE PIPES HAS LIQUID MOVE IT FIRST */
@ -346,8 +346,7 @@ public class HydraulicNetwork
used = Math.min(used, Math.max(used - this.combinedStorage.getLiquid().amount, 0)); used = Math.min(used, Math.max(used - this.combinedStorage.getLiquid().amount, 0));
drainStack = this.combinedStorage.drain(pUsed - used, doFill); drainStack = this.combinedStorage.drain(pUsed - used, doFill);
} }
// System.out.println("Pulling " + drainStack.amount + " from combined leaving " + System.out.println("Pulling " + (drainStack != null ? drainStack.amount : 0) + " from combined leaving " + (this.combinedStorage.getLiquid() != null ? this.combinedStorage.getLiquid().amount : 0));
// this.combinedStorage.getLiquid().amount);
} }
if (prevCombined != null && this.combinedStorage.getLiquid() != null && prevCombined.amount != this.combinedStorage.getLiquid().amount) if (prevCombined != null && this.combinedStorage.getLiquid() != null && prevCombined.amount != this.combinedStorage.getLiquid().amount)

View file

@ -19,7 +19,7 @@ public class FluidHelper
* The default built in flow rate of the liquid threw the pipes. Will correct this later to use * The default built in flow rate of the liquid threw the pipes. Will correct this later to use
* a visc value instead of flow value so that the size of the pipe can play a factor in flow * a visc value instead of flow value so that the size of the pipe can play a factor in flow
*/ */
public int getDefaultFlowRate(LiquidStack stack) public static int getDefaultFlowRate(LiquidStack stack)
{ {
if (stack != null) if (stack != null)
{ {

View file

@ -53,9 +53,13 @@ public abstract class TileEntityFluidStorage extends TileEntityFluidDevice imple
@Override @Override
public int fill(ForgeDirection from, LiquidStack resource, boolean doFill) public int fill(ForgeDirection from, LiquidStack resource, boolean doFill)
{
if (fillableSides.contains(from))
{ {
return this.fill(0, resource, doFill); return this.fill(0, resource, doFill);
} }
return 0;
}
@Override @Override
public int fill(int tankIndex, LiquidStack resource, boolean doFill) public int fill(int tankIndex, LiquidStack resource, boolean doFill)
@ -64,7 +68,7 @@ public abstract class TileEntityFluidStorage extends TileEntityFluidDevice imple
{ {
return 0; return 0;
} }
else if (this.getColor() != ColorCode.NONE && !getColor().isValidLiquid(resource)) else if (!getColor().isValidLiquid(resource))
{ {
return 0; return 0;
} }
@ -97,11 +101,7 @@ public abstract class TileEntityFluidStorage extends TileEntityFluidDevice imple
{ {
stack = FluidHelper.getStack(stack, maxDrain); stack = FluidHelper.getStack(stack, maxDrain);
} }
if (doDrain) return this.tank.drain(maxDrain, doDrain);
{
this.tank.drain(maxDrain, doDrain);
}
return stack;
} }
@Override @Override