Worked on abstracting TileGutter into a flexible node
This commit is contained in:
parent
b145489ca6
commit
91448bf592
5 changed files with 65 additions and 28 deletions
|
@ -189,9 +189,9 @@ public class TileEngineeringTable extends TileInventory implements IPacketReceiv
|
||||||
final double regionLength = 1d / 3d;
|
final double regionLength = 1d / 3d;
|
||||||
|
|
||||||
// Rotate the hit vector based on direction of the tile.
|
// Rotate the hit vector based on direction of the tile.
|
||||||
hitVector.add(new Vector3(-0.5, 0, -0.5));
|
//hitVector.add(new Vector3(-0.5, 0, -0.5));
|
||||||
hitVector.transform(new Quaternion(WorldUtility.getAngleFromForgeDirection(getDirection()), Vector3.up()));
|
//hitVector.transform(new Quaternion(WorldUtility.getAngleFromForgeDirection(getDirection()), Vector3.up()));
|
||||||
hitVector.add(new Vector3(0.5, 0, 0.5));
|
//hitVector.add(new Vector3(0.5, 0, 0.5));
|
||||||
|
|
||||||
/** Crafting Matrix */
|
/** Crafting Matrix */
|
||||||
matrix:
|
matrix:
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package resonantinduction.archaic.fluid.gutter;
|
package resonantinduction.archaic.fluid.gutter;
|
||||||
|
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
import net.minecraftforge.fluids.Fluid;
|
||||||
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import resonantinduction.core.prefab.node.NodePressure;
|
import resonantinduction.core.prefab.node.NodePressure;
|
||||||
import resonantinduction.core.prefab.node.TileTankNode;
|
import resonantinduction.core.prefab.node.TileTankNode;
|
||||||
|
|
||||||
|
@ -22,4 +24,27 @@ public class FluidGravityNode extends NodePressure
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canFill(ForgeDirection from, Fluid fluid)
|
||||||
|
{
|
||||||
|
return from != ForgeDirection.UP && !fluid.isGaseous();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canDrain(ForgeDirection from, Fluid fluid)
|
||||||
|
{
|
||||||
|
return from != ForgeDirection.UP && !fluid.isGaseous();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
|
||||||
|
{
|
||||||
|
if (!resource.getFluid().isGaseous())
|
||||||
|
{
|
||||||
|
return super.fill(from, resource, doFill);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ import resonant.lib.utility.WorldUtility;
|
||||||
import resonant.lib.utility.inventory.InventoryUtility;
|
import resonant.lib.utility.inventory.InventoryUtility;
|
||||||
import resonantinduction.core.RecipeType;
|
import resonantinduction.core.RecipeType;
|
||||||
import resonantinduction.core.Reference;
|
import resonantinduction.core.Reference;
|
||||||
|
import resonantinduction.core.prefab.node.NodePressure;
|
||||||
import resonantinduction.core.prefab.node.TilePressureNode;
|
import resonantinduction.core.prefab.node.TilePressureNode;
|
||||||
import resonantinduction.core.prefab.node.TileTankNode;
|
import resonantinduction.core.prefab.node.TileTankNode;
|
||||||
import universalelectricity.core.transform.region.Cuboid;
|
import universalelectricity.core.transform.region.Cuboid;
|
||||||
|
@ -48,6 +49,7 @@ public class TileGutter extends TilePressureNode
|
||||||
public TileGutter()
|
public TileGutter()
|
||||||
{
|
{
|
||||||
super(Material.rock);
|
super(Material.rock);
|
||||||
|
tankNode_$eq(new FluidGravityNode(this));
|
||||||
setTextureName("material_wood_surface");
|
setTextureName("material_wood_surface");
|
||||||
isOpaqueCube(false);
|
isOpaqueCube(false);
|
||||||
normalRender(false);
|
normalRender(false);
|
||||||
|
@ -185,31 +187,6 @@ public class TileGutter extends TilePressureNode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
|
|
||||||
{
|
|
||||||
if (!resource.getFluid().isGaseous())
|
|
||||||
{
|
|
||||||
return super.fill(from, resource, doFill);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canFill(ForgeDirection from, Fluid fluid)
|
|
||||||
{
|
|
||||||
return from != ForgeDirection.UP && !fluid.isGaseous();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canDrain(ForgeDirection from, Fluid fluid)
|
|
||||||
{
|
|
||||||
return from != ForgeDirection.UP && !fluid.isGaseous();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderDynamic(Vector3 position, float frame, int pass)
|
public void renderDynamic(Vector3 position, float frame, int pass)
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,6 +3,7 @@ package resonantinduction.core.prefab.node;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import net.minecraftforge.fluids.IFluidHandler;
|
import net.minecraftforge.fluids.IFluidHandler;
|
||||||
|
import resonant.lib.utility.WorldUtility;
|
||||||
import universalelectricity.api.core.grid.INodeProvider;
|
import universalelectricity.api.core.grid.INodeProvider;
|
||||||
import universalelectricity.api.core.grid.IUpdate;
|
import universalelectricity.api.core.grid.IUpdate;
|
||||||
|
|
||||||
|
@ -110,6 +111,7 @@ public class NodePressure extends NodeTank implements IUpdate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getPressure(ForgeDirection direction) {
|
public int getPressure(ForgeDirection direction) {
|
||||||
return pressure;
|
return pressure;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,8 @@ import resonant.engine.ResonantEngine;
|
||||||
import resonant.lib.network.discriminator.PacketTile;
|
import resonant.lib.network.discriminator.PacketTile;
|
||||||
import resonant.lib.network.discriminator.PacketType;
|
import resonant.lib.network.discriminator.PacketType;
|
||||||
import resonant.lib.network.handle.IPacketIDReceiver;
|
import resonant.lib.network.handle.IPacketIDReceiver;
|
||||||
|
import resonant.lib.utility.WorldUtility;
|
||||||
|
import resonant.lib.wrapper.ObjectOrWrapper;
|
||||||
import resonantinduction.core.prefab.LimitedTank;
|
import resonantinduction.core.prefab.LimitedTank;
|
||||||
import universalelectricity.api.core.grid.INodeProvider;
|
import universalelectricity.api.core.grid.INodeProvider;
|
||||||
import universalelectricity.api.core.grid.ISave;
|
import universalelectricity.api.core.grid.ISave;
|
||||||
|
@ -23,6 +25,7 @@ import universalelectricity.core.grid.node.NodeConnector;
|
||||||
public class NodeTank extends NodeConnector implements IFluidTank, IFluidHandler, ISave, IPacketIDReceiver
|
public class NodeTank extends NodeConnector implements IFluidTank, IFluidHandler, ISave, IPacketIDReceiver
|
||||||
{
|
{
|
||||||
LimitedTank tank;
|
LimitedTank tank;
|
||||||
|
byte renderSides = 0;
|
||||||
static final int PACKET_DESCRIPTION = 100, PACKET_TANK = 101;
|
static final int PACKET_DESCRIPTION = 100, PACKET_TANK = 101;
|
||||||
|
|
||||||
public NodeTank(INodeProvider parent)
|
public NodeTank(INodeProvider parent)
|
||||||
|
@ -165,6 +168,31 @@ public class NodeTank extends NodeConnector implements IFluidTank, IFluidHandler
|
||||||
ResonantEngine.instance.packetHandler.sendToAllAround(new PacketTile((int)x(), (int)y(), (int)z(), tag), this, 64);
|
ResonantEngine.instance.packetHandler.sendToAllAround(new PacketTile((int)x(), (int)y(), (int)z(), tag), this, 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addConnection(Object obj, ForgeDirection dir)
|
||||||
|
{
|
||||||
|
super.addConnection(obj, dir);
|
||||||
|
if(showConnectionsFor(obj, dir))
|
||||||
|
renderSides = WorldUtility.setEnableSide(getRenderSides(), dir, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean showConnectionsFor(Object obj, ForgeDirection dir)
|
||||||
|
{
|
||||||
|
if(obj != null)
|
||||||
|
{
|
||||||
|
if(obj.getClass().isAssignableFrom(getClass()))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if(obj instanceof INodeProvider)
|
||||||
|
{
|
||||||
|
return ((INodeProvider) obj).getNode(getClass(), dir) != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public void setCapacity(int capacity)
|
public void setCapacity(int capacity)
|
||||||
{
|
{
|
||||||
tank.setCapacity(capacity);
|
tank.setCapacity(capacity);
|
||||||
|
@ -179,4 +207,9 @@ public class NodeTank extends NodeConnector implements IFluidTank, IFluidHandler
|
||||||
{
|
{
|
||||||
return tank.maxOutput;
|
return tank.maxOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public byte getRenderSides()
|
||||||
|
{
|
||||||
|
return renderSides;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue