Rewrote NodeFluid

This commit is contained in:
Calclavia 2014-11-06 23:11:08 +08:00
parent 47a4ea6ef1
commit 780250cda0
13 changed files with 192 additions and 209 deletions

View file

@ -4,12 +4,15 @@ 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
import resonantinduction.core.prefab.node.TileFluidProvider
class FluidGravityNode(parent: TileTankNode) extends NodePressure(parent)
/**
* A node for fluid that follows pressure and gravity.
* @author Calclavia
*/
class NodePressureGravity(parent: TileFluidProvider) extends NodePressure(parent)
{
override def getPressure(dir: ForgeDirection): Int =
override def pressure(dir: ForgeDirection): Int =
{
if (dir eq ForgeDirection.UP)
{

View file

@ -17,6 +17,7 @@ import org.lwjgl.opengl.GL11
import resonant.api.grid.INode
import resonant.api.recipe.{MachineRecipes, RecipeResource}
import resonant.content.factory.resources.RecipeType
import resonant.lib.prefab.fluid.NodeFluid
import resonant.lib.render.{FluidRenderUtility, RenderUtility}
import resonant.lib.utility.FluidUtility
import resonant.lib.utility.inventory.InventoryUtility
@ -39,34 +40,36 @@ object TileGutter
*/
class TileGutter extends TilePressureNode(Material.rock)
{
tankNode = new FluidGravityNode(this)
fluidNode = new NodePressureGravity(this)
setTextureName("material_wood_surface")
isOpaqueCube = false
normalRender = false
bounds = new Cuboid(0, 0, 0, 1, 0.99, 1)
override protected var fluidNode: NodeFluid = new NodePressureGravity(this)
override def getCollisionBoxes: java.lang.Iterable[Cuboid] =
{
val list: List[Cuboid] = new ArrayList[Cuboid]
val thickness = 0.1f
if (!renderSides.mask(ForgeDirection.DOWN))
if (!clientRenderMask.mask(ForgeDirection.DOWN))
{
list.add(new Cuboid(0.0F, 0.0F, 0.0F, 1.0F, thickness, 1.0F))
}
if (!renderSides.mask(ForgeDirection.WEST))
if (!clientRenderMask.mask(ForgeDirection.WEST))
{
list.add(new Cuboid(0.0F, 0.0F, 0.0F, thickness, 1.0F, 1.0F))
}
if (!renderSides.mask(ForgeDirection.NORTH))
if (!clientRenderMask.mask(ForgeDirection.NORTH))
{
list.add(new Cuboid(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, thickness))
}
if (!renderSides.mask(ForgeDirection.EAST))
if (!clientRenderMask.mask(ForgeDirection.EAST))
{
list.add(new Cuboid(1.0F - thickness, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F))
}
if (!renderSides.mask(ForgeDirection.SOUTH))
if (!clientRenderMask.mask(ForgeDirection.SOUTH))
{
list.add(new Cuboid(0.0F, 0.0F, 1.0F - thickness, 1.0F, 1.0F, 1.0F))
}
@ -166,7 +169,7 @@ class TileGutter extends TilePressureNode(Material.rock)
GL11.glPushMatrix()
GL11.glTranslated(position.x + 0.5, position.y + 0.5, position.z + 0.5)
render(0, renderSides)
render(0, clientRenderMask)
if (world != null)
{
@ -189,7 +192,7 @@ class TileGutter extends TilePressureNode(Material.rock)
GL11.glPopMatrix()
}
def render(meta: Int, sides: Byte)
def render(meta: Int, sides: Int)
{
RenderUtility.bind(TileGutter.TEXTURE)

View file

@ -14,12 +14,13 @@ import net.minecraftforge.fluids.{FluidContainerRegistry, FluidStack, FluidTank,
import org.lwjgl.opengl.GL11
import resonant.api.IRemovable.ISneakPickup
import resonant.content.prefab.RenderConnectedTexture
import resonant.lib.prefab.fluid.NodeFluid
import resonant.lib.render.{FluidRenderUtility, RenderUtility}
import resonant.lib.transform.vector.Vector3
import resonant.lib.utility.FluidUtility
import resonantinduction.archaic.ArchaicContent
import resonantinduction.core.Reference
import resonantinduction.core.prefab.node.TileTankNode
import resonantinduction.core.prefab.node.{NodePressure, TileFluidProvider}
/**
* Tile/Block class for basic Dynamic tanks
@ -28,23 +29,21 @@ import resonantinduction.core.prefab.node.TileTankNode
*/
object TileTank
{
final val volume: Int = 16
val volume = 16
}
class TileTank extends TileTankNode(Material.iron) with ISneakPickup with RenderConnectedTexture
class TileTank extends TileFluidProvider(Material.iron) with ISneakPickup with RenderConnectedTexture
{
isOpaqueCube = false
normalRender = false
forceStandardRender(true)
forceStandardRender (true)
itemBlock = classOf[ItemBlockTank]
setCapacity(16 * FluidContainerRegistry.BUCKET_VOLUME)
setCapacity(TileTank.volume * FluidContainerRegistry.BUCKET_VOLUME)
override protected var fluidNode: NodeFluid = new NodePressure(this)
override val edgeTexture = Reference.prefix + "tankEdge"
override def shouldSideBeRendered(access: IBlockAccess, x: Int, y: Int, z: Int, side: Int): Boolean =
{
return access.getBlock(x, y, z) != getBlockType
}
override def shouldSideBeRendered(access: IBlockAccess, x: Int, y: Int, z: Int, side: Int): Boolean = access.getBlock(x, y, z) != getBlockType
override def use(player: EntityPlayer, side: Int, vector3: Vector3): Boolean =
{
@ -52,6 +51,7 @@ class TileTank extends TileTankNode(Material.iron) with ISneakPickup with Render
{
return FluidUtility.playerActivatedFluidItem(world, xi, yi, zi, player, side)
}
return true
}
@ -61,6 +61,7 @@ class TileTank extends TileTankNode(Material.iron) with ISneakPickup with Render
{
return getFluid.getFluid.getLuminosity
}
return super.getLightValue(access)
}

View file

@ -1,49 +1,106 @@
package resonantinduction.core.prefab.node
import net.minecraftforge.common.util.ForgeDirection
import net.minecraftforge.fluids.{FluidStack, IFluidHandler}
import net.minecraftforge.fluids.{FluidContainerRegistry, IFluidHandler}
import resonant.api.grid.{INodeProvider, IUpdate}
import resonant.lib.prefab.fluid.NodeFluid
import scala.collection.convert.wrapAll._
class NodePressure(parent: INodeProvider, buckets: Int = 1) extends NodeTank(parent, buckets) with IUpdate
/**
* A node for fluid that moves based on pressure
*
* @param parent Parent(TileEntity or Multipart) that contains this node
* @param volume Amount of fluid in liters
*
* @author Calclavia
*/
class NodePressure(parent: INodeProvider, volume: Int = FluidContainerRegistry.BUCKET_VOLUME) extends NodeFluid(parent, volume) with IUpdate
{
private var pressure: Int = 0
var maxFlowRate = 20
var maxPressure = 100
private var _pressure: Int = 0
def update(deltaTime: Double)
{
if (!world.isRemote)
{
updatePressure()
distribute()
}
}
if (getFluid != null)
def distribute()
{
directionMap.foreach
{
case (handler: IFluidHandler, dir: ForgeDirection) =>
{
for (entry <- directionMap.entrySet)
if (handler.isInstanceOf[NodePressure])
{
if (entry.getKey.isInstanceOf[INodeProvider] && (entry.getKey.asInstanceOf[INodeProvider]).getNode(classOf[NodePressure], entry.getValue.getOpposite).isInstanceOf[NodePressure])
//It's another pressure node
val otherNode = handler.asInstanceOf[NodePressure]
val pressureA = pressure(dir)
val pressureB = otherNode.pressure(dir.getOpposite)
if (pressureA >= pressureB)
{
val node: NodePressure = (entry.getKey.asInstanceOf[INodeProvider]).getNode(classOf[NodePressure], entry.getValue.getOpposite).asInstanceOf[NodePressure]
if (node.getPressure(entry.getValue.getOpposite) <= getPressure(entry.getValue))
val tankA = getPrimaryTank
if (tankA != null)
{
val fluidA = tankA.getFluid
if (fluidA != null)
{
val amountA: Int = fluidA.amount
if (amountA > 0)
{
val tankB = otherNode.getPrimaryTank
if (tankB != null)
{
val amountB: Int = tankB.getFluidAmount
var quantity: Int = Math.max(if (pressureA > pressureB) (pressureA - pressureB) * maxFlowRate else 0, Math.min((amountA - amountB) / 2, maxFlowRate))
quantity = Math.min(Math.min(quantity, tankB.getCapacity - amountB), amountA)
if (quantity > 0)
{
val drainStack = drain(dir.getOpposite, quantity, false)
if (drainStack != null && drainStack.amount > 0)
{
drain(dir.getOpposite, otherNode.fill(dir, drainStack, true), true)
}
}
}
}
}
}
}
else if (entry.getKey.isInstanceOf[INodeProvider] && (entry.getKey.asInstanceOf[INodeProvider]).getNode(classOf[NodeTank], entry.getValue.getOpposite).isInstanceOf[NodeTank])
}
else
{
//It's a fluid handler.
val pressure = this.pressure(dir)
val tankPressure = 0
val sourceTank = getPrimaryTank
val transferAmount = (Math.max(pressure, tankPressure) - Math.min(pressure, tankPressure)) * maxFlowRate
if (pressure > tankPressure)
{
val node: NodeTank = (entry.getKey.asInstanceOf[INodeProvider]).getNode(classOf[NodeTank], entry.getValue.getOpposite).asInstanceOf[NodeTank]
if (node.canFill(entry.getValue.getOpposite, getFluid.getFluid))
if (sourceTank.getFluidAmount > 0 && transferAmount > 0)
{
val stack: FluidStack = drain(Integer.MAX_VALUE, false)
val drained: Int = node.fill(stack, true)
drain(drained, true)
val drainStack = drain(dir.getOpposite, transferAmount, false)
drain(dir.getOpposite, handler.fill(dir.getOpposite, drainStack, true), true)
}
}
else if (entry.getKey.isInstanceOf[IFluidHandler])
else if (pressure < tankPressure)
{
if ((entry.getKey.asInstanceOf[IFluidHandler]).canFill(entry.getValue.getOpposite, getFluid.getFluid))
if (transferAmount > 0)
{
val stack: FluidStack = drain(Integer.MAX_VALUE, false)
val drained: Int = (entry.getKey.asInstanceOf[IFluidHandler]).fill(entry.getValue.getOpposite, stack, true)
drain(drained, true)
val drainStack = handler.drain(dir.getOpposite, transferAmount, false)
if (drainStack != null)
{
handler.drain(dir.getOpposite, fill(dir.getOpposite, drainStack, true), true)
}
}
}
}
@ -53,50 +110,51 @@ class NodePressure(parent: INodeProvider, buckets: Int = 1) extends NodeTank(par
protected def updatePressure()
{
var totalPressure: Int = 0
val connectionSize: Int = connections.size
var minPressure: Int = 0
var maxPressure: Int = 0
for (entry <- directionMap.entrySet)
var totalPressure = 0
val connectionSize = connections.size
var minPressure = 0
var maxPressure = 0
directionMap.foreach
{
if (entry.getKey.isInstanceOf[INodeProvider] && (entry.getKey.asInstanceOf[INodeProvider]).getNode(classOf[NodePressure], entry.getValue.getOpposite).isInstanceOf[NodePressure])
case (handler: IFluidHandler, dir: ForgeDirection) =>
{
val node: NodePressure = (entry.getKey.asInstanceOf[INodeProvider]).getNode(classOf[NodePressure], entry.getValue.getOpposite).asInstanceOf[NodePressure]
val pressure: Int = node.getPressure(entry.getValue.getOpposite)
minPressure = Math.min(pressure, minPressure)
maxPressure = Math.max(pressure, maxPressure)
totalPressure += pressure
if (handler.isInstanceOf[NodePressure])
{
val node = handler.asInstanceOf[NodePressure]
val pressure = node.pressure(dir.getOpposite)
minPressure = Math.min(pressure, minPressure)
maxPressure = Math.max(pressure, maxPressure)
totalPressure += pressure
}
}
}
if (connectionSize == 0)
{
setPressure(0)
pressure = 0
}
else
{
if (minPressure < 0)
{
minPressure += 1
}
if (maxPressure > 0)
{
maxPressure -= 1
}
setPressure(Math.max(minPressure, Math.min(maxPressure, totalPressure / connectionSize + Integer.signum(totalPressure))))
pressure = Math.max(minPressure, Math.min(maxPressure, totalPressure / connectionSize + Integer.signum(totalPressure)))
}
}
def getPressure(direction: ForgeDirection): Int =
def pressure: Int = _pressure
def pressure(direction: ForgeDirection): Int = _pressure
def pressure_=(pressure: Int)
{
return pressure
this._pressure = pressure
}
def setPressure(pressure: Int)
{
this.pressure = pressure
}
def canUpdate =true
def canUpdate = true
def continueUpdate = true
}

View file

@ -1,56 +0,0 @@
package resonantinduction.core.prefab.node
import net.minecraft.nbt.NBTTagCompound
import net.minecraftforge.common.util.ForgeDirection
import net.minecraftforge.fluids._
import resonant.api.ISave
import resonant.api.grid.{INode, INodeProvider}
import resonant.lib.prefab.fluid.{LimitedTank, NodeFluidHandler}
import resonant.lib.wrapper.BitmaskWrapper._
/**
* Simple tank node designed to be implemented by any machine that can connect to other fluid based machines.
*
* @author Darkguardsman
*/
class NodeTank(parent: INodeProvider, buckets: Int) extends NodeFluidHandler(parent, new LimitedTank(buckets * FluidContainerRegistry.BUCKET_VOLUME)) with ISave with INode
{
def load(nbt: NBTTagCompound)
{
getPrimaryTank.readFromNBT(nbt.getCompoundTag("tank"))
}
def save(nbt: NBTTagCompound)
{
nbt.setTag("tank", getPrimaryTank.writeToNBT(new NBTTagCompound))
}
override def connect[B <: IFluidHandler](obj: B, dir: ForgeDirection)
{
super.connect(obj, dir)
if (showConnectionsFor(obj, dir))
{
renderSides = getRenderSides.openMask(dir)
}
}
protected def showConnectionsFor(obj: AnyRef, dir: ForgeDirection): Boolean =
{
if (obj != null)
{
if (obj.getClass.isAssignableFrom(getParent.getClass))
{
return true
}
}
return false
}
def getRenderSides: Int =
{
return renderSides
}
private[node] var renderSides: Int = 0
}

View file

@ -10,66 +10,42 @@ import net.minecraftforge.common.util.ForgeDirection
import net.minecraftforge.fluids._
import resonant.api.grid.{INode, INodeProvider}
import resonant.content.prefab.java.TileAdvanced
import resonant.lib.grid.node.TSpatialNodeProvider
import resonant.lib.network.discriminator.{PacketTile, PacketType}
import resonant.lib.network.handle.TPacketIDReceiver
import resonant.lib.prefab.fluid.NodeFluid
/**
* A prefab class for tiles that use the fluid network.
*
* @author DarkGuardsman
* @author DarkGuardsman, Calclavia
*/
class TileTankNode(material: Material) extends TileAdvanced(material) with INodeProvider with IFluidHandler with TPacketIDReceiver
abstract class TileFluidProvider(material: Material) extends TileAdvanced(material) with TSpatialNodeProvider with IFluidHandler with TPacketIDReceiver
{
val PACKET_DESCRIPTION = 0
val PACKET_RENDER = 1
var renderSides: Byte = 0
var tankNode: NodeTank = new NodeTank(this, 16)
val descriptionPacket = 0
val renderPacket = 1
protected var fluidNode: NodeFluid
protected var colorID: Int = 0
protected var clientRenderMask = 0x00
nodes.add(fluidNode)
def getFluid: FluidStack = getTank.getFluid
def getFluidCapacity: Int = getTank.getCapacity
def getTank: IFluidTank = tankNode
override def start()
{
super.start()
tankNode.reconstruct()
}
override def invalidate()
{
tankNode.deconstruct()
super.invalidate()
}
override def onWorldJoin()
{
tankNode.reconstruct()
}
override def onNeighborChanged(block: Block)
{
tankNode.reconstruct()
}
override def onWorldSeparate()
{
tankNode.deconstruct()
}
def getTank: IFluidTank = fluidNode
override def readFromNBT(nbt: NBTTagCompound)
{
super.readFromNBT(nbt)
tankNode.load(nbt)
colorID = nbt.getInteger("colorID")
}
override def writeToNBT(nbt: NBTTagCompound)
{
super.writeToNBT(nbt)
tankNode.save(nbt)
nbt.setInteger("colorID", colorID)
}
@ -78,9 +54,9 @@ class TileTankNode(material: Material) extends TileAdvanced(material) with INode
if (!world.isRemote)
{
val packet: PacketTile = new PacketTile(this);
packet <<< PACKET_RENDER
packet <<< renderPacket
packet <<< colorID
packet <<< renderSides
packet <<< fluidNode.connectedBitmask
sendPacket(packet)
}
}
@ -88,11 +64,11 @@ class TileTankNode(material: Material) extends TileAdvanced(material) with INode
override def getDescPacket(): PacketTile =
{
val packet: PacketTile = new PacketTile(this);
packet <<< PACKET_DESCRIPTION
packet <<< descriptionPacket
packet <<< colorID
packet <<< renderSides
packet <<< fluidNode.connectedBitmask
val tag: NBTTagCompound = new NBTTagCompound()
tankNode.save(tag)
fluidNode.save(tag)
packet <<< tag
sendPacket(packet)
return packet
@ -100,40 +76,37 @@ class TileTankNode(material: Material) extends TileAdvanced(material) with INode
override def read(buf: ByteBuf, id: Int, player: EntityPlayer, t: PacketType): Boolean =
{
//TODO handle fluid node's packet code
if (id == PACKET_DESCRIPTION)
if (id == descriptionPacket)
{
colorID = buf.readInt()
renderSides = buf.readByte()
tankNode.load(ByteBufUtils.readTag(buf))
clientRenderMask = buf.readByte()
fluidNode.load(ByteBufUtils.readTag(buf))
}
else if (id == PACKET_RENDER)
else if (id == renderPacket)
{
colorID = buf.readInt()
renderSides = buf.readByte()
clientRenderMask = buf.readByte()
}
return false
}
override def getNode[N <: INode](nodeType: Class[_ <: N], from: ForgeDirection): N = (if (nodeType.isInstanceOf[NodeTank]) tankNode else null).asInstanceOf[N]
override def drain(from: ForgeDirection, resource: FluidStack, doDrain: Boolean): FluidStack = fluidNode.drain(from, resource, doDrain)
override def drain(from: ForgeDirection, resource: FluidStack, doDrain: Boolean): FluidStack = tankNode.drain(from, resource, doDrain)
override def drain(from: ForgeDirection, maxDrain: Int, doDrain: Boolean): FluidStack = fluidNode.drain(from, maxDrain, doDrain)
override def drain(from: ForgeDirection, maxDrain: Int, doDrain: Boolean): FluidStack = tankNode.drain(from, maxDrain, doDrain)
override def canFill(from: ForgeDirection, fluid: Fluid): Boolean = fluidNode.canFill(from, fluid)
override def canFill(from: ForgeDirection, fluid: Fluid): Boolean = tankNode.canFill(from, fluid)
override def canDrain(from: ForgeDirection, fluid: Fluid): Boolean = fluidNode.canDrain(from, fluid)
override def canDrain(from: ForgeDirection, fluid: Fluid): Boolean = tankNode.canDrain(from, fluid)
override def fill(from: ForgeDirection, resource: FluidStack, doFill: Boolean): Int = fluidNode.fill(from, resource, doFill)
override def fill(from: ForgeDirection, resource: FluidStack, doFill: Boolean): Int = tankNode.fill(from, resource, doFill)
override def getTankInfo(from: ForgeDirection): Array[FluidTankInfo] = tankNode.getTankInfo(from)
override def getTankInfo(from: ForgeDirection): Array[FluidTankInfo] = fluidNode.getTankInfo(from)
def setCapacity(capacity: Int)
{
tankNode.setCapacity(capacity)
fluidNode.setCapacity(capacity)
}
def getFluidAmount: Int = tankNode.getFluidAmount
def getFluidAmount: Int = fluidNode.getFluidAmount
}

View file

@ -2,19 +2,22 @@ package resonantinduction.core.prefab.node
import net.minecraft.block.material.Material
import net.minecraftforge.common.util.ForgeDirection
import resonant.lib.prefab.fluid.NodeFluid
class TilePressureNode(material: Material) extends TileTankNode(material: Material)
class TilePressureNode(material: Material) extends TileFluidProvider(material: Material)
{
//Constructor
tankNode == new NodePressure(this)
fluidNode == new NodePressure(this)
override protected var fluidNode: NodeFluid = new NodePressure(this)
def getPressureNode: NodePressure =
{
return tankNode.asInstanceOf[NodePressure]
return fluidNode.asInstanceOf[NodePressure]
}
def getPressure(direction: ForgeDirection): Int =
{
return getPressureNode.getPressure(direction)
return getPressureNode.pressure(direction)
}
}

View file

@ -17,7 +17,7 @@ import scala.collection.convert.wrapAll._
import scala.collection.mutable
abstract class PartFramedNode extends PartAbstract with TNodePartConnector with TSlottedPart with TNormalOcclusion with TIconHitEffects
abstract class PartFramedNode extends PartAbstract with TPartNodeProvider with TSlottedPart with TNormalOcclusion with TIconHitEffects
{
/** Bitmask connections */
var connectionMask = 0x00

View file

@ -9,7 +9,7 @@ import resonant.api.grid.{INode, INodeProvider}
* A node trait that can be mixed into any multipart nodes. Mixing this trait will cause nodes to reconstruct/deconstruct when needed.
* @author Calclavia
*/
trait TNodePartConnector extends PartAbstract with INodeProvider
trait TPartNodeProvider extends PartAbstract with INodeProvider
{
protected lazy val node: INode = null

View file

@ -6,10 +6,10 @@ import net.minecraft.block.material.Material
import net.minecraft.nbt.NBTTagCompound
import net.minecraftforge.common.util.ForgeDirection
import resonant.api.IRotatable
import resonant.api.grid.{INode, IUpdate, NodeRegistry}
import resonant.api.grid.{INode, IUpdate}
import resonant.content.prefab.java.TileNode
import resonant.lib.content.prefab.TElectric
import resonantinduction.core.interfaces.IMechanicalNode
import resonantinduction.mechanical.mech.MechanicalNode
/**
* A kinetic energy to electrical energy converter.
@ -18,19 +18,16 @@ import resonantinduction.core.interfaces.IMechanicalNode
*/
class TileMotor extends TileNode(Material.iron) with TElectric with IRotatable
{
var mechNode: IMechanicalNode = NodeRegistry.get(this, classOf[IMechanicalNode])
var mechNode = new MechanicalNode(this)
/** Generator turns KE -> EE. Inverted one will turn EE -> KE. */
var isInversed: Boolean = true
private var gearRatio: Byte = 0
private var gearRatio = 0
//Constructor
this.normalRender(false)
this.isOpaqueCube(false)
normalRender = false
isOpaqueCube = false
def toggleGearRatio: Byte =
{
return ((gearRatio + 1) % 3).asInstanceOf[Byte]
}
def toggleGearRatio = ((gearRatio + 1) % 3)
override def start
{
@ -86,7 +83,7 @@ class TileMotor extends TileNode(Material.iron) with TElectric with IRotatable
var setTorque: Double = maxTorque
val currentTorque: Double = Math.abs(mechNode.getForce(ForgeDirection.UNKNOWN))
if (currentTorque != 0)
{setTorque = Math.min(setTorque, maxTorque) * (mechNode.getForce(ForgeDirection.UNKNOWN) / currentTorque) }
{setTorque = Math.min(setTorque, maxTorque) * (mechNode.getForce(ForgeDirection.UNKNOWN) / currentTorque)}
val currentVelo: Double = Math.abs(mechNode.getAngularSpeed(ForgeDirection.UNKNOWN))
if (currentVelo != 0) setAngularVelocity = Math.min(+setAngularVelocity, maxAngularVelocity) * (mechNode.getAngularSpeed(ForgeDirection.UNKNOWN) / currentVelo)
mechNode.apply(this, setTorque - mechNode.getForce(ForgeDirection.UNKNOWN), setAngularVelocity - mechNode.getAngularSpeed(ForgeDirection.UNKNOWN))
@ -121,7 +118,7 @@ class TileMotor extends TileNode(Material.iron) with TElectric with IRotatable
{
super.writeToNBT(nbt)
nbt.setBoolean("isInversed", isInversed)
nbt.setByte("gear", gearRatio)
nbt.setByte("gear", gearRatio.toByte)
}
override def getNode[N <: INode](nodeType: Class[_ <: N], from: ForgeDirection): N =

View file

@ -20,7 +20,7 @@ import resonant.api.grid.INodeProvider
*
* @author Calclavia
*/
trait TWire extends PartAbstract with TNodePartConnector with TMaterial[WireMaterial] with TInsulatable with TColorable
trait TWire extends PartAbstract with TPartNodeProvider with TMaterial[WireMaterial] with TInsulatable with TColorable
{
override protected val insulationItem: Item = ElectricalContent.itemInsulation
material = WireMaterial.COPPER

View file

@ -13,7 +13,7 @@ class PumpNode(parent: INodeProvider) extends NodePressure(parent)
{
def pump: TilePump = getParent.asInstanceOf[TilePump]
override def getPressure(dir: ForgeDirection): Int =
override def pressure(dir: ForgeDirection): Int =
{
if (pump.mechanicalNode.getPower > 0)
{

View file

@ -37,10 +37,10 @@ abstract class PartMechanical extends PartAbstract with JNormalOcclusion with TF
this.tier = itemDamage
}
override def onNeighborChanged
override def onNeighborChanged()
{
super.onNeighborChanged
mechanicalNode.reconstruct
super.onNeighborChanged()
mechanicalNode.reconstruct()
}
override def onPartChanged(part: TMultiPart)
@ -94,7 +94,7 @@ abstract class PartMechanical extends PartAbstract with JNormalOcclusion with TF
return super.activate(player, hit, itemStack)
}
def checkClientUpdate
def checkClientUpdate()
{
if (Math.abs(prevAngularVelocity - mechanicalNode.angularVelocity) >= 0.1)
{
@ -111,22 +111,23 @@ abstract class PartMechanical extends PartAbstract with JNormalOcclusion with TF
return null.asInstanceOf[N]
}
override def onWorldJoin
override def onWorldJoin()
{
mechanicalNode.reconstruct
mechanicalNode.reconstruct()
}
override def onWorldSeparate
override def onWorldSeparate()
{
mechanicalNode.deconstruct
mechanicalNode.deconstruct()
if (frame != null)
{
frame.closeDebugFrame
frame.closeDebugFrame()
}
}
/** Packet Code. */
def sendRotationPacket
def sendRotationPacket()
{
if (world != null && !world.isRemote)
{