Fixed fluid system tentatively

This commit is contained in:
Calclavia 2014-03-08 13:44:21 -08:00
parent b94e8aaf17
commit 33df875a9b
6 changed files with 109 additions and 69 deletions

View file

@ -88,10 +88,10 @@ public class RenderGutter extends TileEntitySpecialRenderer implements ISimpleIt
FluidTank tank = ((TileGutter) tileEntity).getInternalTank();
double percentageFilled = (double) tank.getFluidAmount() / (double) tank.getCapacity();
double ySouthEast = FluidUtility.getAveragePercentageFilledForSides(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 ySouthWest = FluidUtility.getAveragePercentageFilledForSides(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 ySouthEast = FluidUtility.getAveragePercentageFilledForSides(TileGutter.class, percentageFilled, tileEntity.worldObj, new Vector3(tileEntity), ForgeDirection.SOUTH, ForgeDirection.EAST);
double yNorthEast = FluidUtility.getAveragePercentageFilledForSides(TileGutter.class, percentageFilled, tileEntity.worldObj, new Vector3(tileEntity), ForgeDirection.NORTH, ForgeDirection.EAST);
double ySouthWest = FluidUtility.getAveragePercentageFilledForSides(TileGutter.class, percentageFilled, tileEntity.worldObj, new Vector3(tileEntity), ForgeDirection.SOUTH, 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);
GL11.glPopMatrix();

View file

@ -67,10 +67,10 @@ public class RenderTank extends TileEntitySpecialRenderer implements ISimpleItem
FluidTank tank = ((TileTank) tileEntity).getInternalTank();
double percentageFilled = (double) tank.getFluidAmount() / (double) tank.getCapacity();
double ySouthEast = FluidUtility.getAveragePercentageFilledForSides(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 ySouthWest = FluidUtility.getAveragePercentageFilledForSides(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 ySouthEast = FluidUtility.getAveragePercentageFilledForSides(TileTank.class, percentageFilled, tileEntity.worldObj, new Vector3(tileEntity), ForgeDirection.SOUTH, ForgeDirection.EAST);
double yNorthEast = FluidUtility.getAveragePercentageFilledForSides(TileTank.class, percentageFilled, tileEntity.worldObj, new Vector3(tileEntity), ForgeDirection.NORTH, ForgeDirection.EAST);
double ySouthWest = FluidUtility.getAveragePercentageFilledForSides(TileTank.class, percentageFilled, tileEntity.worldObj, new Vector3(tileEntity), ForgeDirection.SOUTH, 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);
}
else

View file

@ -49,6 +49,9 @@ public class PartPipe extends PartFramedNode<EnumPipeMaterial, PressureNode, IPr
synchronized (connections)
{
connections.clear();
if (world() != null)
{
byte previousConnections = getAllCurrentConnections();
currentConnections = 0;
@ -78,30 +81,32 @@ public class PartPipe extends PartFramedNode<EnumPipeMaterial, PressureNode, IPr
}
/** Only send packet updates if visuallyConnected changed. */
if (previousConnections != currentConnections)
if (!world().isRemote && previousConnections != currentConnections)
{
sendConnectionUpdate();
}
}
}
}
@Override
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 getColor() == ((PartPipe) obj).getColor() || (getColor() == DEFAULT_COLOR || ((PartPipe) obj).getColor() == DEFAULT_COLOR);
}
return false;
}
return tile instanceof IFluidHandler;*/
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 getColor() == ((PartPipe) obj).getColor() || (getColor() == DEFAULT_COLOR
* || ((PartPipe) obj).getColor() == DEFAULT_COLOR);
* }
* return false;
* }
* return tile instanceof IFluidHandler;
*/
}
@Override
@ -232,12 +237,12 @@ public class PartPipe extends PartFramedNode<EnumPipeMaterial, PressureNode, IPr
@Override
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

View file

@ -16,7 +16,6 @@ import calclavia.lib.prefab.tile.IRotatable;
public class TilePump extends TileMechanical implements IPressureNodeProvider, IRotatable
{
private final long maximumPower = 100000;
private final PressureNode pressureNode;
public TilePump()
@ -30,19 +29,46 @@ public class TilePump extends TileMechanical implements IPressureNodeProvider, I
{
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())
{
return (int) -Math.max((((double) mechanicalNode.getPower() / (double) maximumPower) * 100), 2);
return (int) -Math.max(Math.abs(mechanicalNode.getTorque() / 1000d), 2);
}
}
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
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);
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(), flowRate, false);
FluidStack drain = ((IFluidHandler) tileIn).drain(getDirection(), pressureNode.getMaxFlowRate(), false);
if (drain != null)
{

View file

@ -104,9 +104,12 @@ public class PressureNode extends Node<IPressureNodeProvider, TickingGrid, Objec
if (pressureA >= pressureB)
{
FluidTank tankA = parent.getPressureTank();
if (tankA != null)
{
FluidStack fluidA = tankA.getFluid();
if (tankA != null && fluidA != null)
if (fluidA != null)
{
int amountA = fluidA.amount;
@ -133,6 +136,7 @@ public class PressureNode extends Node<IPressureNodeProvider, TickingGrid, Objec
}
}
}
}
else if (obj instanceof IFluidHandler)
{
IFluidHandler fluidHandler = (IFluidHandler) obj;
@ -166,7 +170,7 @@ public class PressureNode extends Node<IPressureNodeProvider, TickingGrid, Objec
}
}
protected int getMaxFlowRate()
public int getMaxFlowRate()
{
return 10;
}

View file

@ -219,6 +219,12 @@ public abstract class PartFramedNode<M extends Enum, N extends Node, T extends I
node.reconstruct();
}
@Override
public void onNeighborChanged()
{
node.reconstruct();
}
@Override
public void onWorldSeparate()
{