Fixed gutter fluid attempting to flow back up
This commit is contained in:
parent
fbcdbbca4d
commit
1b1a295513
4 changed files with 80 additions and 53 deletions
|
@ -22,11 +22,16 @@ class NodeFluidGravity(parent: TileFluidProvider, volume: Int = FluidContainerRe
|
|||
var quantity = 0
|
||||
|
||||
if (dir == ForgeDirection.DOWN)
|
||||
{
|
||||
quantity = Math.max(if (pressureA > pressureB) (pressureA - pressureB) * flowRate else amountA, amountA)
|
||||
else if (nodeB.isInstanceOf[NodeFluidGravity])
|
||||
}
|
||||
else if (dir != ForgeDirection.UP)
|
||||
{
|
||||
if (nodeB.isInstanceOf[NodeFluidGravity])
|
||||
quantity = Math.max(if (pressureA > pressureB) (pressureA - pressureB) * flowRate else Math.min((amountA - amountB) / 2, flowRate), Math.min((amountA - amountB) / 2, flowRate))
|
||||
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)
|
||||
|
|
|
@ -17,6 +17,7 @@ import net.minecraftforge.fluids._
|
|||
import org.lwjgl.opengl.GL11
|
||||
import resonant.api.recipe.{MachineRecipes, RecipeResource}
|
||||
import resonant.content.factory.resources.RecipeType
|
||||
import resonant.lib.grid.UpdateTicker
|
||||
import resonant.lib.prefab.fluid.NodeFluid
|
||||
import resonant.lib.render.{FluidRenderUtility, RenderUtility}
|
||||
import resonant.lib.transform.region.Cuboid
|
||||
|
@ -46,6 +47,15 @@ object TileGutter
|
|||
class TileGutter extends TileFluidProvider(Material.rock)
|
||||
{
|
||||
fluidNode = new NodeGutter(this)
|
||||
fluidNode.onFluidChanged = () =>
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
//TODO: Check if this is very costly
|
||||
// UpdateTicker.world.enqueue(checkFluidAbove)
|
||||
sendPacket(0)
|
||||
}
|
||||
}
|
||||
|
||||
textureName = "material_wood_surface"
|
||||
isOpaqueCube = false
|
||||
|
@ -114,10 +124,23 @@ class TileGutter extends TileFluidProvider(Material.rock)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the block is first added to the world
|
||||
*/
|
||||
override def onWorldJoin()
|
||||
{
|
||||
super.onWorldJoin()
|
||||
checkFluidAbove()
|
||||
}
|
||||
|
||||
override def onNeighborChanged(block: Block)
|
||||
{
|
||||
super.onNeighborChanged(block)
|
||||
checkFluidAbove()
|
||||
}
|
||||
|
||||
def checkFluidAbove()
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
val posAbove = toVectorWorld + new Vector3(0, 1, 0)
|
||||
|
@ -274,8 +297,7 @@ class TileGutter extends TileFluidProvider(Material.rock)
|
|||
|
||||
class NodeGutter(parent: TileFluidProvider) extends NodeFluidGravity(parent)
|
||||
{
|
||||
|
||||
override def canConnect[B <: IFluidHandler](other: B, from: ForgeDirection) : Boolean =
|
||||
override def canConnect[B <: IFluidHandler](other: B, from: ForgeDirection): Boolean =
|
||||
{
|
||||
if (other.isInstanceOf[NodeFluid] && other.asInstanceOf[NodeFluid].parent.isInstanceOf[TileTank])
|
||||
return false
|
||||
|
|
|
@ -6,7 +6,6 @@ import resonant.api.IUpdate
|
|||
import resonant.api.tile.INodeProvider
|
||||
import resonant.lib.grid.UpdateTicker
|
||||
import resonant.lib.prefab.fluid.NodeFluid
|
||||
import resonantinduction.archaic.fluid.gutter.NodeFluidGravity
|
||||
|
||||
import scala.collection.convert.wrapAll._
|
||||
|
||||
|
@ -43,6 +42,8 @@ class NodeFluidPressure(parent: INodeProvider, volume: Int = FluidContainerRegis
|
|||
{
|
||||
val flowRate = (maxFlowRate * deltaTime).toInt
|
||||
|
||||
directionMap synchronized
|
||||
{
|
||||
directionMap.foreach
|
||||
{
|
||||
case (handler: IFluidHandler, dir: ForgeDirection) =>
|
||||
|
@ -112,6 +113,7 @@ class NodeFluidPressure(parent: INodeProvider, volume: Int = FluidContainerRegis
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected def doDistribute(dir: ForgeDirection, nodeA: NodeFluidPressure, nodeB: NodeFluidPressure, flowRate: Int)
|
||||
{
|
||||
|
|
|
@ -79,15 +79,13 @@ object ElectricalContent extends ContentHolder
|
|||
{
|
||||
super.init()
|
||||
|
||||
RICreativeTab.itemStack(new ItemStack(ElectricalContent.itemTransformer))
|
||||
|
||||
OreDictionary.registerOre("wire", ElectricalContent.itemWire)
|
||||
OreDictionary.registerOre("motor", ElectricalContent.blockMotor)
|
||||
OreDictionary.registerOre("battery", ItemBlockBattery.setTier(new ItemStack(ElectricalContent.blockBattery, 1, 0), 0.asInstanceOf[Byte]))
|
||||
OreDictionary.registerOre("batteryBox", ItemBlockBattery.setTier(new ItemStack(ElectricalContent.blockBattery, 1, 0), 0.asInstanceOf[Byte]))
|
||||
}
|
||||
|
||||
override def postInit
|
||||
override def postInit()
|
||||
{
|
||||
recipes += shaped(blockTesla, "WEW", " C ", "DID", 'W', "wire", 'E', Items.ender_eye, 'C', UniversalRecipe.BATTERY.get, 'D', Items.diamond, 'I', UniversalRecipe.PRIMARY_PLATE.get)
|
||||
recipes += shaped(itemMultimeter, "WWW", "ICI", 'W', "wire", 'C', UniversalRecipe.BATTERY.get, 'I', UniversalRecipe.PRIMARY_METAL.get)
|
||||
|
@ -141,7 +139,7 @@ object ElectricalContent extends ContentHolder
|
|||
@SideOnly(Side.CLIENT)
|
||||
def preTextureHook(event: TextureStitchEvent.Pre)
|
||||
{
|
||||
if (event.map.getTextureType() == 0)
|
||||
if (event.map.getTextureType == 0)
|
||||
{
|
||||
RenderFlatWire.wireIcon = event.map.registerIcon(Reference.prefix + "models/flatWire")
|
||||
RenderFramedWire.wireIcon = event.map.registerIcon(Reference.prefix + "models/wire")
|
||||
|
|
Loading…
Reference in a new issue