Some incomplete work on pressure nodes
This commit is contained in:
parent
8131256e08
commit
be889b7064
3 changed files with 73 additions and 100 deletions
|
@ -13,10 +13,12 @@ import net.minecraftforge.common.ForgeDirection;
|
|||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import resonantinduction.core.ResonantInduction;
|
||||
import resonantinduction.core.fluid.IPressurizedNode;
|
||||
import resonantinduction.core.fluid.TilePressurizedNode;
|
||||
import resonantinduction.core.grid.fluid.PressureNode;
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
import calclavia.lib.prefab.vector.Cuboid;
|
||||
import calclavia.lib.utility.FluidUtility;
|
||||
|
@ -28,7 +30,7 @@ import calclavia.lib.utility.WorldUtility;
|
|||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public class TileGutter extends TilePressurizedNode implements IPressurizedNode
|
||||
public class TileGutter extends TilePressurizedNode
|
||||
{
|
||||
public TileGutter()
|
||||
{
|
||||
|
@ -36,6 +38,27 @@ public class TileGutter extends TilePressurizedNode implements IPressurizedNode
|
|||
textureName = "material_wood_surface";
|
||||
isOpaqueCube = false;
|
||||
normalRender = false;
|
||||
|
||||
node = new ExtendedPressureNode(this)
|
||||
{
|
||||
@Override
|
||||
public int getPressure(ForgeDirection dir)
|
||||
{
|
||||
if (dir == ForgeDirection.UP)
|
||||
return -3;
|
||||
|
||||
if (dir == ForgeDirection.DOWN)
|
||||
return +3;
|
||||
|
||||
return pressure;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxFlowRate()
|
||||
{
|
||||
return 20;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -95,6 +118,11 @@ public class TileGutter extends TilePressurizedNode implements IPressurizedNode
|
|||
entity.motionZ += 0.01 * dir.offsetZ * deltaPressure;
|
||||
}
|
||||
}
|
||||
|
||||
if (getInternalTank().getFluid().getFluid().getTemperature() >= 373)
|
||||
{
|
||||
entity.setFire(5);
|
||||
}
|
||||
}
|
||||
|
||||
if (entity instanceof EntityItem)
|
||||
|
@ -129,7 +157,7 @@ public class TileGutter extends TilePressurizedNode implements IPressurizedNode
|
|||
}
|
||||
|
||||
@Override
|
||||
public void refresh()
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
/**
|
||||
* Drain block above if it is a fluid.
|
||||
|
@ -142,8 +170,6 @@ public class TileGutter extends TilePressurizedNode implements IPressurizedNode
|
|||
if (fill(ForgeDirection.UP, drain, true) > 0)
|
||||
FluidUtility.drainBlock(worldObj, drainPos, true);
|
||||
}
|
||||
|
||||
super.refresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -153,13 +179,8 @@ public class TileGutter extends TilePressurizedNode implements IPressurizedNode
|
|||
{
|
||||
if (tileEntity instanceof IFluidHandler)
|
||||
{
|
||||
if (tileEntity instanceof TileGutter)
|
||||
{
|
||||
getNetwork().merge(((TileGutter) tileEntity).getNetwork());
|
||||
}
|
||||
|
||||
renderSides = WorldUtility.setEnableSide(renderSides, side, true);
|
||||
connectedBlocks[side.ordinal()] = tileEntity;
|
||||
node.getConnections().connectedBlocks[side.ordinal()] = tileEntity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -175,24 +196,6 @@ public class TileGutter extends TilePressurizedNode implements IPressurizedNode
|
|||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPressure(ForgeDirection dir)
|
||||
{
|
||||
if (dir == ForgeDirection.UP)
|
||||
return -3;
|
||||
|
||||
if (dir == ForgeDirection.DOWN)
|
||||
return +3;
|
||||
|
||||
return pressure;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxFlowRate()
|
||||
{
|
||||
return 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
|
@ -204,4 +207,5 @@ public class TileGutter extends TilePressurizedNode implements IPressurizedNode
|
|||
{
|
||||
return from != ForgeDirection.UP && !fluid.isGaseous();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@ import net.minecraftforge.fluids.FluidContainerRegistry;
|
|||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import resonantinduction.core.grid.fluid.IPressureNodeProvider;
|
||||
import resonantinduction.core.grid.fluid.PressureNode;
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
import calclavia.lib.network.IPacketReceiverWithID;
|
||||
|
||||
|
@ -15,12 +17,40 @@ import calclavia.lib.network.IPacketReceiverWithID;
|
|||
*
|
||||
* @author DarkGuardsman
|
||||
*/
|
||||
public abstract class TilePressurizedNode extends TileFluidNode implements IPressurizedNode, IPacketReceiverWithID
|
||||
public abstract class TilePressurizedNode extends TileFluidNode implements IPressureNodeProvider, IPacketReceiverWithID
|
||||
{
|
||||
protected Object[] connectedBlocks = new Object[6];
|
||||
protected PressureNode node;
|
||||
|
||||
/** Network used to link all parts together */
|
||||
protected PressureNetwork network;
|
||||
static class ExtendedPressureNode extends PressureNode
|
||||
{
|
||||
public ExtendedPressureNode(IPressureNodeProvider parent)
|
||||
{
|
||||
super(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recache()
|
||||
{
|
||||
if (!world().isRemote)
|
||||
{
|
||||
byte previousConnections = renderSides;
|
||||
connectedBlocks = new Object[6];
|
||||
renderSides = 0;
|
||||
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
validateConnectionSide(new Vector3(this).translate(dir).getTileEntity(worldObj), dir);
|
||||
}
|
||||
|
||||
/** Only send packet updates if visuallyConnected changed. */
|
||||
if (previousConnections != renderSides)
|
||||
{
|
||||
sendRenderUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
public TilePressurizedNode(Material material)
|
||||
{
|
||||
|
@ -32,23 +62,16 @@ public abstract class TilePressurizedNode extends TileFluidNode implements IPres
|
|||
public void initiate()
|
||||
{
|
||||
super.initiate();
|
||||
refresh();
|
||||
getNetwork().reconstruct();
|
||||
node.reconstruct();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
this.getNetwork().split(this);
|
||||
node.deconstruct();
|
||||
super.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPressure(int amount)
|
||||
{
|
||||
pressure = amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
|
@ -77,36 +100,6 @@ public abstract class TilePressurizedNode extends TileFluidNode implements IPres
|
|||
return new FluidTankInfo[] { getInternalTank().getInfo() };
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getConnections()
|
||||
{
|
||||
return connectedBlocks;
|
||||
}
|
||||
|
||||
public void refresh()
|
||||
{
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
byte previousConnections = renderSides;
|
||||
connectedBlocks = new Object[6];
|
||||
renderSides = 0;
|
||||
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
validateConnectionSide(new Vector3(this).translate(dir).getTileEntity(worldObj), dir);
|
||||
}
|
||||
|
||||
/** Only send packet updates if visuallyConnected changed. */
|
||||
if (previousConnections != renderSides)
|
||||
{
|
||||
sendRenderUpdate();
|
||||
}
|
||||
|
||||
getNetwork().reconstruct();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to make sure the connection is valid to the tileEntity
|
||||
*
|
||||
|
@ -125,12 +118,6 @@ public abstract class TilePressurizedNode extends TileFluidNode implements IPres
|
|||
this.colorID = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection direction, Object obj)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTank getInternalTank()
|
||||
{
|
||||
|
@ -142,32 +129,14 @@ public abstract class TilePressurizedNode extends TileFluidNode implements IPres
|
|||
}
|
||||
|
||||
@Override
|
||||
public IPressurizedNode getInstance(ForgeDirection from)
|
||||
public FluidTank getPressureTank()
|
||||
{
|
||||
return this;
|
||||
return getInternalTank();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFlow()
|
||||
public PressureNode getNode(ForgeDirection from)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PressureNetwork getNetwork()
|
||||
{
|
||||
if (this.network == null)
|
||||
{
|
||||
this.network = new PressureNetwork();
|
||||
this.network.addConnector(this);
|
||||
}
|
||||
|
||||
return this.network;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNetwork(PressureNetwork network)
|
||||
{
|
||||
this.network = network;
|
||||
return node;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -169,7 +169,7 @@ public class PressureNode extends Node<IPressureNodeProvider, TickingGrid, Objec
|
|||
}
|
||||
}
|
||||
|
||||
private int getMaxFlowRate()
|
||||
protected int getMaxFlowRate()
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue