Fixed pump
This commit is contained in:
parent
b8b4b866c5
commit
7f6e7be7d6
|
@ -14,18 +14,12 @@ import resonant.lib.utility.nbt.NBTUtility
|
|||
import resonant.lib.wrapper.WrapList._
|
||||
import resonant.lib.transform.vector.Vector3
|
||||
|
||||
/** Handheld thermometer */
|
||||
object ItemBlockThermometer
|
||||
{
|
||||
final val ENERGY_CONSUMPTION: Int = 1000
|
||||
}
|
||||
|
||||
class ItemBlockThermometer(block: Block) extends ItemBlockSaved(block: Block)
|
||||
{
|
||||
|
||||
override def addInformation(itemStack: ItemStack, player: EntityPlayer, par3List: List[_], par4: Boolean)
|
||||
{
|
||||
super.addInformation(itemStack, player, par3List, par4)
|
||||
|
||||
val coord: Vector3 = getSavedCoord(itemStack)
|
||||
if (coord != null)
|
||||
{
|
||||
|
|
|
@ -2,8 +2,8 @@ package resonantinduction.mechanical.fluid.transport
|
|||
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import net.minecraftforge.fluids.IFluidHandler
|
||||
import resonantinduction.core.prefab.node.NodePressure
|
||||
import resonant.api.grid.INodeProvider
|
||||
import resonantinduction.core.prefab.node.NodePressure
|
||||
|
||||
/**
|
||||
* A node for the pump
|
||||
|
@ -15,18 +15,12 @@ class PumpNode(parent: INodeProvider) extends NodePressure(parent)
|
|||
|
||||
override def pressure(dir: ForgeDirection): Int =
|
||||
{
|
||||
if (pump.mechanicalNode.getPower > 0)
|
||||
if (dir == pump.getDirection)
|
||||
{
|
||||
if (dir == pump.getDirection)
|
||||
{
|
||||
return Math.max(Math.abs(pump.mechanicalNode.torque / 8000d), 2).asInstanceOf[Int]
|
||||
}
|
||||
else if (dir == pump.getDirection.getOpposite)
|
||||
{
|
||||
return -Math.max(Math.abs(pump.mechanicalNode.torque / 8000d), 2).asInstanceOf[Int]
|
||||
}
|
||||
return Math.max(Math.abs(pump.mechanicalNode.torque / 8000d), 2) toInt
|
||||
}
|
||||
return 0
|
||||
|
||||
return -Math.max(Math.abs(pump.mechanicalNode.torque / 8000d), 2).toInt
|
||||
}
|
||||
|
||||
override def canConnect[B <: IFluidHandler](source: B, from: ForgeDirection): Boolean =
|
||||
|
|
|
@ -29,6 +29,7 @@ class TilePump extends TileMechanical(Material.iron) with IRotatable with IFluid
|
|||
normalRender = false
|
||||
isOpaqueCube = false
|
||||
setTextureName("material_steel")
|
||||
|
||||
nodes.add(pressureNode)
|
||||
|
||||
override def update()
|
||||
|
@ -37,16 +38,16 @@ class TilePump extends TileMechanical(Material.iron) with IRotatable with IFluid
|
|||
|
||||
if (!worldObj.isRemote && mechanicalNode.getPower > 0)
|
||||
{
|
||||
val tileIn: TileEntity = toVector3.add(getDirection.getOpposite).getTileEntity(this.worldObj)
|
||||
//Push fluid inside this block to its front
|
||||
//TODO: Allow change of direction based on angular velocity
|
||||
val drain = pressureNode.drain(getDirection, pressureNode.getCapacity, false)
|
||||
|
||||
if (tileIn.isInstanceOf[IFluidHandler])
|
||||
if (drain != null)
|
||||
{
|
||||
val drain: FluidStack = (tileIn.asInstanceOf[IFluidHandler]).drain(getDirection, pressureNode.getCapacity, false)
|
||||
if (drain != null)
|
||||
{
|
||||
(tileIn.asInstanceOf[IFluidHandler]).drain(getDirection, fill(getDirection.getOpposite, drain, true), true)
|
||||
}
|
||||
pressureNode.drain(getDirection, fill(getDirection.getOpposite, drain, true), true)
|
||||
}
|
||||
|
||||
pressureNode.maxFlowRate = Math.abs(mechanicalNode.angularVelocity * 15).toInt
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,9 +91,9 @@ class TilePump extends TileMechanical(Material.iron) with IRotatable with IFluid
|
|||
|
||||
def drain(from: ForgeDirection, maxDrain: Int, doDrain: Boolean): FluidStack = null
|
||||
|
||||
def canFill(from: ForgeDirection, fluid: Fluid): Boolean = from == this.getDirection.getOpposite
|
||||
def canFill(from: ForgeDirection, fluid: Fluid): Boolean = from == getDirection.getOpposite
|
||||
|
||||
def canDrain(from: ForgeDirection, fluid: Fluid): Boolean = from == this.getDirection
|
||||
def canDrain(from: ForgeDirection, fluid: Fluid): Boolean = from == getDirection
|
||||
|
||||
def getTankInfo(from: ForgeDirection): Array[FluidTankInfo] = null
|
||||
}
|
|
@ -6,8 +6,9 @@ import net.minecraft.block.material.Material
|
|||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraft.init.Items
|
||||
import net.minecraft.item.ItemStack
|
||||
import resonant.content.prefab.java.TileNode
|
||||
import resonant.content.spatial.block.SpatialTile
|
||||
import resonant.engine.ResonantEngine
|
||||
import resonant.lib.content.prefab.TRotatable
|
||||
import resonant.lib.grid.node.TSpatialNodeProvider
|
||||
import resonant.lib.network.ByteBufWrapper._
|
||||
import resonant.lib.network.discriminator.PacketType
|
||||
|
@ -18,18 +19,26 @@ import resonantinduction.mechanical.mech.grid.MechanicalNode
|
|||
/** Prefab for resonantinduction.mechanical tiles
|
||||
*
|
||||
* @author Calclavia */
|
||||
abstract class TileMechanical(material: Material) extends TileNode(material) with TSpatialNodeProvider with TPacketSender with TPacketReceiver
|
||||
abstract class TileMechanical(material: Material) extends SpatialTile(material: Material) with TRotatable with TSpatialNodeProvider with TPacketSender with TPacketReceiver
|
||||
{
|
||||
/** Node that handles most mechanical actions */
|
||||
var mechanicalNode = new MechanicalNode(this)
|
||||
private var _mechanicalNode: MechanicalNode = null
|
||||
|
||||
def mechanicalNode = _mechanicalNode
|
||||
|
||||
def mechanicalNode_=(newNode: MechanicalNode)
|
||||
{
|
||||
_mechanicalNode = newNode
|
||||
mechanicalNode.onVelocityChanged = () => markPacket = true
|
||||
nodes.add(mechanicalNode)
|
||||
}
|
||||
|
||||
var markPacket = false
|
||||
|
||||
/** External debug GUI */
|
||||
var frame: DebugFrameMechanical = null
|
||||
|
||||
mechanicalNode.onVelocityChanged = () => markPacket = true
|
||||
nodes.add(mechanicalNode)
|
||||
mechanicalNode = new MechanicalNode(this)
|
||||
|
||||
override def update()
|
||||
{
|
||||
|
@ -80,14 +89,14 @@ abstract class TileMechanical(material: Material) extends TileNode(material) wit
|
|||
return false
|
||||
}
|
||||
|
||||
override def write(buf: ByteBuf, id: Int): Unit =
|
||||
override def write(buf: ByteBuf, id: Int)
|
||||
{
|
||||
super.write(buf, id)
|
||||
|
||||
id match
|
||||
{
|
||||
case 0 =>
|
||||
case 1 => buf <<< mechanicalNode.angularVelocity
|
||||
case 1 => buf <<< mechanicalNode.angularVelocity.toFloat
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -98,10 +107,7 @@ abstract class TileMechanical(material: Material) extends TileNode(material) wit
|
|||
id match
|
||||
{
|
||||
case 0 =>
|
||||
case 1 =>
|
||||
{
|
||||
mechanicalNode.angularVelocity = buf.readDouble
|
||||
}
|
||||
case 1 => mechanicalNode.angularVelocity = buf.readFloat()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -34,17 +34,12 @@ class TileMechanicalPiston extends TileMechanical(Material.piston)
|
|||
|
||||
//Constructor
|
||||
mechanicalNode = new NodeMechanicalPiston(this)
|
||||
isOpaqueCube(false)
|
||||
normalRender(false)
|
||||
customItemRender(true)
|
||||
isOpaqueCube=false
|
||||
normalRender=false
|
||||
customItemRender=true
|
||||
rotationMask = 63
|
||||
setTextureName("material_steel_dark")
|
||||
|
||||
override def getNodes(nodes: List[INode])
|
||||
{
|
||||
if (mechanicalNode != null) nodes.add(this.mechanicalNode)
|
||||
}
|
||||
|
||||
override def update
|
||||
{
|
||||
super.update
|
||||
|
|
|
@ -52,11 +52,6 @@ class TileMixer extends TileMechanical(Material.iron)
|
|||
customItemRender(true)
|
||||
setTextureName("material_metal_top")
|
||||
|
||||
override def getNodes(nodes: List[INode])
|
||||
{
|
||||
if (mechanicalNode != null) nodes.add(this.mechanicalNode)
|
||||
}
|
||||
|
||||
override def update
|
||||
{
|
||||
super.update
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
package resonantinduction.mechanical.mech.turbine
|
||||
|
||||
import io.netty.buffer.ByteBuf
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import net.minecraftforge.fluids.{Fluid, FluidStack, FluidTank, FluidTankInfo}
|
||||
import resonant.api.IBoilHandler
|
||||
import resonant.lib.content.prefab.{TElectric, TEnergyStorage}
|
||||
import resonant.lib.network.discriminator.PacketType
|
||||
import resonantinduction.core.{Reference, Settings}
|
||||
|
||||
class TileElectricTurbine extends TileTurbine with IBoilHandler with TElectric with TEnergyStorage
|
||||
|
|
|
@ -18,7 +18,7 @@ import resonant.api.grid.INodeProvider
|
|||
import resonant.lib.transform.vector.Vector3
|
||||
|
||||
/** Reduced version of the main turbine class */
|
||||
class TileTurbine extends TileMechanical(Material.wood) with IMultiBlockStructure[TileTurbine] with INodeProvider with IPacketIDReceiver
|
||||
class TileTurbine extends TileMechanical(Material.wood) with IMultiBlockStructure[TileTurbine] with INodeProvider
|
||||
{
|
||||
/** Tier of the tile */
|
||||
var tier: Int = 0
|
||||
|
|
Loading…
Reference in a new issue