Tanks now push fluids upwards when full

This commit is contained in:
Calclavia 2015-01-19 13:55:46 +08:00
parent e76e5cddd3
commit e1109de534
5 changed files with 33 additions and 21 deletions

View file

@ -17,7 +17,7 @@ class NodeFluidGravity(parent: TileFluidProvider, volume: Int = FluidContainerRe
val pressureA = nodeA.pressure(dir)
val pressureB = nodeB.pressure(dir.getOpposite)
val amountA = tankA.getFluidAmount
val amountB = tankB.getFluidAmount
val amountB = nodeB.fill(dir, drain(dir.getOpposite, amountA, false), false)
var quantity = 0

View file

@ -47,6 +47,24 @@ class TileTank extends TileFluidProvider(Material.iron) with ISneakPickup with R
if (obj.isInstanceOf[INode] && !obj.asInstanceOf[Node].parent.isInstanceOf[TileTank])
_connectedMask = _connectedMask.closeMask(dir)
}
override def fill(from: ForgeDirection, resource: FluidStack, doFill: Boolean): Int =
{
//Try to fill the current tank. If it fails, try to fill the tank above it.
val result = super.fill(from, resource, doFill)
if (result == 0)
{
val tile = (toVectorWorld + new Vector3(0, 1, 0)).getTileEntity
if (tile.isInstanceOf[TileTank])
{
return tile.asInstanceOf[TileTank].fill(from, resource, doFill)
}
}
return result
}
}
fluidNode.asInstanceOf[NodeFluidGravity].maxFlowRate = FluidContainerRegistry.BUCKET_VOLUME
@ -134,6 +152,7 @@ class TileTank extends TileFluidProvider(Material.iron) with ISneakPickup with R
GL11.glPopMatrix()
}
@SideOnly(Side.CLIENT)
def renderInventoryFluid(x: Double, y: Double, z: Double, fluid: FluidStack, capacity: Int)
{
val tank = new FluidTank(fluid, capacity)

View file

@ -30,6 +30,12 @@ class NodeFluidPressure(parent: INodeProvider, volume: Int = FluidContainerRegis
UpdateTicker.threaded.addUpdater(this)
}
override def deconstruct()
{
super.deconstruct()
UpdateTicker.threaded.removeUpdater(this)
}
def update(deltaTime: Double)
{
if (!world.isRemote)
@ -124,7 +130,7 @@ class NodeFluidPressure(parent: INodeProvider, volume: Int = FluidContainerRegis
val pressureA = nodeA.pressure(dir)
val pressureB = nodeB.pressure(dir.getOpposite)
val amountA = tankA.getFluidAmount
val amountB = tankB.getFluidAmount
val amountB = nodeB.fill(dir, drain(dir.getOpposite, amountA, false), false)
var quantity = if (pressureA > pressureB) (pressureA - pressureB) * flowRate else 0
quantity = Math.min(Math.min(quantity, tankB.getCapacity - amountB), amountA)
@ -139,6 +145,8 @@ class NodeFluidPressure(parent: INodeProvider, volume: Int = FluidContainerRegis
}
}
def pressure(direction: ForgeDirection): Int = _pressure
protected def updatePressure()
{
var totalPressure = 0
@ -176,8 +184,6 @@ class NodeFluidPressure(parent: INodeProvider, volume: Int = FluidContainerRegis
}
}
def pressure(direction: ForgeDirection): Int = _pressure
def pressure: Int = _pressure
def pressure_=(pressure: Int)
@ -185,6 +191,6 @@ class NodeFluidPressure(parent: INodeProvider, volume: Int = FluidContainerRegis
this._pressure = pressure
}
override def updateRate: Int = if (!isInvalid) 20 else 0
override def updateRate: Int = 20
}

View file

@ -12,10 +12,8 @@ import edx.core.prefab.part.connector.{PartFramedNode, TColorable, TMaterial}
import edx.mechanical.MechanicalContent
import edx.mechanical.fluid.pipe.PipeMaterials.PipeMaterial
import net.minecraft.client.renderer.RenderBlocks
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound
import net.minecraft.util.MovingObjectPosition
import net.minecraftforge.common.util.ForgeDirection
import net.minecraftforge.fluids._
import resonant.lib.collection.EvictingList
@ -75,17 +73,6 @@ class PartPipe extends PartFramedNode with TMaterial[PipeMaterial] with TColorab
}
}
/**
* Changes the wire's color.
*/
override def activate(player: EntityPlayer, part: MovingObjectPosition, itemStack: ItemStack): Boolean =
{
if (!world.isRemote)
println(node.pressure + " : " + node.getFluidAmount)
return super.activate(player, part, itemStack)
}
/**
* Packet Methods
*/

View file

@ -3,7 +3,6 @@ package edx.mechanical.fluid.transport
import edx.core.Reference
import edx.mechanical.mech.TileMechanical
import net.minecraft.block.material.Material
import net.minecraft.tileentity.TileEntity
import net.minecraft.util.ResourceLocation
import net.minecraftforge.client.model.AdvancedModelLoader
import net.minecraftforge.common.util.ForgeDirection
@ -55,8 +54,9 @@ class TilePump extends TileMechanical(Material.iron) with IRotatable with IFluid
{
if (from == getDirection.getOpposite)
{
val tileOut: TileEntity = toVector3.add(from.getOpposite).getTileEntity(this.worldObj)
if (tileOut.isInstanceOf[IFluidHandler]) return (tileOut.asInstanceOf[IFluidHandler]).fill(from, resource, doFill)
val tileOut = (toVectorWorld + from.getOpposite).getTileEntity
if (tileOut.isInstanceOf[IFluidHandler])
return (tileOut.asInstanceOf[IFluidHandler]).fill(from, resource, doFill)
}
return 0
}