Fixed grate not filling world with gravity
This commit is contained in:
parent
59e5c5cf10
commit
e03aec6950
3 changed files with 21 additions and 26 deletions
|
@ -60,24 +60,6 @@ public class TileGrate extends TilePressureNode implements IRotatable
|
||||||
iconSide = iconRegister.registerIcon(Reference.PREFIX + "grate");
|
iconSide = iconRegister.registerIcon(Reference.PREFIX + "grate");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canUpdate()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ForgeDirection getDirection()
|
|
||||||
{
|
|
||||||
return ForgeDirection.getOrientation(getBlockMetadata());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setDirection(ForgeDirection direction)
|
|
||||||
{
|
|
||||||
this.worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, direction.ordinal(), 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FluidTankInfo[] getTankInfo(ForgeDirection from)
|
public FluidTankInfo[] getTankInfo(ForgeDirection from)
|
||||||
{
|
{
|
||||||
|
@ -96,11 +78,18 @@ public class TileGrate extends TilePressureNode implements IRotatable
|
||||||
return getDirection() != from;
|
return getDirection() != from;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateEntity()
|
||||||
|
{
|
||||||
|
super.updateEntity();
|
||||||
|
|
||||||
|
System.out.println("" + getPressureTank().getFluidAmount());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
|
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
|
||||||
{
|
{
|
||||||
int filled = getPressureTank().fill(resource, doFill);
|
int filled = getPressureTank().fill(resource, doFill);
|
||||||
System.out.println("FILL");
|
|
||||||
|
|
||||||
if (getPressureTank().getFluidAmount() > 0)
|
if (getPressureTank().getFluidAmount() > 0)
|
||||||
{
|
{
|
||||||
|
@ -110,10 +99,11 @@ public class TileGrate extends TilePressureNode implements IRotatable
|
||||||
gratePath.startFill(new Vector3(this), getPressureTank().getFluid().getFluid().getID());
|
gratePath.startFill(new Vector3(this), getPressureTank().getFluid().getFluid().getID());
|
||||||
}
|
}
|
||||||
|
|
||||||
return getPressureTank().drain(gratePath.tryFill(getPressureTank().getFluidAmount(), 2000), true).amount;
|
int filledInWorld = gratePath.tryFill(getPressureTank().getFluidAmount(), 2000);
|
||||||
|
getPressureTank().drain(filledInWorld, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return filled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -127,6 +117,8 @@ public class TileGrate extends TilePressureNode implements IRotatable
|
||||||
@Override
|
@Override
|
||||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
|
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
|
||||||
{
|
{
|
||||||
|
System.out.println("DRAIN");
|
||||||
|
|
||||||
if (maxDrain > 0)
|
if (maxDrain > 0)
|
||||||
{
|
{
|
||||||
if (gratePath == null)
|
if (gratePath == null)
|
||||||
|
|
|
@ -84,6 +84,7 @@ public abstract class TilePressureNode extends TileFluidNode implements IPressur
|
||||||
{
|
{
|
||||||
this.tank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME);
|
this.tank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.tank;
|
return this.tank;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,14 +100,16 @@ public class FluidPressureNode extends Node<IPressureNodeProvider, TickingGrid,
|
||||||
|
|
||||||
if (obj instanceof FluidPressureNode)
|
if (obj instanceof FluidPressureNode)
|
||||||
{
|
{
|
||||||
FluidPressureNode otherPipe = (FluidPressureNode) obj;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Move fluid from higher pressure to lower. In this case, move from tankA to
|
* Move fluid from higher pressure to lower. In this case, move from tankA to
|
||||||
* tankB.
|
* tankB.
|
||||||
*/
|
*/
|
||||||
|
FluidPressureNode otherNode = (FluidPressureNode) obj;
|
||||||
|
|
||||||
|
// A is the pressure in the current node while B is the pressure in the node we
|
||||||
|
// are iterating through.
|
||||||
int pressureA = getPressure(dir);
|
int pressureA = getPressure(dir);
|
||||||
int pressureB = otherPipe.getPressure(dir.getOpposite());
|
int pressureB = otherNode.getPressure(dir.getOpposite());
|
||||||
|
|
||||||
if (pressureA >= pressureB)
|
if (pressureA >= pressureB)
|
||||||
{
|
{
|
||||||
|
@ -123,7 +125,7 @@ public class FluidPressureNode extends Node<IPressureNodeProvider, TickingGrid,
|
||||||
|
|
||||||
if (amountA > 0)
|
if (amountA > 0)
|
||||||
{
|
{
|
||||||
FluidTank tankB = otherPipe.parent.getPressureTank();
|
FluidTank tankB = otherNode.parent.getPressureTank();
|
||||||
|
|
||||||
if (tankB != null)
|
if (tankB != null)
|
||||||
{
|
{
|
||||||
|
@ -137,7 +139,7 @@ public class FluidPressureNode extends Node<IPressureNodeProvider, TickingGrid,
|
||||||
FluidStack drainStack = parent.drain(dir.getOpposite(), quantity, false);
|
FluidStack drainStack = parent.drain(dir.getOpposite(), quantity, false);
|
||||||
|
|
||||||
if (drainStack != null && drainStack.amount > 0)
|
if (drainStack != null && drainStack.amount > 0)
|
||||||
parent.drain(dir.getOpposite(), otherPipe.parent.fill(dir, drainStack, true), true);
|
parent.drain(dir.getOpposite(), otherNode.parent.fill(dir, drainStack, true), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue