diff --git a/src/main/scala/resonantinduction/archaic/fluid/gutter/NodePressureGravity.scala b/src/main/scala/resonantinduction/archaic/fluid/gutter/NodePressureGravity.scala index acf579f3c..329b1dbd1 100644 --- a/src/main/scala/resonantinduction/archaic/fluid/gutter/NodePressureGravity.scala +++ b/src/main/scala/resonantinduction/archaic/fluid/gutter/NodePressureGravity.scala @@ -28,6 +28,7 @@ class NodePressureGravity(parent: TileFluidProvider, volume: Int = FluidContaine else quantity = if (pressureA > pressureB) (pressureA - pressureB) * flowRate else 0 + //TODO: There's a slight pressure backflow quantity = Math.min(Math.min(quantity, tankB.getCapacity - amountB), amountA) if (quantity > 0) diff --git a/src/main/scala/resonantinduction/mechanical/fluid/pipe/NodePipe.scala b/src/main/scala/resonantinduction/mechanical/fluid/pipe/NodePipe.scala index 8badabb91..41d3c64ba 100644 --- a/src/main/scala/resonantinduction/mechanical/fluid/pipe/NodePipe.scala +++ b/src/main/scala/resonantinduction/mechanical/fluid/pipe/NodePipe.scala @@ -3,7 +3,6 @@ package resonantinduction.mechanical.fluid.pipe import net.minecraftforge.common.util.ForgeDirection import net.minecraftforge.fluids.IFluidHandler import resonant.api.grid.INodeProvider -import resonant.lib.wrapper.BitmaskWrapper._ import resonantinduction.core.prefab.node.{NodePressure, TMultipartNode} import resonantinduction.core.prefab.part.connector.TColorable diff --git a/src/main/scala/resonantinduction/mechanical/fluid/pipe/PartPipe.scala b/src/main/scala/resonantinduction/mechanical/fluid/pipe/PartPipe.scala index 888d2523d..485769b71 100644 --- a/src/main/scala/resonantinduction/mechanical/fluid/pipe/PartPipe.scala +++ b/src/main/scala/resonantinduction/mechanical/fluid/pipe/PartPipe.scala @@ -31,8 +31,6 @@ import scala.collection.mutable */ class PartPipe extends PartFramedNode with TMaterial[PipeMaterial] with TColorable with IFluidHandler { - val tank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME) - override lazy val node = new NodePipe(this) /** @@ -72,7 +70,7 @@ class PartPipe extends PartFramedNode with TMaterial[PipeMaterial] with TColorab { super.update() - averageTankData.add(tank.getFluidAmount) + averageTankData.add(node.getFluidAmount) if (!world.isRemote && markPacket) { @@ -87,7 +85,7 @@ class PartPipe extends PartFramedNode with TMaterial[PipeMaterial] with TColorab override def activate(player: EntityPlayer, part: MovingObjectPosition, itemStack: ItemStack) : Boolean = { if(!world.isRemote) - println(node.pressure) + println(node.pressure + " : " + node.getFluidAmount) return super.activate(player, part, itemStack) } @@ -103,12 +101,12 @@ class PartPipe extends PartFramedNode with TMaterial[PipeMaterial] with TColorab if (id == 3) { - //Tank Packet + //node Packet val nbt = new NBTTagCompound val averageAmount = averageTankData.reduce(_ + _) / averageTankData.size - val tempTank = if (tank.getFluid != null) new FluidTank(tank.getFluid.getFluid, averageAmount, tank.getCapacity) else new FluidTank(tank.getCapacity) + val tempTank = node.getPrimaryTank//if (node.getFluid != null) new FluidTank(node.getFluid.getFluid, averageAmount, node.getCapacity) else new FluidTank(node.getCapacity) tempTank.writeToNBT(nbt) - packet.writeInt(tank.getCapacity).writeNBTTagCompound(nbt) + packet.writeInt(node.getCapacity).writeNBTTagCompound(nbt) } } @@ -118,10 +116,10 @@ class PartPipe extends PartFramedNode with TMaterial[PipeMaterial] with TColorab super[TMaterial].read(packet, packetID) super[TColorable].read(packet, packetID) - if (packetID == 3) + if (packetID == 3 && world.isRemote) { - tank.setCapacity(packet.readInt) - tank.readFromNBT(packet.readNBTTagCompound) + node.setPrimaryTank(new FluidTank(packet.readInt)) + node.getPrimaryTank.readFromNBT(packet.readNBTTagCompound) } } @@ -134,7 +132,7 @@ class PartPipe extends PartFramedNode with TMaterial[PipeMaterial] with TColorab super[TMaterial].load(nbt) super[TColorable].load(nbt) - tank.readFromNBT(nbt) + node.load(nbt) } override def save(nbt: NBTTagCompound) @@ -143,7 +141,7 @@ class PartPipe extends PartFramedNode with TMaterial[PipeMaterial] with TColorab super[TMaterial].save(nbt) super[TColorable].save(nbt) - tank.writeToNBT(nbt) + node.save(nbt) } @SideOnly(Side.CLIENT) @@ -161,7 +159,7 @@ class PartPipe extends PartFramedNode with TMaterial[PipeMaterial] with TColorab if (doFill) markPacket = true - return tank.fill(resource, doFill) + return node.fill(resource, doFill) } return 0 } @@ -178,7 +176,7 @@ class PartPipe extends PartFramedNode with TMaterial[PipeMaterial] with TColorab if (doDrain) markPacket = true - return tank.drain(maxDrain, doDrain) + return node.drain(maxDrain, doDrain) } return null } @@ -187,7 +185,7 @@ class PartPipe extends PartFramedNode with TMaterial[PipeMaterial] with TColorab override def canDrain(from: ForgeDirection, fluid: Fluid): Boolean = true - override def getTankInfo(from: ForgeDirection): Array[FluidTankInfo] = Array[FluidTankInfo](tank.getInfo) + override def getTankInfo(from: ForgeDirection): Array[FluidTankInfo] = Array[FluidTankInfo](node.getInfo) override def drawBreaking(renderBlocks: RenderBlocks) { diff --git a/src/main/scala/resonantinduction/mechanical/fluid/pipe/RenderPipe.scala b/src/main/scala/resonantinduction/mechanical/fluid/pipe/RenderPipe.scala index 6ba41e15d..8d69db9c8 100644 --- a/src/main/scala/resonantinduction/mechanical/fluid/pipe/RenderPipe.scala +++ b/src/main/scala/resonantinduction/mechanical/fluid/pipe/RenderPipe.scala @@ -9,11 +9,10 @@ import net.minecraftforge.client.IItemRenderer.ItemRenderType import net.minecraftforge.client.model.AdvancedModelLoader import net.minecraftforge.common.util.ForgeDirection import org.lwjgl.opengl.GL11 -import resonant.api.grid.INodeProvider import resonant.content.prefab.scal.render.ISimpleItemRenderer import resonant.lib.render.{FluidRenderUtility, RenderUtility} import resonant.lib.transform.vector.Vector3 -import resonant.lib.utility.{FluidUtility, WorldUtility} +import resonant.lib.utility.WorldUtility import resonant.lib.wrapper.BitmaskWrapper._ import resonantinduction.core.Reference @@ -85,7 +84,7 @@ object RenderPipe extends ISimpleItemRenderer GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5) render(part.getMaterialID, if (part.getColor > 0) ItemDye.field_150922_c(part.getColor) else -1, part.clientRenderMask) - val fluid = part.tank.getFluid + val fluid = part.node.getFluid val pos = new Vector3(x, y, z) if (fluid != null && fluid.amount > 0) @@ -96,13 +95,8 @@ object RenderPipe extends ISimpleItemRenderer GL11.glPushMatrix() GL11.glTranslated(dir.offsetX * 0.33, dir.offsetY * 0.33, dir.offsetZ * 0.33) GL11.glScaled(0.33, 0.33, 0.33) - val tank = part.tank - val percentageFilled = tank.getFluidAmount.toDouble / tank.getCapacity.toDouble - val ySouthEast = FluidUtility.getAveragePercentageFilledForSides(classOf[INodeProvider], percentageFilled, part.world, pos, ForgeDirection.SOUTH, ForgeDirection.EAST) - val yNorthEast = FluidUtility.getAveragePercentageFilledForSides(classOf[INodeProvider], percentageFilled, part.world, pos, ForgeDirection.NORTH, ForgeDirection.EAST) - val ySouthWest = FluidUtility.getAveragePercentageFilledForSides(classOf[INodeProvider], percentageFilled, part.world, pos, ForgeDirection.SOUTH, ForgeDirection.WEST) - val yNorthWest = FluidUtility.getAveragePercentageFilledForSides(classOf[INodeProvider], percentageFilled, part.world, pos, ForgeDirection.NORTH, ForgeDirection.WEST) - FluidRenderUtility.renderFluidTesselation(tank, ySouthEast, yNorthEast, ySouthWest, yNorthWest) + val tank = part.node + FluidRenderUtility.renderFluidTesselation(tank, 1, 1, 1, 1) GL11.glPopMatrix() }) } diff --git a/src/main/scala/resonantinduction/mechanical/fluid/transport/PumpNode.scala b/src/main/scala/resonantinduction/mechanical/fluid/transport/PumpNode.scala index ba223e4f0..9e3d041b5 100644 --- a/src/main/scala/resonantinduction/mechanical/fluid/transport/PumpNode.scala +++ b/src/main/scala/resonantinduction/mechanical/fluid/transport/PumpNode.scala @@ -15,14 +15,14 @@ class PumpNode(parent: INodeProvider) extends NodePressure(parent) override def pressure(dir: ForgeDirection): Int = { - if(pump.mechanicalNode.getPower > 0) + if (pump.mechanicalNode.getPower > 0) { if (dir == pump.getDirection) { - return Math.max(Math.log(Math.abs(pump.mechanicalNode.torque)), 2) toInt + return Math.max(Math.log(Math.abs(pump.mechanicalNode.torque) + 1), 2).toInt } - return -Math.max(Math.log(Math.abs(pump.mechanicalNode.torque)), 2).toInt + return -Math.max(Math.log(Math.abs(pump.mechanicalNode.torque) + 1), 2).toInt } return 0