Fixed tank not working when only one block
This commit is contained in:
parent
20dcbce5c5
commit
0f977d5b8a
5 changed files with 29 additions and 25 deletions
|
@ -10,8 +10,9 @@ import net.minecraftforge.fluids.FluidStack;
|
|||
import net.minecraftforge.fluids.FluidTank;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import resonantinduction.api.fluid.IFluidNetwork;
|
||||
import resonantinduction.api.fluid.IFluidConnector;
|
||||
import resonantinduction.api.fluid.IFluidNetwork;
|
||||
import resonantinduction.mechanical.fluid.tank.TileTank;
|
||||
import universalelectricity.api.net.IConnector;
|
||||
import universalelectricity.core.net.ConnectionPathfinder;
|
||||
import universalelectricity.core.net.Network;
|
||||
|
@ -99,6 +100,7 @@ public abstract class FluidNetwork extends Network<IFluidNetwork, IFluidConnecto
|
|||
{
|
||||
this.rebuildHandler();
|
||||
}
|
||||
|
||||
return fill;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,12 +35,11 @@ public class BlockPipe extends BlockFluidNetwork
|
|||
|
||||
}
|
||||
|
||||
// Use Vanilla Couldron to fill it.
|
||||
@Deprecated
|
||||
@Override
|
||||
public void fillWithRain(World world, int x, int y, int z)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
if (meta == FluidContainerMaterial.WOOD.ordinal() || meta == FluidContainerMaterial.STONE.ordinal())
|
||||
{
|
||||
// TODO fill pipe since it will have an open top and can gather rain
|
||||
|
|
|
@ -22,17 +22,17 @@ public class PipeNetwork extends FluidNetwork
|
|||
@Override
|
||||
public void update()
|
||||
{
|
||||
System.out.println("PipeNetwork:" + this.toString());
|
||||
System.out.println("FluidVol: " + this.getTank().getFluidAmount());
|
||||
|
||||
super.update();
|
||||
|
||||
// Slight delay to allow visual effect to take place before draining the pipe's internal
|
||||
// tank
|
||||
if (this.ticks % 2 == 0 && this.getTank().getFluidAmount() > 0)
|
||||
/*
|
||||
* Slight delay to allow visual effect to take place before draining the pipe's internal
|
||||
* tank
|
||||
*/
|
||||
if (this.getTank().getFluidAmount() > 0)
|
||||
{
|
||||
FluidStack stack = this.getTank().getFluid().copy();
|
||||
int count = this.connectionMap.size();
|
||||
|
||||
for (Entry<IFluidHandler, EnumSet<ForgeDirection>> entry : this.connectionMap.entrySet())
|
||||
{
|
||||
int sideCount = entry.getValue().size();
|
||||
|
@ -46,7 +46,9 @@ public class PipeNetwork extends FluidNetwork
|
|||
{
|
||||
maxFill = ((IFluidPipe) entity).getMaxFlowRate();
|
||||
}
|
||||
|
||||
stack.amount -= entry.getKey().fill(dir, FluidUtility.getStack(stack, Math.min(volPerSide, maxFill)), true);
|
||||
|
||||
if (sideCount > 1)
|
||||
--sideCount;
|
||||
if (volPer <= 0)
|
||||
|
@ -57,6 +59,7 @@ public class PipeNetwork extends FluidNetwork
|
|||
if (stack == null || stack.amount <= 0)
|
||||
break;
|
||||
}
|
||||
|
||||
this.getTank().setFluid(stack);
|
||||
// TODO check for change before rebuilding
|
||||
this.rebuildHandler();
|
||||
|
@ -72,7 +75,7 @@ public class PipeNetwork extends FluidNetwork
|
|||
@Override
|
||||
public boolean continueUpdate()
|
||||
{
|
||||
return true;// this.getConnectors().size() > 0;
|
||||
return this.getConnectors().size() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,6 +15,18 @@ public class BlockFluidNetwork extends BlockRI
|
|||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World world, int x, int y, int z)
|
||||
{
|
||||
TileEntity tile = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tile instanceof TileFluidNetwork)
|
||||
{
|
||||
((TileFluidNetwork) tile).refresh();
|
||||
((TileFluidNetwork) tile).getNetwork().reconstruct();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, int par5)
|
||||
{
|
||||
|
|
|
@ -100,31 +100,19 @@ public abstract class TileFluidNetwork<N extends FluidNetwork> extends TileEntit
|
|||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
if (this.getNetwork() != null && resource != null)
|
||||
{
|
||||
return this.getNetwork().fill(this, from, resource, doFill);
|
||||
}
|
||||
return 0;
|
||||
return this.getNetwork().fill(this, from, resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
if (this.getNetwork() != null && resource != null)
|
||||
{
|
||||
return this.getNetwork().drain(this, from, resource, doDrain);
|
||||
}
|
||||
return null;
|
||||
return this.getNetwork().drain(this, from, resource, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
if (this.getNetwork() != null)
|
||||
{
|
||||
return this.getNetwork().drain(this, from, maxDrain, doDrain);
|
||||
}
|
||||
return null;
|
||||
return this.getNetwork().drain(this, from, maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue