Fixed fluid system tentatively
This commit is contained in:
parent
b94e8aaf17
commit
33df875a9b
6 changed files with 109 additions and 69 deletions
|
@ -88,10 +88,10 @@ public class RenderGutter extends TileEntitySpecialRenderer implements ISimpleIt
|
||||||
FluidTank tank = ((TileGutter) tileEntity).getInternalTank();
|
FluidTank tank = ((TileGutter) tileEntity).getInternalTank();
|
||||||
double percentageFilled = (double) tank.getFluidAmount() / (double) tank.getCapacity();
|
double percentageFilled = (double) tank.getFluidAmount() / (double) tank.getCapacity();
|
||||||
|
|
||||||
double ySouthEast = FluidUtility.getAveragePercentageFilledForSides(percentageFilled, tileEntity.worldObj, new Vector3(tileEntity), ForgeDirection.SOUTH, ForgeDirection.EAST);
|
double ySouthEast = FluidUtility.getAveragePercentageFilledForSides(TileGutter.class, percentageFilled, tileEntity.worldObj, new Vector3(tileEntity), ForgeDirection.SOUTH, ForgeDirection.EAST);
|
||||||
double yNorthEast = FluidUtility.getAveragePercentageFilledForSides(percentageFilled, tileEntity.worldObj, new Vector3(tileEntity), ForgeDirection.NORTH, ForgeDirection.EAST);
|
double yNorthEast = FluidUtility.getAveragePercentageFilledForSides(TileGutter.class, percentageFilled, tileEntity.worldObj, new Vector3(tileEntity), ForgeDirection.NORTH, ForgeDirection.EAST);
|
||||||
double ySouthWest = FluidUtility.getAveragePercentageFilledForSides(percentageFilled, tileEntity.worldObj, new Vector3(tileEntity), ForgeDirection.SOUTH, ForgeDirection.WEST);
|
double ySouthWest = FluidUtility.getAveragePercentageFilledForSides(TileGutter.class, percentageFilled, tileEntity.worldObj, new Vector3(tileEntity), ForgeDirection.SOUTH, ForgeDirection.WEST);
|
||||||
double yNorthWest = FluidUtility.getAveragePercentageFilledForSides(percentageFilled, tileEntity.worldObj, new Vector3(tileEntity), ForgeDirection.NORTH, ForgeDirection.WEST);
|
double yNorthWest = FluidUtility.getAveragePercentageFilledForSides(TileGutter.class, percentageFilled, tileEntity.worldObj, new Vector3(tileEntity), ForgeDirection.NORTH, ForgeDirection.WEST);
|
||||||
|
|
||||||
FluidRenderUtility.renderFluidTesselation(tank, ySouthEast, yNorthEast, ySouthWest, yNorthWest);
|
FluidRenderUtility.renderFluidTesselation(tank, ySouthEast, yNorthEast, ySouthWest, yNorthWest);
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
|
|
|
@ -67,10 +67,10 @@ public class RenderTank extends TileEntitySpecialRenderer implements ISimpleItem
|
||||||
FluidTank tank = ((TileTank) tileEntity).getInternalTank();
|
FluidTank tank = ((TileTank) tileEntity).getInternalTank();
|
||||||
double percentageFilled = (double) tank.getFluidAmount() / (double) tank.getCapacity();
|
double percentageFilled = (double) tank.getFluidAmount() / (double) tank.getCapacity();
|
||||||
|
|
||||||
double ySouthEast = FluidUtility.getAveragePercentageFilledForSides(percentageFilled, tileEntity.worldObj, new Vector3(tileEntity), ForgeDirection.SOUTH, ForgeDirection.EAST);
|
double ySouthEast = FluidUtility.getAveragePercentageFilledForSides(TileTank.class, percentageFilled, tileEntity.worldObj, new Vector3(tileEntity), ForgeDirection.SOUTH, ForgeDirection.EAST);
|
||||||
double yNorthEast = FluidUtility.getAveragePercentageFilledForSides(percentageFilled, tileEntity.worldObj, new Vector3(tileEntity), ForgeDirection.NORTH, ForgeDirection.EAST);
|
double yNorthEast = FluidUtility.getAveragePercentageFilledForSides(TileTank.class, percentageFilled, tileEntity.worldObj, new Vector3(tileEntity), ForgeDirection.NORTH, ForgeDirection.EAST);
|
||||||
double ySouthWest = FluidUtility.getAveragePercentageFilledForSides(percentageFilled, tileEntity.worldObj, new Vector3(tileEntity), ForgeDirection.SOUTH, ForgeDirection.WEST);
|
double ySouthWest = FluidUtility.getAveragePercentageFilledForSides(TileTank.class, percentageFilled, tileEntity.worldObj, new Vector3(tileEntity), ForgeDirection.SOUTH, ForgeDirection.WEST);
|
||||||
double yNorthWest = FluidUtility.getAveragePercentageFilledForSides(percentageFilled, tileEntity.worldObj, new Vector3(tileEntity), ForgeDirection.NORTH, ForgeDirection.WEST);
|
double yNorthWest = FluidUtility.getAveragePercentageFilledForSides(TileTank.class, percentageFilled, tileEntity.worldObj, new Vector3(tileEntity), ForgeDirection.NORTH, ForgeDirection.WEST);
|
||||||
FluidRenderUtility.renderFluidTesselation(tank, ySouthEast, yNorthEast, ySouthWest, yNorthWest);
|
FluidRenderUtility.renderFluidTesselation(tank, ySouthEast, yNorthEast, ySouthWest, yNorthWest);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -49,6 +49,9 @@ public class PartPipe extends PartFramedNode<EnumPipeMaterial, PressureNode, IPr
|
||||||
synchronized (connections)
|
synchronized (connections)
|
||||||
{
|
{
|
||||||
connections.clear();
|
connections.clear();
|
||||||
|
|
||||||
|
if (world() != null)
|
||||||
|
{
|
||||||
byte previousConnections = getAllCurrentConnections();
|
byte previousConnections = getAllCurrentConnections();
|
||||||
currentConnections = 0;
|
currentConnections = 0;
|
||||||
|
|
||||||
|
@ -78,30 +81,32 @@ public class PartPipe extends PartFramedNode<EnumPipeMaterial, PressureNode, IPr
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Only send packet updates if visuallyConnected changed. */
|
/** Only send packet updates if visuallyConnected changed. */
|
||||||
if (previousConnections != currentConnections)
|
if (!world().isRemote && previousConnections != currentConnections)
|
||||||
{
|
{
|
||||||
sendConnectionUpdate();
|
sendConnectionUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canConnect(ForgeDirection from, Object source)
|
public boolean canConnect(ForgeDirection from, Object source)
|
||||||
{return
|
|
||||||
super.canConnect(from, source);
|
|
||||||
/*Object obj = tile instanceof TileMultipart ? ((TileMultipart) tile).partMap(ForgeDirection.UNKNOWN.ordinal()) : tile;
|
|
||||||
|
|
||||||
if (obj instanceof PartPipe)
|
|
||||||
{
|
{
|
||||||
if (this.getMaterial() == ((PartPipe) obj).getMaterial())
|
return super.canConnect(from, source);
|
||||||
{
|
/*
|
||||||
return getColor() == ((PartPipe) obj).getColor() || (getColor() == DEFAULT_COLOR || ((PartPipe) obj).getColor() == DEFAULT_COLOR);
|
* Object obj = tile instanceof TileMultipart ? ((TileMultipart)
|
||||||
}
|
* tile).partMap(ForgeDirection.UNKNOWN.ordinal()) : tile;
|
||||||
|
* if (obj instanceof PartPipe)
|
||||||
return false;
|
* {
|
||||||
}
|
* if (this.getMaterial() == ((PartPipe) obj).getMaterial())
|
||||||
|
* {
|
||||||
return tile instanceof IFluidHandler;*/
|
* return getColor() == ((PartPipe) obj).getColor() || (getColor() == DEFAULT_COLOR
|
||||||
|
* || ((PartPipe) obj).getColor() == DEFAULT_COLOR);
|
||||||
|
* }
|
||||||
|
* return false;
|
||||||
|
* }
|
||||||
|
* return tile instanceof IFluidHandler;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -232,12 +237,12 @@ public class PartPipe extends PartFramedNode<EnumPipeMaterial, PressureNode, IPr
|
||||||
@Override
|
@Override
|
||||||
public FluidTank getPressureTank()
|
public FluidTank getPressureTank()
|
||||||
{
|
{
|
||||||
if (this.tank == null)
|
if (tank == null)
|
||||||
{
|
{
|
||||||
this.tank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME);
|
tank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.tank;
|
return tank;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -16,7 +16,6 @@ import calclavia.lib.prefab.tile.IRotatable;
|
||||||
|
|
||||||
public class TilePump extends TileMechanical implements IPressureNodeProvider, IRotatable
|
public class TilePump extends TileMechanical implements IPressureNodeProvider, IRotatable
|
||||||
{
|
{
|
||||||
private final long maximumPower = 100000;
|
|
||||||
private final PressureNode pressureNode;
|
private final PressureNode pressureNode;
|
||||||
|
|
||||||
public TilePump()
|
public TilePump()
|
||||||
|
@ -30,19 +29,46 @@ public class TilePump extends TileMechanical implements IPressureNodeProvider, I
|
||||||
{
|
{
|
||||||
if (dir == getDirection())
|
if (dir == getDirection())
|
||||||
{
|
{
|
||||||
return (int) Math.max((((double) mechanicalNode.getPower() / (double) maximumPower) * 100), 2);
|
return (int) Math.max(Math.abs(mechanicalNode.getTorque() / 1000d), 2);
|
||||||
}
|
}
|
||||||
else if (dir == getDirection().getOpposite())
|
else if (dir == getDirection().getOpposite())
|
||||||
{
|
{
|
||||||
return (int) -Math.max((((double) mechanicalNode.getPower() / (double) maximumPower) * 100), 2);
|
return (int) -Math.max(Math.abs(mechanicalNode.getTorque() / 1000d), 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxFlowRate()
|
||||||
|
{
|
||||||
|
return (int) Math.abs(mechanicalNode.getAngularVelocity() * 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canConnect(ForgeDirection from, Object source)
|
||||||
|
{
|
||||||
|
return super.canConnect(from, source) && (from == getDirection() || from == getDirection().getOpposite());
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initiate()
|
||||||
|
{
|
||||||
|
pressureNode.reconstruct();
|
||||||
|
super.initiate();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void invalidate()
|
||||||
|
{
|
||||||
|
super.invalidate();
|
||||||
|
pressureNode.deconstruct();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateEntity()
|
public void updateEntity()
|
||||||
{
|
{
|
||||||
|
@ -55,10 +81,9 @@ public class TilePump extends TileMechanical implements IPressureNodeProvider, I
|
||||||
*/
|
*/
|
||||||
TileEntity tileIn = new Vector3(this).translate(getDirection().getOpposite()).getTileEntity(this.worldObj);
|
TileEntity tileIn = new Vector3(this).translate(getDirection().getOpposite()).getTileEntity(this.worldObj);
|
||||||
|
|
||||||
if (tileIn instanceof IFluidHandler && !(tileIn instanceof IPressureNodeProvider))
|
if (tileIn instanceof IFluidHandler)
|
||||||
{
|
{
|
||||||
int flowRate = (int) (((double) mechanicalNode.getPower() / (double) maximumPower) * 500);
|
FluidStack drain = ((IFluidHandler) tileIn).drain(getDirection(), pressureNode.getMaxFlowRate(), false);
|
||||||
FluidStack drain = ((IFluidHandler) tileIn).drain(getDirection(), flowRate, false);
|
|
||||||
|
|
||||||
if (drain != null)
|
if (drain != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -104,9 +104,12 @@ public class PressureNode extends Node<IPressureNodeProvider, TickingGrid, Objec
|
||||||
if (pressureA >= pressureB)
|
if (pressureA >= pressureB)
|
||||||
{
|
{
|
||||||
FluidTank tankA = parent.getPressureTank();
|
FluidTank tankA = parent.getPressureTank();
|
||||||
|
|
||||||
|
if (tankA != null)
|
||||||
|
{
|
||||||
FluidStack fluidA = tankA.getFluid();
|
FluidStack fluidA = tankA.getFluid();
|
||||||
|
|
||||||
if (tankA != null && fluidA != null)
|
if (fluidA != null)
|
||||||
{
|
{
|
||||||
int amountA = fluidA.amount;
|
int amountA = fluidA.amount;
|
||||||
|
|
||||||
|
@ -133,6 +136,7 @@ public class PressureNode extends Node<IPressureNodeProvider, TickingGrid, Objec
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (obj instanceof IFluidHandler)
|
else if (obj instanceof IFluidHandler)
|
||||||
{
|
{
|
||||||
IFluidHandler fluidHandler = (IFluidHandler) obj;
|
IFluidHandler fluidHandler = (IFluidHandler) obj;
|
||||||
|
@ -166,7 +170,7 @@ public class PressureNode extends Node<IPressureNodeProvider, TickingGrid, Objec
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getMaxFlowRate()
|
public int getMaxFlowRate()
|
||||||
{
|
{
|
||||||
return 10;
|
return 10;
|
||||||
}
|
}
|
||||||
|
|
|
@ -219,6 +219,12 @@ public abstract class PartFramedNode<M extends Enum, N extends Node, T extends I
|
||||||
node.reconstruct();
|
node.reconstruct();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNeighborChanged()
|
||||||
|
{
|
||||||
|
node.reconstruct();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onWorldSeparate()
|
public void onWorldSeparate()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue