This commit is contained in:
DarkGuardsman 2014-01-19 01:47:31 -05:00
commit ff0dbfe5ad
5 changed files with 29 additions and 25 deletions

View file

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

View file

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

View file

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

View file

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

View file

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