Fixed #409 - Gutter bucket fill and drain
This commit is contained in:
parent
dd3e1cc8d4
commit
1e0492eb53
7 changed files with 57 additions and 43 deletions
|
@ -3,11 +3,8 @@ package resonantinduction.archaic.fluid.gutter;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -18,11 +15,11 @@ import net.minecraftforge.client.model.AdvancedModelLoader;
|
|||
import net.minecraftforge.client.model.IModelCustom;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
|
@ -205,7 +202,36 @@ public class TileGutter extends TilePressureNode
|
|||
|
||||
if (!world().isRemote)
|
||||
{
|
||||
return FluidUtility.playerActivatedFluidItem(world(), x(), y(), z(), player, side);
|
||||
ArrayList<IFluidTank> tanks = new ArrayList<IFluidTank>();
|
||||
|
||||
synchronized (node.getGrid().getNodes())
|
||||
{
|
||||
for (Object check : node.getGrid().getNodes())
|
||||
{
|
||||
if (check instanceof PressureNode)
|
||||
{
|
||||
tanks.add(((PressureNode) check).parent.getPressureTank());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (FluidUtility.playerActivatedFluidItem(tanks, player, side))
|
||||
{
|
||||
synchronized (node.getGrid().getNodes())
|
||||
{
|
||||
for (Object check : node.getGrid().getNodes())
|
||||
{
|
||||
if (check instanceof PressureNode)
|
||||
{
|
||||
((PressureNode) check).parent.onFluidChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -241,39 +267,12 @@ public class TileGutter extends TilePressureNode
|
|||
{
|
||||
if (!resource.getFluid().isGaseous())
|
||||
{
|
||||
int totalFill = 0;
|
||||
int trials = 0;
|
||||
FluidStack fillStack = resource.copy();
|
||||
|
||||
// Handle overflow.
|
||||
do
|
||||
{
|
||||
int filled = super.fill(from, fillStack, doFill);
|
||||
totalFill += filled;
|
||||
int remain = fillStack.amount - filled;
|
||||
fillStack.amount -= filled;
|
||||
node.update(1 / 20f);
|
||||
trials++;
|
||||
}
|
||||
while (fillStack.amount > totalFill && trials < 20);
|
||||
|
||||
return totalFill;
|
||||
return super.fill(from, resource, doFill);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTank getInternalTank()
|
||||
{
|
||||
if (tank == null)
|
||||
{
|
||||
tank = new FluidTank(2 * FluidContainerRegistry.BUCKET_VOLUME);
|
||||
}
|
||||
|
||||
return tank;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
|
|
|
@ -271,4 +271,9 @@ public class PartPipe extends PartFramedNode<EnumPipeMaterial, PressureNode, IPr
|
|||
node.maxFlowRate = getMaterial().maxFlowRate;
|
||||
node.maxPressure = getMaterial().maxPressure;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFluidChanged()
|
||||
{
|
||||
}
|
||||
}
|
|
@ -163,4 +163,10 @@ public class TilePump extends TileMechanical implements IPressureNodeProvider, I
|
|||
|
||||
return super.getNode(nodeType, from);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFluidChanged()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,16 +69,16 @@ public abstract class TileFluidNode extends TileBase implements IPacketReceiverW
|
|||
{
|
||||
if (id == PACKET_DESCRIPTION)
|
||||
{
|
||||
this.colorID = data.readInt();
|
||||
this.renderSides = data.readByte();
|
||||
this.tank = new FluidTank(data.readInt());
|
||||
this.getInternalTank().readFromNBT(PacketHandler.readNBTTagCompound(data));
|
||||
colorID = data.readInt();
|
||||
renderSides = data.readByte();
|
||||
tank = new FluidTank(data.readInt());
|
||||
getInternalTank().readFromNBT(PacketHandler.readNBTTagCompound(data));
|
||||
return true;
|
||||
}
|
||||
else if (id == PACKET_RENDER)
|
||||
{
|
||||
this.colorID = data.readInt();
|
||||
this.renderSides = data.readByte();
|
||||
colorID = data.readInt();
|
||||
renderSides = data.readByte();
|
||||
return true;
|
||||
}
|
||||
else if (id == PACKET_TANK)
|
||||
|
|
|
@ -23,7 +23,6 @@ public abstract class TilePressureNode extends TileFluidNode implements IPressur
|
|||
public TilePressureNode(Material material)
|
||||
{
|
||||
super(material);
|
||||
getInternalTank().setCapacity(FluidContainerRegistry.BUCKET_VOLUME);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,5 +6,7 @@ import resonantinduction.core.grid.INodeProvider;
|
|||
|
||||
public interface IPressureNodeProvider extends INodeProvider, IFluidHandler
|
||||
{
|
||||
FluidTank getPressureTank();
|
||||
public FluidTank getPressureTank();
|
||||
|
||||
public void onFluidChanged();
|
||||
}
|
||||
|
|
|
@ -36,8 +36,11 @@ public class PressureNode extends Node<IPressureNodeProvider, TickingGrid, Objec
|
|||
@Override
|
||||
public void update(float deltaTime)
|
||||
{
|
||||
updatePressure();
|
||||
distribute();
|
||||
if (!world().isRemote)
|
||||
{
|
||||
updatePressure();
|
||||
distribute();
|
||||
}
|
||||
}
|
||||
|
||||
protected void updatePressure()
|
||||
|
|
Loading…
Reference in a new issue