From 91448bf5922d3930aa4d0ebbb89894b7d762bdc7 Mon Sep 17 00:00:00 2001 From: Robert S Date: Sat, 16 Aug 2014 03:59:58 -0400 Subject: [PATCH] Worked on abstracting TileGutter into a flexible node --- .../engineering/TileEngineeringTable.java | 6 ++-- .../fluid/gutter/FluidGravityNode.java | 25 ++++++++++++++ .../archaic/fluid/gutter/TileGutter.java | 27 ++------------- .../core/prefab/node/NodePressure.java | 2 ++ .../core/prefab/node/NodeTank.java | 33 +++++++++++++++++++ 5 files changed, 65 insertions(+), 28 deletions(-) diff --git a/src/main/scala/resonantinduction/archaic/engineering/TileEngineeringTable.java b/src/main/scala/resonantinduction/archaic/engineering/TileEngineeringTable.java index 79c6dbfda..bfa0a93c8 100644 --- a/src/main/scala/resonantinduction/archaic/engineering/TileEngineeringTable.java +++ b/src/main/scala/resonantinduction/archaic/engineering/TileEngineeringTable.java @@ -189,9 +189,9 @@ public class TileEngineeringTable extends TileInventory implements IPacketReceiv final double regionLength = 1d / 3d; // Rotate the hit vector based on direction of the tile. - hitVector.add(new Vector3(-0.5, 0, -0.5)); - 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)); + //hitVector.transform(new Quaternion(WorldUtility.getAngleFromForgeDirection(getDirection()), Vector3.up())); + //hitVector.add(new Vector3(0.5, 0, 0.5)); /** Crafting Matrix */ matrix: diff --git a/src/main/scala/resonantinduction/archaic/fluid/gutter/FluidGravityNode.java b/src/main/scala/resonantinduction/archaic/fluid/gutter/FluidGravityNode.java index 3fee75676..00efc7239 100644 --- a/src/main/scala/resonantinduction/archaic/fluid/gutter/FluidGravityNode.java +++ b/src/main/scala/resonantinduction/archaic/fluid/gutter/FluidGravityNode.java @@ -1,6 +1,8 @@ package resonantinduction.archaic.fluid.gutter; 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.TileTankNode; @@ -22,4 +24,27 @@ public class FluidGravityNode extends NodePressure 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; + } } diff --git a/src/main/scala/resonantinduction/archaic/fluid/gutter/TileGutter.java b/src/main/scala/resonantinduction/archaic/fluid/gutter/TileGutter.java index 84fe95151..7c5568d4b 100644 --- a/src/main/scala/resonantinduction/archaic/fluid/gutter/TileGutter.java +++ b/src/main/scala/resonantinduction/archaic/fluid/gutter/TileGutter.java @@ -26,6 +26,7 @@ import resonant.lib.utility.WorldUtility; import resonant.lib.utility.inventory.InventoryUtility; import resonantinduction.core.RecipeType; import resonantinduction.core.Reference; +import resonantinduction.core.prefab.node.NodePressure; import resonantinduction.core.prefab.node.TilePressureNode; import resonantinduction.core.prefab.node.TileTankNode; import universalelectricity.core.transform.region.Cuboid; @@ -48,6 +49,7 @@ public class TileGutter extends TilePressureNode public TileGutter() { super(Material.rock); + tankNode_$eq(new FluidGravityNode(this)); setTextureName("material_wood_surface"); isOpaqueCube(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 public void renderDynamic(Vector3 position, float frame, int pass) { diff --git a/src/main/scala/resonantinduction/core/prefab/node/NodePressure.java b/src/main/scala/resonantinduction/core/prefab/node/NodePressure.java index 45eb5fbd6..2647b9436 100644 --- a/src/main/scala/resonantinduction/core/prefab/node/NodePressure.java +++ b/src/main/scala/resonantinduction/core/prefab/node/NodePressure.java @@ -3,6 +3,7 @@ package resonantinduction.core.prefab.node; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidHandler; +import resonant.lib.utility.WorldUtility; import universalelectricity.api.core.grid.INodeProvider; import universalelectricity.api.core.grid.IUpdate; @@ -110,6 +111,7 @@ public class NodePressure extends NodeTank implements IUpdate } } + public int getPressure(ForgeDirection direction) { return pressure; } diff --git a/src/main/scala/resonantinduction/core/prefab/node/NodeTank.java b/src/main/scala/resonantinduction/core/prefab/node/NodeTank.java index 9fee8a5fb..016f4b2bc 100644 --- a/src/main/scala/resonantinduction/core/prefab/node/NodeTank.java +++ b/src/main/scala/resonantinduction/core/prefab/node/NodeTank.java @@ -10,6 +10,8 @@ import resonant.engine.ResonantEngine; import resonant.lib.network.discriminator.PacketTile; import resonant.lib.network.discriminator.PacketType; import resonant.lib.network.handle.IPacketIDReceiver; +import resonant.lib.utility.WorldUtility; +import resonant.lib.wrapper.ObjectOrWrapper; import resonantinduction.core.prefab.LimitedTank; import universalelectricity.api.core.grid.INodeProvider; 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 { LimitedTank tank; + byte renderSides = 0; static final int PACKET_DESCRIPTION = 100, PACKET_TANK = 101; 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); } + + @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) { tank.setCapacity(capacity); @@ -179,4 +207,9 @@ public class NodeTank extends NodeConnector implements IFluidTank, IFluidHandler { return tank.maxOutput; } + + public byte getRenderSides() + { + return renderSides; + } }