Fixed an issue with pipes filling
This commit is contained in:
parent
45367e6e51
commit
d7a25fae49
3 changed files with 16 additions and 33 deletions
|
@ -65,14 +65,14 @@ public class NetworkFluidTiles extends NetworkTileEntities
|
|||
return this.sharedTankInfo;
|
||||
}
|
||||
|
||||
public int fillNetworkTank(World world, FluidStack stack, boolean doFill)
|
||||
public int fillNetworkTank(TileEntity source, FluidStack stack, boolean doFill)
|
||||
{
|
||||
if (!this.loadedLiquids)
|
||||
{
|
||||
this.load();
|
||||
this.loadedLiquids = true;
|
||||
}
|
||||
if (!world.isRemote && this.getNetworkTank() != null && stack != null)
|
||||
if (!source.worldObj.isRemote && this.getNetworkTank() != null && stack != null)
|
||||
{
|
||||
int p = this.getNetworkTank().getFluidAmount();
|
||||
int r = this.getNetworkTank().fill(stack, doFill);
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.EnumSet;
|
|||
import java.util.Map.Entry;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
@ -37,6 +38,17 @@ public class NetworkPipes extends NetworkFluidTiles
|
|||
super(parts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fillNetworkTank(TileEntity source, FluidStack stack, boolean doFill)
|
||||
{
|
||||
int netFill = this.addFluidToNetwork(source, stack, doFill);
|
||||
if (netFill > 0)
|
||||
{
|
||||
return netFill;
|
||||
}
|
||||
return super.fillNetworkTank(source, stack, doFill);
|
||||
}
|
||||
|
||||
/** Adds FLuid to this network from one of the connected Pipes
|
||||
*
|
||||
* @param source - Were this liquid came from
|
||||
|
@ -101,41 +113,12 @@ public class NetworkPipes extends NetworkFluidTiles
|
|||
break;
|
||||
}
|
||||
}// End of tank finder
|
||||
|
||||
boolean filledMain = false;
|
||||
if (tankToFill != null)
|
||||
{
|
||||
//TODO set up a list of tanks to actually fill rather than one at a time
|
||||
used = tankToFill.fill(fillDir, stack, doFill);
|
||||
// System.out.println("Seconday Target " + used + doFill);
|
||||
}
|
||||
else if (allowStore)
|
||||
{
|
||||
used = this.fillNetworkTank(source.worldObj, stack, doFill);
|
||||
// System.out.println("Network Target filled for " + used + doFill);
|
||||
filledMain = true;
|
||||
}
|
||||
|
||||
/* IF THE COMBINED STORAGE OF THE PIPES HAS LIQUID MOVE IT FIRST */
|
||||
if (!filledMain && used > 0 && this.getNetworkTank().getFluid() != null && this.getNetworkTank().getFluid().amount > 0)
|
||||
{
|
||||
|
||||
FluidStack drainStack = new FluidStack(0, 0);
|
||||
if (this.getNetworkTank().getFluid().amount >= used)
|
||||
{
|
||||
drainStack = this.drainNetworkTank(source.worldObj, used, doFill);
|
||||
used = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
int pUsed = used;
|
||||
used = Math.min(used, Math.max(used - this.getNetworkTank().getFluid().amount, 0));
|
||||
drainStack = this.drainNetworkTank(source.worldObj, pUsed - used, doFill);
|
||||
}
|
||||
// System.out.println("Pulling " + (drainStack != null ? drainStack.amount : 0) +
|
||||
// " from combined leaving " + (this.combinedStorage.getLiquid() != null ?
|
||||
// this.combinedStorage.getLiquid().amount : 0));
|
||||
|
||||
}
|
||||
}
|
||||
this.processingRequest = false;
|
||||
return used;
|
||||
|
|
|
@ -117,7 +117,7 @@ public abstract class TileEntityFluidNetworkTile extends TileEntityFluidDevice i
|
|||
{
|
||||
if (this.getTileNetwork() != null && resource != null)
|
||||
{
|
||||
return this.getTileNetwork().fillNetworkTank(this.worldObj, resource, doFill);
|
||||
return this.getTileNetwork().fillNetworkTank(this, resource, doFill);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue