Resolved all errors
This commit is contained in:
parent
1b7b4e8c9f
commit
5af7e0e9bf
|
@ -14,6 +14,7 @@ import net.minecraftforge.client.model.{AdvancedModelLoader, IModelCustom}
|
|||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import net.minecraftforge.fluids.{FluidRegistry, FluidStack, IFluidTank}
|
||||
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.render.{FluidRenderUtility, RenderUtility}
|
||||
|
|
|
@ -6,7 +6,7 @@ import net.minecraftforge.fluids._
|
|||
import resonant.api.ISave
|
||||
import resonant.api.grid.{INode, INodeProvider}
|
||||
import resonant.lib.prefab.fluid.{LimitedTank, NodeFluidHandler}
|
||||
import resonant.lib.utility.WorldUtility
|
||||
import resonant.lib.wrapper.BitmaskWrapper._
|
||||
|
||||
/**
|
||||
* Simple tank node designed to be implemented by any machine that can connect to other fluid based machines.
|
||||
|
@ -25,13 +25,13 @@ class NodeTank(parent: INodeProvider, buckets: Int) extends NodeFluidHandler(par
|
|||
nbt.setTag("tank", getPrimaryTank.writeToNBT(new NBTTagCompound))
|
||||
}
|
||||
|
||||
protected override def connect(obj: NodeFluidHandler, dir: ForgeDirection)
|
||||
override def connect[B <: IFluidHandler](obj: B, dir: ForgeDirection)
|
||||
{
|
||||
super.connect(obj, dir)
|
||||
|
||||
if (showConnectionsFor(obj, dir))
|
||||
{
|
||||
renderSides = WorldUtility.setEnableSide(getRenderSides, dir, true)
|
||||
renderSides = getRenderSides.openMask(dir)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,19 +3,18 @@ package resonantinduction.core.prefab.node
|
|||
import net.minecraft.block.material.Material
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
|
||||
/**
|
||||
* Created by robert on 8/15/2014.
|
||||
*/
|
||||
class TilePressureNode(material: Material) extends TileTankNode(material: Material) {
|
||||
|
||||
class TilePressureNode(material: Material) extends TileTankNode(material: Material)
|
||||
{
|
||||
//Constructor
|
||||
tankNode_$eq(new NodePressure(this))
|
||||
tankNode == new NodePressure(this)
|
||||
|
||||
def getPressureNode: NodePressure = {
|
||||
def getPressureNode: NodePressure =
|
||||
{
|
||||
return tankNode.asInstanceOf[NodePressure]
|
||||
}
|
||||
|
||||
def getPressure(direction: ForgeDirection): Int = {
|
||||
def getPressure(direction: ForgeDirection): Int =
|
||||
{
|
||||
return getPressureNode.getPressure(direction)
|
||||
}
|
||||
}
|
|
@ -7,10 +7,10 @@ import net.minecraft.entity.player.EntityPlayer
|
|||
import net.minecraft.nbt.NBTTagCompound
|
||||
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.network.discriminator.{PacketTile, PacketType}
|
||||
import resonant.lib.network.handle.TPacketIDReceiver
|
||||
import resonant.api.grid.{INodeProvider, INode}
|
||||
|
||||
/**
|
||||
* A prefab class for tiles that use the fluid network.
|
||||
|
@ -84,10 +84,11 @@ class TileTankNode(material: Material) extends TileAdvanced(material) with INode
|
|||
colorID = buf.readInt()
|
||||
renderSides = buf.readByte()
|
||||
}
|
||||
return false;
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
override def getNode(nodeType: Class[_ <: INode], from: ForgeDirection): INode = if (nodeType.isInstanceOf[NodeTank]) return tankNode else null
|
||||
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 = tankNode.drain(from, resource, doDrain)
|
||||
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
package resonantinduction.core.prefab.part.connector
|
||||
|
||||
import codechicken.multipart.TMultiPart
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import resonant.api.ISave
|
||||
import resonant.api.grid.{INodeProvider, INode}
|
||||
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.
|
||||
|
@ -51,10 +50,11 @@ trait TNodePartConnector extends PartAbstract with INodeProvider
|
|||
node.asInstanceOf[ISave].load(nbt)
|
||||
}
|
||||
|
||||
override def getNode(nodeType: Class[_ <: INode], from: ForgeDirection): INode =
|
||||
override def getNode[N <: INode](nodeType: Class[_ <: N], from: ForgeDirection): N =
|
||||
{
|
||||
if (nodeType.isAssignableFrom(node.getClass) || node.getClass == nodeType)
|
||||
return node
|
||||
return null
|
||||
return node.asInstanceOf[N]
|
||||
|
||||
return null.asInstanceOf[N]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,8 @@ import resonant.api.grid.INodeProvider;
|
|||
*/
|
||||
public class TNodeProvider extends TileMultipart implements INodeProvider
|
||||
{
|
||||
public INode getNode(Class<? extends INode> nodeType, ForgeDirection from)
|
||||
@Override
|
||||
public <N extends INode> N getNode(Class<? extends N> nodeType, ForgeDirection from)
|
||||
{
|
||||
TMultiPart nodePart = partMap(from.ordinal());
|
||||
|
||||
|
|
|
@ -6,20 +6,20 @@ 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.content.prefab.java.TileNode
|
||||
import resonant.lib.content.prefab.TElectric
|
||||
import resonant.lib.content.prefab.java.TileElectric
|
||||
import resonantinduction.core.interfaces.IMechanicalNode
|
||||
import resonant.api.grid.{NodeRegistry, IUpdate, INode}
|
||||
|
||||
/**
|
||||
* A kinetic energy to electrical energy converter.
|
||||
*
|
||||
* @author Calclavia
|
||||
*/
|
||||
class TileMotor extends TileNode(Material.iron) with TElectric with IRotatable {
|
||||
class TileMotor extends TileNode(Material.iron) with TElectric with IRotatable
|
||||
{
|
||||
|
||||
var mechNode : IMechanicalNode = NodeRegistry.get(this, classOf[IMechanicalNode])
|
||||
var mechNode: IMechanicalNode = NodeRegistry.get(this, classOf[IMechanicalNode])
|
||||
/** Generator turns KE -> EE. Inverted one will turn EE -> KE. */
|
||||
var isInversed: Boolean = true
|
||||
private var gearRatio: Byte = 0
|
||||
|
@ -28,90 +28,112 @@ class TileMotor extends TileNode(Material.iron) with TElectric with IRotatable {
|
|||
this.normalRender(false)
|
||||
this.isOpaqueCube(false)
|
||||
|
||||
def toggleGearRatio: Byte = {
|
||||
def toggleGearRatio: Byte =
|
||||
{
|
||||
return ((gearRatio + 1) % 3).asInstanceOf[Byte]
|
||||
}
|
||||
|
||||
override def start {
|
||||
override def start
|
||||
{
|
||||
super.start
|
||||
if (mechNode != null) mechNode.reconstruct
|
||||
}
|
||||
|
||||
override def invalidate {
|
||||
override def invalidate
|
||||
{
|
||||
mechNode.deconstruct
|
||||
super.invalidate
|
||||
}
|
||||
|
||||
override def update {
|
||||
override def update
|
||||
{
|
||||
super.update
|
||||
if (mechNode != null && mechNode.isInstanceOf[IUpdate]) {
|
||||
if (mechNode != null && mechNode.isInstanceOf[IUpdate])
|
||||
{
|
||||
mechNode.asInstanceOf[IUpdate].update(0.05f)
|
||||
if (!isInversed) {
|
||||
if (!isInversed)
|
||||
{
|
||||
receiveMechanical
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
produceMechanical
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def receiveMechanical {
|
||||
def receiveMechanical
|
||||
{
|
||||
val power: Double = mechNode.getForce(ForgeDirection.UNKNOWN) * mechNode.getAngularSpeed(ForgeDirection.UNKNOWN)
|
||||
val receive: Double =0// dcNode.addEnergy(ForgeDirection.UNKNOWN, power, true)
|
||||
if (receive > 0) {
|
||||
val receive: Double = 0 // dcNode.addEnergy(ForgeDirection.UNKNOWN, power, true)
|
||||
if (receive > 0)
|
||||
{
|
||||
val percentageUsed: Double = receive / power
|
||||
mechNode.apply(this, -mechNode.getForce(ForgeDirection.UNKNOWN) * percentageUsed, -mechNode.getAngularSpeed(ForgeDirection.UNKNOWN) * percentageUsed)
|
||||
}
|
||||
}
|
||||
|
||||
def produceMechanical {
|
||||
val extract: Double = 0//dcNode.removeEnergy(ForgeDirection.UNKNOWN, dcNode.getEnergy(ForgeDirection.UNKNOWN), false)
|
||||
if (extract > 0) {
|
||||
def produceMechanical
|
||||
{
|
||||
val extract: Double = 0 //dcNode.removeEnergy(ForgeDirection.UNKNOWN, dcNode.getEnergy(ForgeDirection.UNKNOWN), false)
|
||||
if (extract > 0)
|
||||
{
|
||||
val torqueRatio: Long = ((gearRatio + 1) / 2.2d * (extract)).asInstanceOf[Long]
|
||||
if (torqueRatio > 0) {
|
||||
if (torqueRatio > 0)
|
||||
{
|
||||
val maxAngularVelocity: Double = extract / torqueRatio.asInstanceOf[Float]
|
||||
val maxTorque: Double = (extract) / maxAngularVelocity
|
||||
var setAngularVelocity: Double = maxAngularVelocity
|
||||
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) }
|
||||
if (currentTorque != 0)
|
||||
{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))
|
||||
// dcNode.removeEnergy(ForgeDirection.UNKNOWN, Math.abs(setTorque * setAngularVelocity).asInstanceOf[Long], true)
|
||||
// dcNode.removeEnergy(ForgeDirection.UNKNOWN, Math.abs(setTorque * setAngularVelocity).asInstanceOf[Long], true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override def getInputDirections: HashSet[ForgeDirection] = {
|
||||
override def getInputDirections: HashSet[ForgeDirection] =
|
||||
{
|
||||
return getOutputDirections
|
||||
}
|
||||
|
||||
override def getOutputDirections: HashSet[ForgeDirection] = {
|
||||
override def getOutputDirections: HashSet[ForgeDirection] =
|
||||
{
|
||||
val dirs: HashSet[ForgeDirection] = new HashSet[ForgeDirection]
|
||||
for (dir <- ForgeDirection.VALID_DIRECTIONS) {
|
||||
for (dir <- ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if (dir != getDirection && dir != getDirection.getOpposite && dir != ForgeDirection.UNKNOWN) dirs.add(dir)
|
||||
}
|
||||
return dirs
|
||||
}
|
||||
|
||||
override def readFromNBT(nbt: NBTTagCompound) {
|
||||
override def readFromNBT(nbt: NBTTagCompound)
|
||||
{
|
||||
super.readFromNBT(nbt)
|
||||
isInversed = nbt.getBoolean("isInversed")
|
||||
gearRatio = nbt.getByte("gear")
|
||||
}
|
||||
|
||||
override def writeToNBT(nbt: NBTTagCompound) {
|
||||
override def writeToNBT(nbt: NBTTagCompound)
|
||||
{
|
||||
super.writeToNBT(nbt)
|
||||
nbt.setBoolean("isInversed", isInversed)
|
||||
nbt.setByte("gear", gearRatio)
|
||||
}
|
||||
|
||||
override def getNode(nodeType: Class[_ <: INode], from: ForgeDirection): INode = {
|
||||
if (from == getDirection || from == getDirection.getOpposite) {
|
||||
if (nodeType.isAssignableFrom(mechNode.getClass)) return mechNode
|
||||
override def getNode[N <: INode](nodeType: Class[_ <: N], from: ForgeDirection): N =
|
||||
{
|
||||
if (from == getDirection || from == getDirection.getOpposite)
|
||||
{
|
||||
if (nodeType.isAssignableFrom(mechNode.getClass))
|
||||
return mechNode.asInstanceOf[N]
|
||||
}
|
||||
return super.getNode(nodeType, from)
|
||||
|
||||
return null.asInstanceOf[N]
|
||||
}
|
||||
|
||||
override def getNodes(nodes: java.util.List[INode])
|
||||
|
@ -120,8 +142,8 @@ class TileMotor extends TileNode(Material.iron) with TElectric with IRotatable {
|
|||
nodes.add(this.dcNode)
|
||||
}
|
||||
|
||||
override def toString: String = {
|
||||
override def toString: String =
|
||||
{
|
||||
return "[TileMotor]" + x + "x " + y + "y " + z + "z "
|
||||
}
|
||||
|
||||
}
|
|
@ -8,10 +8,10 @@ import net.minecraft.item.ItemStack
|
|||
import net.minecraft.nbt.NBTTagCompound
|
||||
import net.minecraft.util.{ChatComponentText, MovingObjectPosition}
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import resonant.api.grid.{INode, INodeProvider}
|
||||
import resonant.lib.utility.WrenchUtility
|
||||
import resonantinduction.core.prefab.part.PartFace
|
||||
import resonantinduction.electrical.ElectricalContent
|
||||
import resonant.api.grid.{INodeProvider, INode}
|
||||
|
||||
/**
|
||||
* TODO: We can't use face parts, need to use thicker ones. Also, transformer is currently NO-OP
|
||||
|
@ -111,7 +111,7 @@ class PartElectricTransformer extends PartFace with INodeProvider
|
|||
return true
|
||||
}
|
||||
|
||||
override def getNode(nodeType: Class[_ <: INode], from: ForgeDirection): INode =
|
||||
override def getNode[N <: INode](nodeType: Class[_ <: N], from: ForgeDirection): N =
|
||||
{
|
||||
if (from == getAbsoluteFacing)
|
||||
{
|
||||
|
@ -122,6 +122,6 @@ class PartElectricTransformer extends PartFace with INodeProvider
|
|||
|
||||
}
|
||||
|
||||
return null;
|
||||
return null.asInstanceOf[N]
|
||||
}
|
||||
}
|
|
@ -12,17 +12,16 @@ 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.tileentity.TileEntity
|
||||
import net.minecraft.util.{IIcon, MovingObjectPosition}
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import org.lwjgl.opengl.GL11
|
||||
import resonant.api.grid.INodeProvider
|
||||
import resonant.lib.grid.node.DCNode
|
||||
import resonantinduction.core.prefab.node.TMultipartNode
|
||||
import resonantinduction.core.prefab.part.ChickenBonesWrapper._
|
||||
import resonantinduction.core.prefab.part.connector.PartAbstract
|
||||
import resonantinduction.core.util.MultipartUtil
|
||||
import resonantinduction.electrical.wire.base.TWire
|
||||
import resonant.api.grid.INodeProvider
|
||||
import resonant.lib.grid.node.DCNode
|
||||
|
||||
import scala.collection.convert.wrapAll._
|
||||
|
||||
|
@ -344,7 +343,7 @@ class PartFlatWire extends PartAbstract with TWire with TFacePart with TNormalOc
|
|||
* TODO: ForgeDirection may NOT be suitable. Integers are better.
|
||||
* @param provider
|
||||
*/
|
||||
class FlatWireNode(provider: INodeProvider) extends DCNode(provider) with TMultipartNode
|
||||
class FlatWireNode(provider: INodeProvider) extends DCNode(provider) with TMultipartNode[DCNode]
|
||||
{
|
||||
override def reconstruct()
|
||||
{
|
||||
|
@ -749,7 +748,7 @@ class PartFlatWire extends PartAbstract with TWire with TFacePart with TNormalOc
|
|||
if (canConnectTo(tp))
|
||||
{
|
||||
if (tp.isInstanceOf[PartFlatWire])
|
||||
return tp.asInstanceOf[PartFlatWire].getNode(classOf[FlatWireNode], null).asInstanceOf[FlatWireNode].connectInternal(PartFlatWire.this, side)
|
||||
return tp.asInstanceOf[PartFlatWire].getNode(classOf[FlatWireNode], null).connectInternal(PartFlatWire.this, side)
|
||||
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -7,12 +7,11 @@ import cpw.mods.fml.relauncher.{Side, SideOnly}
|
|||
import net.minecraft.client.renderer.RenderBlocks
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import resonant.lib.wrapper.BitmaskWrapper._
|
||||
import resonant.lib.grid.node.DCNode
|
||||
import resonantinduction.core.prefab.node.TMultipartNode
|
||||
import resonantinduction.core.prefab.part.connector.PartFramedNode
|
||||
import resonantinduction.electrical.wire.base.TWire
|
||||
import resonant.lib.grid.node.DCNode
|
||||
|
||||
import resonant.lib.wrapper.BitmaskWrapper._
|
||||
/**
|
||||
* Fluid transport pipe
|
||||
*
|
||||
|
@ -20,20 +19,20 @@ import resonant.lib.grid.node.DCNode
|
|||
*/
|
||||
class PartFramedWire extends PartFramedNode with TWire
|
||||
{
|
||||
override lazy val node = new DCNode(this) with TMultipartNode
|
||||
override lazy val node = new DCNode(this) with TMultipartNode[DCNode]
|
||||
{
|
||||
override def reconstruct()
|
||||
{
|
||||
val prevCon = connectionMask
|
||||
connectionMask = 0x00
|
||||
|
||||
super.reconstruct()
|
||||
super.reconstruct()
|
||||
|
||||
if (connectionMask != prevCon)
|
||||
sendConnectionUpdate()
|
||||
}
|
||||
|
||||
override protected def addConnection(obj: AnyRef, dir: ForgeDirection)
|
||||
override def connect[B <: DCNode](obj: B, dir: ForgeDirection) =
|
||||
{
|
||||
super.connect(obj, dir)
|
||||
connectionMask = connectionMask.openMask(dir)
|
||||
|
|
|
@ -12,7 +12,7 @@ import resonant.api.grid.INodeProvider
|
|||
*
|
||||
* @author Calclavia, Darkguardsman
|
||||
*/
|
||||
class PipePressureNode(parent: PartPipe) extends NodePressure(parent) with TMultipartNode
|
||||
class PipePressureNode(parent: PartPipe) extends NodePressure(parent) with TMultipartNode[IFluidHandler]
|
||||
{
|
||||
def pipe: PartPipe = getParent.asInstanceOf[PartPipe]
|
||||
|
||||
|
@ -38,13 +38,13 @@ class PipePressureNode(parent: PartPipe) extends NodePressure(parent) with TMult
|
|||
if (check.isInstanceOf[NodePressure] && canConnect(check,dir) && check.asInstanceOf[NodePressure].canConnect(this, dir.getOpposite))
|
||||
{
|
||||
pipe.connectionMask = pipe.connectionMask.openMask(dir)
|
||||
connections.put(check, dir)
|
||||
connect(check, dir)
|
||||
}
|
||||
}
|
||||
else if (canConnect(tile,dir))
|
||||
{
|
||||
pipe.connectionMask = pipe.connectionMask.openMask(dir)
|
||||
connections.put(tile, dir)
|
||||
connect(tile.asInstanceOf[IFluidHandler], dir)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,97 +5,98 @@ import net.minecraft.tileentity.TileEntity
|
|||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import net.minecraftforge.fluids.{Fluid, FluidStack, FluidTankInfo, IFluidHandler}
|
||||
import resonant.api.IRotatable
|
||||
import resonantinduction.mechanical.mech.TileMechanical
|
||||
import resonant.api.grid.INode
|
||||
import resonantinduction.mechanical.mech.TileMechanical
|
||||
|
||||
class TilePump extends TileMechanical(Material.iron) with IRotatable with IFluidHandler
|
||||
{
|
||||
var pressureNode : PumpNode = null
|
||||
var pressureNode: PumpNode = null
|
||||
|
||||
//Constructor
|
||||
normalRender(false)
|
||||
isOpaqueCube(false)
|
||||
customItemRender(true)
|
||||
setTextureName("material_steel")
|
||||
pressureNode = new PumpNode(this)
|
||||
//Constructor
|
||||
normalRender(false)
|
||||
isOpaqueCube(false)
|
||||
customItemRender(true)
|
||||
setTextureName("material_steel")
|
||||
pressureNode = new PumpNode(this)
|
||||
|
||||
override def start
|
||||
{
|
||||
pressureNode.reconstruct
|
||||
super.start
|
||||
}
|
||||
|
||||
override def start
|
||||
override def invalidate
|
||||
{
|
||||
super.invalidate
|
||||
pressureNode.deconstruct
|
||||
}
|
||||
|
||||
override def update
|
||||
{
|
||||
super.update
|
||||
if (!worldObj.isRemote && mechanicalNode.getPower > 0)
|
||||
{
|
||||
pressureNode.reconstruct
|
||||
super.start
|
||||
}
|
||||
|
||||
override def invalidate
|
||||
{
|
||||
super.invalidate
|
||||
pressureNode.deconstruct
|
||||
}
|
||||
|
||||
override def update
|
||||
{
|
||||
super.update
|
||||
if (!worldObj.isRemote && mechanicalNode.getPower > 0)
|
||||
val tileIn: TileEntity = asVector3.add(getDirection.getOpposite).getTileEntity(this.worldObj)
|
||||
if (tileIn.isInstanceOf[IFluidHandler])
|
||||
{
|
||||
val drain: FluidStack = (tileIn.asInstanceOf[IFluidHandler]).drain(getDirection, pressureNode.getCapacity, false)
|
||||
if (drain != null)
|
||||
{
|
||||
val tileIn: TileEntity = asVector3.add(getDirection.getOpposite).getTileEntity(this.worldObj)
|
||||
if (tileIn.isInstanceOf[IFluidHandler])
|
||||
{
|
||||
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)
|
||||
}
|
||||
}
|
||||
(tileIn.asInstanceOf[IFluidHandler]).drain(getDirection, fill(getDirection.getOpposite, drain, true), true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def fill(from: ForgeDirection, resource: FluidStack, doFill: Boolean): Int =
|
||||
def fill(from: ForgeDirection, resource: FluidStack, doFill: Boolean): Int =
|
||||
{
|
||||
if (from eq getDirection.getOpposite)
|
||||
{
|
||||
if (from eq getDirection.getOpposite)
|
||||
{
|
||||
val tileOut: TileEntity = asVector3.add(from.getOpposite).getTileEntity(this.worldObj)
|
||||
if (tileOut.isInstanceOf[IFluidHandler]) return (tileOut.asInstanceOf[IFluidHandler]).fill(from, resource, doFill)
|
||||
}
|
||||
return 0
|
||||
val tileOut: TileEntity = asVector3.add(from.getOpposite).getTileEntity(this.worldObj)
|
||||
if (tileOut.isInstanceOf[IFluidHandler]) return (tileOut.asInstanceOf[IFluidHandler]).fill(from, resource, doFill)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
def drain(from: ForgeDirection, resource: FluidStack, doDrain: Boolean): FluidStack =
|
||||
{
|
||||
return null
|
||||
}
|
||||
def drain(from: ForgeDirection, resource: FluidStack, doDrain: Boolean): FluidStack =
|
||||
{
|
||||
return null
|
||||
}
|
||||
|
||||
def drain(from: ForgeDirection, maxDrain: Int, doDrain: Boolean): FluidStack =
|
||||
{
|
||||
return null
|
||||
}
|
||||
def drain(from: ForgeDirection, maxDrain: Int, doDrain: Boolean): FluidStack =
|
||||
{
|
||||
return null
|
||||
}
|
||||
|
||||
def canFill(from: ForgeDirection, fluid: Fluid): Boolean =
|
||||
{
|
||||
return from eq this.getDirection.getOpposite
|
||||
}
|
||||
def canFill(from: ForgeDirection, fluid: Fluid): Boolean =
|
||||
{
|
||||
return from eq this.getDirection.getOpposite
|
||||
}
|
||||
|
||||
def canDrain(from: ForgeDirection, fluid: Fluid): Boolean =
|
||||
{
|
||||
return from eq this.getDirection
|
||||
}
|
||||
def canDrain(from: ForgeDirection, fluid: Fluid): Boolean =
|
||||
{
|
||||
return from eq this.getDirection
|
||||
}
|
||||
|
||||
def getTankInfo(from: ForgeDirection): Array[FluidTankInfo] =
|
||||
{
|
||||
return null
|
||||
}
|
||||
def getTankInfo(from: ForgeDirection): Array[FluidTankInfo] =
|
||||
{
|
||||
return null
|
||||
}
|
||||
|
||||
override def getNode(nodeType: Class[_ <: INode], from: ForgeDirection): INode =
|
||||
{
|
||||
if (nodeType.isAssignableFrom(pressureNode.getClass)) return pressureNode
|
||||
return super.getNode(nodeType, from)
|
||||
}
|
||||
override def getNode[N <: INode](nodeType: Class[_ <: N], from: ForgeDirection): N =
|
||||
{
|
||||
if (nodeType.isAssignableFrom(pressureNode.getClass))
|
||||
return pressureNode.asInstanceOf[N]
|
||||
|
||||
override def getDirection: ForgeDirection =
|
||||
{
|
||||
return null
|
||||
}
|
||||
return null.asInstanceOf[N]
|
||||
}
|
||||
|
||||
override def setDirection(direction: ForgeDirection)
|
||||
{
|
||||
}
|
||||
override def getDirection: ForgeDirection =
|
||||
{
|
||||
return null
|
||||
}
|
||||
|
||||
override def setDirection(direction: ForgeDirection)
|
||||
{
|
||||
}
|
||||
}
|
|
@ -102,8 +102,8 @@ public class DebugFrameMechanical extends FrameNodeDebug
|
|||
{
|
||||
if (getNode() != null && getNode().connections() != null)
|
||||
{
|
||||
ForgeDirection dir = (ForgeDirection) getNode().connections().values().toArray()[row];
|
||||
MechanicalNode node = (MechanicalNode) getNode().connections().keySet().toArray()[row];
|
||||
ForgeDirection dir = (ForgeDirection) getNode().directionMap().values().toArray()[row];
|
||||
MechanicalNode node = (MechanicalNode) getNode().directionMap().keySet().toArray()[row];
|
||||
switch(col)
|
||||
{
|
||||
case 0: return dir;
|
||||
|
|
|
@ -2,14 +2,14 @@ package resonantinduction.mechanical.mech;
|
|||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import resonant.lib.utility.nbt.ISaveObj;
|
||||
import resonantinduction.core.interfaces.IMechanicalNode;
|
||||
import resonantinduction.core.prefab.node.TMultipartNode;
|
||||
import resonant.api.grid.INode;
|
||||
import resonant.api.grid.INodeProvider;
|
||||
import resonant.api.grid.IUpdate;
|
||||
import resonant.lib.grid.node.NodeConnector;
|
||||
import resonant.lib.transform.vector.IVectorWorld;
|
||||
import resonant.lib.utility.nbt.ISaveObj;
|
||||
import resonantinduction.core.interfaces.IMechanicalNode;
|
||||
import resonantinduction.core.prefab.node.TMultipartNode;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
|
@ -20,7 +20,7 @@ import java.util.Map.Entry;
|
|||
* @author Calclavia, Darkguardsman
|
||||
*/
|
||||
//Don't convert to scala as this will find its way into RE later - From Darkguardsman
|
||||
public class MechanicalNode extends NodeConnector<MechanicalNode> implements TMultipartNode, IMechanicalNode, ISaveObj, IVectorWorld, IUpdate
|
||||
public class MechanicalNode extends NodeConnector<MechanicalNode> implements TMultipartNode<MechanicalNode>, IMechanicalNode, ISaveObj, IVectorWorld, IUpdate
|
||||
{
|
||||
/**
|
||||
* Marks that the rotation has changed and should be updated client side
|
||||
|
@ -164,14 +164,15 @@ public class MechanicalNode extends NodeConnector<MechanicalNode> implements TMu
|
|||
if (sharePower)
|
||||
{
|
||||
// Power sharing calculations
|
||||
Iterator<Entry<Object, ForgeDirection>> it = connections().entrySet().iterator();
|
||||
Iterator<Entry<MechanicalNode, ForgeDirection>> it = directionMap().entrySet().iterator();
|
||||
|
||||
while (it.hasNext())
|
||||
{
|
||||
MechanicalNode adjacentMech = null;
|
||||
Entry<Object, ForgeDirection> entry = it.next();
|
||||
Entry<MechanicalNode, ForgeDirection> entry = it.next();
|
||||
ForgeDirection dir = entry.getValue();
|
||||
|
||||
//TODO: Will never happen that it isn't a mech node.
|
||||
// Get mech node
|
||||
if (entry.getKey() instanceof MechanicalNode)
|
||||
{
|
||||
|
@ -332,10 +333,4 @@ public class MechanicalNode extends NodeConnector<MechanicalNode> implements TMu
|
|||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getConnectClass()
|
||||
{
|
||||
return getClass();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,207 +10,206 @@ import net.minecraft.item.ItemStack
|
|||
import net.minecraft.nbt.NBTTagCompound
|
||||
import net.minecraft.util.MovingObjectPosition
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import resonant.api.grid.{INode, INodeProvider}
|
||||
import resonant.engine.ResonantEngine
|
||||
import resonantinduction.core.prefab.part.connector.PartAbstract
|
||||
import resonant.api.grid.{INodeProvider, INode}
|
||||
import resonant.lib.transform.vector.VectorWorld
|
||||
import resonantinduction.core.prefab.part.connector.PartAbstract
|
||||
|
||||
/** We assume all the force acting on the gear is 90 degrees.
|
||||
*
|
||||
* @author Calclavia */
|
||||
abstract class PartMechanical extends PartAbstract with JNormalOcclusion with TFacePart with INodeProvider with TCuboidPart
|
||||
{
|
||||
/** Node that handles resonantinduction.mechanical action of the machine */
|
||||
var node: MechanicalNode = null
|
||||
protected var prevAngularVelocity: Double = .0
|
||||
/** Packets */
|
||||
private[mech] var markPacketUpdate: Boolean = false
|
||||
/** Simple debug external GUI */
|
||||
private[mech] var frame: DebugFrameMechanical = null
|
||||
/** Side of the block this is placed on */
|
||||
var placementSide: ForgeDirection = ForgeDirection.UNKNOWN
|
||||
var tier: Int = 0
|
||||
/** Node that handles resonantinduction.mechanical action of the machine */
|
||||
var mechanicalNode: MechanicalNode = null
|
||||
protected var prevAngularVelocity: Double = .0
|
||||
/** Packets */
|
||||
private[mech] var markPacketUpdate: Boolean = false
|
||||
/** Simple debug external GUI */
|
||||
private[mech] var frame: DebugFrameMechanical = null
|
||||
/** Side of the block this is placed on */
|
||||
var placementSide: ForgeDirection = ForgeDirection.UNKNOWN
|
||||
var tier: Int = 0
|
||||
|
||||
def preparePlacement(side: Int, itemDamage: Int)
|
||||
def preparePlacement(side: Int, itemDamage: Int)
|
||||
{
|
||||
this.placementSide = ForgeDirection.getOrientation((side).asInstanceOf[Byte])
|
||||
this.tier = itemDamage
|
||||
}
|
||||
|
||||
override def onNeighborChanged
|
||||
{
|
||||
super.onNeighborChanged
|
||||
mechanicalNode.reconstruct
|
||||
}
|
||||
|
||||
override def onPartChanged(part: TMultiPart)
|
||||
{
|
||||
super.onPartChanged(part)
|
||||
if (part.isInstanceOf[INodeProvider])
|
||||
{
|
||||
this.placementSide = ForgeDirection.getOrientation((side).asInstanceOf[Byte])
|
||||
this.tier = itemDamage
|
||||
mechanicalNode.reconstruct
|
||||
}
|
||||
}
|
||||
|
||||
override def onNeighborChanged
|
||||
override def update
|
||||
{
|
||||
this.mechanicalNode.update
|
||||
if (!world.isRemote)
|
||||
{
|
||||
super.onNeighborChanged
|
||||
node.reconstruct
|
||||
checkClientUpdate
|
||||
}
|
||||
|
||||
override def onPartChanged(part: TMultiPart)
|
||||
if (frame != null)
|
||||
{
|
||||
super.onPartChanged(part)
|
||||
if (part.isInstanceOf[INodeProvider])
|
||||
{
|
||||
node.reconstruct
|
||||
}
|
||||
frame.update
|
||||
}
|
||||
super.update
|
||||
}
|
||||
|
||||
override def update
|
||||
override def activate(player: EntityPlayer, hit: MovingObjectPosition, itemStack: ItemStack): Boolean =
|
||||
{
|
||||
if (ResonantEngine.runningAsDev)
|
||||
{
|
||||
this.node.update
|
||||
if (!world.isRemote)
|
||||
if (itemStack != null && !world.isRemote)
|
||||
{
|
||||
if (itemStack.getItem eq Items.stick)
|
||||
{
|
||||
checkClientUpdate
|
||||
}
|
||||
if (frame != null)
|
||||
{
|
||||
frame.update
|
||||
}
|
||||
super.update
|
||||
}
|
||||
|
||||
override def activate(player: EntityPlayer, hit: MovingObjectPosition, itemStack: ItemStack): Boolean =
|
||||
{
|
||||
if (ResonantEngine.runningAsDev)
|
||||
{
|
||||
if (itemStack != null && !world.isRemote)
|
||||
if (ControlKeyModifer.isControlDown(player))
|
||||
{
|
||||
if (frame == null)
|
||||
{
|
||||
if (itemStack.getItem eq Items.stick)
|
||||
{
|
||||
if (ControlKeyModifer.isControlDown(player))
|
||||
{
|
||||
if (frame == null)
|
||||
{
|
||||
frame = new DebugFrameMechanical(this)
|
||||
frame.showDebugFrame
|
||||
}
|
||||
else
|
||||
{
|
||||
frame.closeDebugFrame
|
||||
frame = null
|
||||
}
|
||||
}
|
||||
}
|
||||
frame = new DebugFrameMechanical(this)
|
||||
frame.showDebugFrame
|
||||
}
|
||||
else
|
||||
{
|
||||
frame.closeDebugFrame
|
||||
frame = null
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.activate(player, hit, itemStack)
|
||||
}
|
||||
}
|
||||
return super.activate(player, hit, itemStack)
|
||||
}
|
||||
|
||||
def checkClientUpdate
|
||||
def checkClientUpdate
|
||||
{
|
||||
if (Math.abs(prevAngularVelocity - mechanicalNode.angularVelocity) >= 0.1)
|
||||
{
|
||||
if (Math.abs(prevAngularVelocity - node.angularVelocity) >= 0.1)
|
||||
{
|
||||
prevAngularVelocity = node.angularVelocity
|
||||
sendRotationPacket
|
||||
}
|
||||
prevAngularVelocity = mechanicalNode.angularVelocity
|
||||
sendRotationPacket
|
||||
}
|
||||
}
|
||||
|
||||
def getNode(nodeType: Class[_ <: INode], from: ForgeDirection): INode =
|
||||
override def getNode[N <: INode](nodeType: Class[_ <: N], from: ForgeDirection): N =
|
||||
{
|
||||
if (classOf[MechanicalNode].isAssignableFrom(nodeType))
|
||||
return mechanicalNode.asInstanceOf[N]
|
||||
|
||||
return null.asInstanceOf[N]
|
||||
}
|
||||
|
||||
override def onWorldJoin
|
||||
{
|
||||
mechanicalNode.reconstruct
|
||||
}
|
||||
|
||||
override def onWorldSeparate
|
||||
{
|
||||
mechanicalNode.deconstruct
|
||||
if (frame != null)
|
||||
{
|
||||
if (nodeType.isAssignableFrom(node.getClass))
|
||||
{
|
||||
return node
|
||||
}
|
||||
return null
|
||||
frame.closeDebugFrame
|
||||
}
|
||||
}
|
||||
|
||||
override def onWorldJoin
|
||||
/** Packet Code. */
|
||||
def sendRotationPacket
|
||||
{
|
||||
if (world != null && !world.isRemote)
|
||||
{
|
||||
node.reconstruct
|
||||
getWriteStream.writeByte(1).writeDouble(mechanicalNode.angularVelocity)
|
||||
}
|
||||
}
|
||||
|
||||
override def onWorldSeparate
|
||||
/** Packet Code. */
|
||||
override def read(packet: MCDataInput)
|
||||
{
|
||||
read(packet, packet.readUByte)
|
||||
}
|
||||
|
||||
override def read(packet: MCDataInput, packetID: Int)
|
||||
{
|
||||
if (packetID == 0)
|
||||
{
|
||||
node.deconstruct
|
||||
if (frame != null)
|
||||
{
|
||||
frame.closeDebugFrame
|
||||
}
|
||||
load(packet.readNBTTagCompound)
|
||||
}
|
||||
|
||||
/** Packet Code. */
|
||||
def sendRotationPacket
|
||||
else if (packetID == 1)
|
||||
{
|
||||
if (world != null && !world.isRemote)
|
||||
{
|
||||
getWriteStream.writeByte(1).writeDouble(node.angularVelocity)
|
||||
}
|
||||
mechanicalNode.angularVelocity = packet.readDouble
|
||||
}
|
||||
}
|
||||
|
||||
/** Packet Code. */
|
||||
override def read(packet: MCDataInput)
|
||||
{
|
||||
read(packet, packet.readUByte)
|
||||
}
|
||||
override def readDesc(packet: MCDataInput)
|
||||
{
|
||||
packet.readByte
|
||||
load(packet.readNBTTagCompound)
|
||||
}
|
||||
|
||||
override def read(packet: MCDataInput, packetID: Int)
|
||||
{
|
||||
if (packetID == 0)
|
||||
{
|
||||
load(packet.readNBTTagCompound)
|
||||
}
|
||||
else if (packetID == 1)
|
||||
{
|
||||
node.angularVelocity = packet.readDouble
|
||||
}
|
||||
}
|
||||
override def writeDesc(packet: MCDataOutput)
|
||||
{
|
||||
packet.writeByte(0)
|
||||
val nbt: NBTTagCompound = new NBTTagCompound
|
||||
save(nbt)
|
||||
packet.writeNBTTagCompound(nbt)
|
||||
}
|
||||
|
||||
override def readDesc(packet: MCDataInput)
|
||||
{
|
||||
packet.readByte
|
||||
load(packet.readNBTTagCompound)
|
||||
}
|
||||
override def redstoneConductionMap: Int =
|
||||
{
|
||||
return 0
|
||||
}
|
||||
|
||||
override def writeDesc(packet: MCDataOutput)
|
||||
{
|
||||
packet.writeByte(0)
|
||||
val nbt: NBTTagCompound = new NBTTagCompound
|
||||
save(nbt)
|
||||
packet.writeNBTTagCompound(nbt)
|
||||
}
|
||||
override def solid(arg0: Int): Boolean =
|
||||
{
|
||||
return true
|
||||
}
|
||||
|
||||
override def redstoneConductionMap: Int =
|
||||
{
|
||||
return 0
|
||||
}
|
||||
override def load(nbt: NBTTagCompound)
|
||||
{
|
||||
placementSide = ForgeDirection.getOrientation(nbt.getByte("side"))
|
||||
tier = nbt.getByte("tier")
|
||||
mechanicalNode.load(nbt)
|
||||
}
|
||||
|
||||
override def solid(arg0: Int): Boolean =
|
||||
{
|
||||
return true
|
||||
}
|
||||
override def save(nbt: NBTTagCompound)
|
||||
{
|
||||
nbt.setByte("side", placementSide.ordinal.asInstanceOf[Byte])
|
||||
nbt.setByte("tier", tier.asInstanceOf[Byte])
|
||||
mechanicalNode.save(nbt)
|
||||
}
|
||||
|
||||
override def load(nbt: NBTTagCompound)
|
||||
{
|
||||
placementSide = ForgeDirection.getOrientation(nbt.getByte("side"))
|
||||
tier = nbt.getByte("tier")
|
||||
node.load(nbt)
|
||||
}
|
||||
protected def getItem: ItemStack
|
||||
|
||||
override def save(nbt: NBTTagCompound)
|
||||
{
|
||||
nbt.setByte("side", placementSide.ordinal.asInstanceOf[Byte])
|
||||
nbt.setByte("tier", tier.asInstanceOf[Byte])
|
||||
node.save(nbt)
|
||||
}
|
||||
override def getDrops: java.lang.Iterable[ItemStack] =
|
||||
{
|
||||
val drops: List[ItemStack] = new ArrayList[ItemStack]
|
||||
drops.add(getItem)
|
||||
return drops
|
||||
}
|
||||
|
||||
protected def getItem: ItemStack
|
||||
override def pickItem(hit: MovingObjectPosition): ItemStack =
|
||||
{
|
||||
return getItem
|
||||
}
|
||||
|
||||
override def getDrops: java.lang.Iterable[ItemStack] =
|
||||
{
|
||||
val drops: List[ItemStack] = new ArrayList[ItemStack]
|
||||
drops.add(getItem)
|
||||
return drops
|
||||
}
|
||||
def getPosition: VectorWorld =
|
||||
{
|
||||
return new VectorWorld(world, x, y, z)
|
||||
}
|
||||
|
||||
override def pickItem(hit: MovingObjectPosition): ItemStack =
|
||||
{
|
||||
return getItem
|
||||
}
|
||||
|
||||
def getPosition: VectorWorld =
|
||||
{
|
||||
return new VectorWorld(world, x, y, z)
|
||||
}
|
||||
|
||||
override def toString: String =
|
||||
{
|
||||
return "[" + getClass.getSimpleName + "]" + x + "x " + y + "y " + z + "z " + getSlotMask + "s "
|
||||
}
|
||||
override def toString: String =
|
||||
{
|
||||
return "[" + getClass.getSimpleName + "]" + x + "x " + y + "y " + z + "z " + getSlotMask + "s "
|
||||
}
|
||||
}
|
|
@ -10,11 +10,11 @@ import net.minecraft.item.ItemStack
|
|||
import net.minecraft.nbt.NBTTagCompound
|
||||
import net.minecraft.network.Packet
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import resonant.api.grid.{INode, INodeProvider}
|
||||
import resonant.content.prefab.java.TileNode
|
||||
import resonant.engine.ResonantEngine
|
||||
import resonant.lib.network.discriminator.{PacketTile, PacketType}
|
||||
import resonant.lib.network.handle.IPacketIDReceiver
|
||||
import resonant.api.grid.{INodeProvider, INode}
|
||||
import resonant.lib.transform.vector.Vector3
|
||||
|
||||
/** Prefab for resonantinduction.mechanical tiles
|
||||
|
@ -22,114 +22,116 @@ import resonant.lib.transform.vector.Vector3
|
|||
* @author Calclavia */
|
||||
abstract class TileMechanical(material: Material) extends TileNode(material) with INodeProvider with IPacketIDReceiver
|
||||
{
|
||||
/** Internal packet ID for NBTTagCompound parsing from packets */
|
||||
protected var nbt_packet_id: Int = 0
|
||||
/** Internal packet ID for rotation and velocity */
|
||||
protected var vel_packet_id: Int = 1
|
||||
/** Internal packet ID for NBTTagCompound parsing from packets */
|
||||
protected var nbt_packet_id: Int = 0
|
||||
/** Internal packet ID for rotation and velocity */
|
||||
protected var vel_packet_id: Int = 1
|
||||
|
||||
/** Node that handles most mechanical actions */
|
||||
var mechanicalNode: MechanicalNode = new MechanicalNode(this)
|
||||
/** External debug GUI */
|
||||
var frame: DebugFrameMechanical = null
|
||||
/** Node that handles most mechanical actions */
|
||||
var mechanicalNode: MechanicalNode = new MechanicalNode(this)
|
||||
/** External debug GUI */
|
||||
var frame: DebugFrameMechanical = null
|
||||
|
||||
|
||||
override def update
|
||||
override def update
|
||||
{
|
||||
super.update
|
||||
if (frame != null)
|
||||
{
|
||||
super.update
|
||||
if (frame != null)
|
||||
frame.update
|
||||
if (!frame.isVisible)
|
||||
{
|
||||
frame.dispose
|
||||
frame = null
|
||||
}
|
||||
}
|
||||
if (!this.getWorldObj.isRemote)
|
||||
{
|
||||
if (ticks % 3 == 0 && (mechanicalNode.markTorqueUpdate || mechanicalNode.markRotationUpdate))
|
||||
{
|
||||
sendRotationPacket
|
||||
mechanicalNode.markRotationUpdate = false
|
||||
mechanicalNode.markTorqueUpdate = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override def use(player: EntityPlayer, side: Int, hit: Vector3): Boolean =
|
||||
{
|
||||
val itemStack: ItemStack = player.getHeldItem
|
||||
if (ResonantEngine.runningAsDev)
|
||||
{
|
||||
if (itemStack != null && !world.isRemote)
|
||||
{
|
||||
if (itemStack.getItem eq Items.stick)
|
||||
{
|
||||
frame.update
|
||||
if (!frame.isVisible)
|
||||
if (ControlKeyModifer.isControlDown(player))
|
||||
{
|
||||
if (frame == null)
|
||||
{
|
||||
frame.dispose
|
||||
frame = null
|
||||
}
|
||||
}
|
||||
if (!this.getWorldObj.isRemote)
|
||||
{
|
||||
if (ticks % 3 == 0 && (mechanicalNode.markTorqueUpdate || mechanicalNode.markRotationUpdate))
|
||||
{
|
||||
sendRotationPacket
|
||||
mechanicalNode.markRotationUpdate = false
|
||||
mechanicalNode.markTorqueUpdate = false
|
||||
frame = new DebugFrameMechanical(this)
|
||||
frame.showDebugFrame
|
||||
}
|
||||
else
|
||||
{
|
||||
frame.closeDebugFrame
|
||||
frame = null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
override def use(player: EntityPlayer, side: Int, hit: Vector3): Boolean =
|
||||
{
|
||||
val itemStack: ItemStack = player.getHeldItem
|
||||
if (ResonantEngine.runningAsDev)
|
||||
{
|
||||
if (itemStack != null && !world.isRemote)
|
||||
{
|
||||
if (itemStack.getItem eq Items.stick)
|
||||
{
|
||||
if (ControlKeyModifer.isControlDown(player))
|
||||
{
|
||||
if (frame == null)
|
||||
{
|
||||
frame = new DebugFrameMechanical(this)
|
||||
frame.showDebugFrame
|
||||
}
|
||||
else
|
||||
{
|
||||
frame.closeDebugFrame
|
||||
frame = null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
override def getNode[N <: INode](nodeType: Class[_ <: N], from: ForgeDirection): N =
|
||||
{
|
||||
if (classOf[MechanicalNode].isAssignableFrom(nodeType))
|
||||
return mechanicalNode.asInstanceOf[N]
|
||||
|
||||
override def getNode(nodeType: Class[_ <: INode], from: ForgeDirection): INode =
|
||||
{
|
||||
return mechanicalNode
|
||||
}
|
||||
return null.asInstanceOf[N]
|
||||
}
|
||||
|
||||
override def getDescriptionPacket: Packet =
|
||||
{
|
||||
val tag: NBTTagCompound = new NBTTagCompound
|
||||
writeToNBT(tag)
|
||||
return ResonantEngine.instance.packetHandler.toMCPacket(new PacketTile(xi, yi, zi, Array(nbt_packet_id, tag)))
|
||||
}
|
||||
override def getDescriptionPacket: Packet =
|
||||
{
|
||||
val tag: NBTTagCompound = new NBTTagCompound
|
||||
writeToNBT(tag)
|
||||
return ResonantEngine.instance.packetHandler.toMCPacket(new PacketTile(xi, yi, zi, Array(nbt_packet_id, tag)))
|
||||
}
|
||||
|
||||
/** Sends the torque and angular velocity to the client */
|
||||
private def sendRotationPacket
|
||||
{
|
||||
ResonantEngine.instance.packetHandler.sendToAllAround(new PacketTile(xi, yi , zi, Array(vel_packet_id, mechanicalNode.angularVelocity, mechanicalNode.torque)), this)
|
||||
}
|
||||
/** Sends the torque and angular velocity to the client */
|
||||
private def sendRotationPacket
|
||||
{
|
||||
ResonantEngine.instance.packetHandler.sendToAllAround(new PacketTile(xi, yi, zi, Array(vel_packet_id, mechanicalNode.angularVelocity, mechanicalNode.torque)), this)
|
||||
}
|
||||
|
||||
override def read(data: ByteBuf, id: Int, player: EntityPlayer, `type`: PacketType): Boolean =
|
||||
override def read(data: ByteBuf, id: Int, player: EntityPlayer, `type`: PacketType): Boolean =
|
||||
{
|
||||
if (world.isRemote)
|
||||
{
|
||||
if (world.isRemote)
|
||||
{
|
||||
if (id == nbt_packet_id)
|
||||
{
|
||||
readFromNBT(ByteBufUtils.readTag(data))
|
||||
return true
|
||||
}
|
||||
else if (id == vel_packet_id)
|
||||
{
|
||||
mechanicalNode.angularVelocity = data.readDouble
|
||||
mechanicalNode.torque = data.readDouble
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
if (id == nbt_packet_id)
|
||||
{
|
||||
readFromNBT(ByteBufUtils.readTag(data))
|
||||
return true
|
||||
}
|
||||
else if (id == vel_packet_id)
|
||||
{
|
||||
mechanicalNode.angularVelocity = data.readDouble
|
||||
mechanicalNode.torque = data.readDouble
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
override def readFromNBT(nbt: NBTTagCompound)
|
||||
{
|
||||
super.readFromNBT(nbt)
|
||||
mechanicalNode.load(nbt)
|
||||
}
|
||||
override def readFromNBT(nbt: NBTTagCompound)
|
||||
{
|
||||
super.readFromNBT(nbt)
|
||||
mechanicalNode.load(nbt)
|
||||
}
|
||||
|
||||
override def writeToNBT(nbt: NBTTagCompound)
|
||||
{
|
||||
super.writeToNBT(nbt)
|
||||
mechanicalNode.save(nbt)
|
||||
}
|
||||
override def writeToNBT(nbt: NBTTagCompound)
|
||||
{
|
||||
super.writeToNBT(nbt)
|
||||
mechanicalNode.save(nbt)
|
||||
}
|
||||
}
|
|
@ -81,7 +81,7 @@ class GearNode(parent: PartGear) extends MechanicalNode(parent: PartGear)
|
|||
if (tile.isInstanceOf[INodeProvider])
|
||||
{
|
||||
val instance: MechanicalNode = (tile.asInstanceOf[INodeProvider]).getNode(classOf[MechanicalNode], if (checkDir eq gear.placementSide.getOpposite) ForgeDirection.UNKNOWN else checkDir).asInstanceOf[MechanicalNode]
|
||||
if (!connections.containsValue(checkDir) && instance != this && checkDir != gear.placementSide && instance != null && instance.canConnect(this,checkDir.getOpposite))
|
||||
if (!directionMap.containsValue(checkDir) && instance != this && checkDir != gear.placementSide && instance != null && instance.canConnect(this,checkDir.getOpposite))
|
||||
{
|
||||
connect(instance, checkDir)
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ class GearNode(parent: PartGear) extends MechanicalNode(parent: PartGear)
|
|||
{
|
||||
val checkDir: ForgeDirection = ForgeDirection.getOrientation(Rotation.rotateSide(gear.placementSide.ordinal, i))
|
||||
val checkTile: TileEntity = new Vector3(gear.tile).add(checkDir).getTileEntity(world)
|
||||
if (!connections.containsValue(checkDir) && checkTile.isInstanceOf[INodeProvider])
|
||||
if (!directionMap.containsValue(checkDir) && checkTile.isInstanceOf[INodeProvider])
|
||||
{
|
||||
val instance: MechanicalNode = (checkTile.asInstanceOf[INodeProvider]).getNode(classOf[MechanicalNode], gear.placementSide).asInstanceOf[MechanicalNode]
|
||||
if (instance != null && instance != this && instance.canConnect(this,checkDir.getOpposite) && !(instance.getParent.isInstanceOf[PartGearShaft]))
|
||||
|
|
|
@ -12,194 +12,192 @@ import net.minecraft.nbt.NBTTagCompound
|
|||
import net.minecraft.util.MovingObjectPosition
|
||||
import net.minecraft.world.World
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import resonant.api.grid.INode
|
||||
import resonant.lib.multiblock.reference.IMultiBlockStructure
|
||||
import resonant.lib.transform.vector.VectorWorld
|
||||
import resonant.lib.utility.WrenchUtility
|
||||
import resonantinduction.core.Reference
|
||||
import resonantinduction.core.prefab.part.CuboidShapes
|
||||
import resonantinduction.mechanical.MechanicalContent
|
||||
import resonantinduction.mechanical.mech.PartMechanical
|
||||
import resonant.api.grid.INode
|
||||
import resonant.lib.transform.vector.VectorWorld
|
||||
|
||||
/** We assume all the force acting on the gear is 90 degrees.
|
||||
*
|
||||
* @author Calclavia */
|
||||
/**
|
||||
* We assume all the force acting on the gear is 90 degrees.
|
||||
*
|
||||
* @author Calclavia
|
||||
*/
|
||||
class PartGear extends PartMechanical with IMultiBlockStructure[PartGear]
|
||||
{
|
||||
var isClockwiseCrank: Boolean = true
|
||||
var manualCrankTime: Int = 0
|
||||
var multiBlockRadius: Int = 1
|
||||
/** Multiblock */
|
||||
var multiBlock: GearMultiBlockHandler = null
|
||||
var isClockwiseCrank: Boolean = true
|
||||
var manualCrankTime: Int = 0
|
||||
var multiBlockRadius: Int = 1
|
||||
/** Multiblock */
|
||||
var multiBlock: GearMultiBlockHandler = null
|
||||
|
||||
//Constructor
|
||||
node = new GearNode(this)
|
||||
//Constructor
|
||||
mechanicalNode = new GearNode(this)
|
||||
|
||||
override def update
|
||||
override def update
|
||||
{
|
||||
super.update
|
||||
if (!this.world.isRemote)
|
||||
{
|
||||
super.update
|
||||
if (!this.world.isRemote)
|
||||
{
|
||||
if (manualCrankTime > 0)
|
||||
{
|
||||
node.apply(this, if (isClockwiseCrank) 15 else -15, if (isClockwiseCrank) 0.025f else -0.025f)
|
||||
manualCrankTime -= 1
|
||||
}
|
||||
}
|
||||
getMultiBlock.update
|
||||
if (manualCrankTime > 0)
|
||||
{
|
||||
mechanicalNode.apply(this, if (isClockwiseCrank) 15 else -15, if (isClockwiseCrank) 0.025f else -0.025f)
|
||||
manualCrankTime -= 1
|
||||
}
|
||||
}
|
||||
getMultiBlock.update
|
||||
}
|
||||
|
||||
override def checkClientUpdate
|
||||
{
|
||||
if (getMultiBlock.isPrimary) super.checkClientUpdate
|
||||
}
|
||||
override def checkClientUpdate
|
||||
{
|
||||
if (getMultiBlock.isPrimary) super.checkClientUpdate
|
||||
}
|
||||
|
||||
override def activate(player: EntityPlayer, hit: MovingObjectPosition, itemStack: ItemStack): Boolean =
|
||||
override def activate(player: EntityPlayer, hit: MovingObjectPosition, itemStack: ItemStack): Boolean =
|
||||
{
|
||||
if (itemStack != null && itemStack.getItem.isInstanceOf[ItemHandCrank])
|
||||
{
|
||||
if (itemStack != null && itemStack.getItem.isInstanceOf[ItemHandCrank])
|
||||
{
|
||||
if (!world.isRemote && ControlKeyModifer.isControlDown(player))
|
||||
{
|
||||
getMultiBlock.get.node.torque = -getMultiBlock.get.node.torque
|
||||
getMultiBlock.get.node.angularVelocity = -getMultiBlock.get.node.angularVelocity
|
||||
return true
|
||||
}
|
||||
isClockwiseCrank = player.isSneaking
|
||||
//TODO fix;
|
||||
// getMultiBlock.get.manualCrankTime = 20
|
||||
world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, Reference.prefix + "gearCrank", 0.5f, 0.9f + world.rand.nextFloat * 0.2f)
|
||||
player.addExhaustion(0.01f)
|
||||
return true
|
||||
}
|
||||
if (WrenchUtility.isWrench(itemStack))
|
||||
{
|
||||
getMultiBlock.toggleConstruct
|
||||
return true
|
||||
}
|
||||
return super.activate(player, hit, itemStack)
|
||||
if (!world.isRemote && ControlKeyModifer.isControlDown(player))
|
||||
{
|
||||
getMultiBlock.get.mechanicalNode.torque = -getMultiBlock.get.mechanicalNode.torque
|
||||
getMultiBlock.get.mechanicalNode.angularVelocity = -getMultiBlock.get.mechanicalNode.angularVelocity
|
||||
return true
|
||||
}
|
||||
isClockwiseCrank = player.isSneaking
|
||||
//TODO fix;
|
||||
// getMultiBlock.get.manualCrankTime = 20
|
||||
world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, Reference.prefix + "gearCrank", 0.5f, 0.9f + world.rand.nextFloat * 0.2f)
|
||||
player.addExhaustion(0.01f)
|
||||
return true
|
||||
}
|
||||
if (WrenchUtility.isWrench(itemStack))
|
||||
{
|
||||
getMultiBlock.toggleConstruct
|
||||
return true
|
||||
}
|
||||
return super.activate(player, hit, itemStack)
|
||||
}
|
||||
|
||||
override def preRemove
|
||||
{
|
||||
super.preRemove
|
||||
getMultiBlock.deconstruct
|
||||
}
|
||||
override def preRemove
|
||||
{
|
||||
super.preRemove
|
||||
getMultiBlock.deconstruct
|
||||
}
|
||||
|
||||
/** Is this gear block the one in the center-edge of the multiblock that can interact with other
|
||||
* gears?
|
||||
*
|
||||
* @return */
|
||||
def isCenterMultiBlock: Boolean =
|
||||
/** Is this gear block the one in the center-edge of the multiblock that can interact with other
|
||||
* gears?
|
||||
*
|
||||
* @return */
|
||||
def isCenterMultiBlock: Boolean =
|
||||
{
|
||||
if (!getMultiBlock.isConstructed)
|
||||
{
|
||||
if (!getMultiBlock.isConstructed)
|
||||
{
|
||||
return true
|
||||
}
|
||||
val primaryPos: VectorWorld = getMultiBlock.getPrimary.getPosition
|
||||
if (primaryPos.xi == x && placementSide.offsetX == 0)
|
||||
{
|
||||
return true
|
||||
}
|
||||
if (primaryPos.yi == y && placementSide.offsetY == 0)
|
||||
{
|
||||
return true
|
||||
}
|
||||
if (primaryPos.zi == z && placementSide.offsetZ == 0)
|
||||
{
|
||||
return true
|
||||
}
|
||||
return false
|
||||
return true
|
||||
}
|
||||
val primaryPos: VectorWorld = getMultiBlock.getPrimary.getPosition
|
||||
if (primaryPos.xi == x && placementSide.offsetX == 0)
|
||||
{
|
||||
return true
|
||||
}
|
||||
if (primaryPos.yi == y && placementSide.offsetY == 0)
|
||||
{
|
||||
return true
|
||||
}
|
||||
if (primaryPos.zi == z && placementSide.offsetZ == 0)
|
||||
{
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
protected def getItem: ItemStack =
|
||||
{
|
||||
return new ItemStack(MechanicalContent.itemGear, 1, tier)
|
||||
}
|
||||
protected def getItem: ItemStack =
|
||||
{
|
||||
return new ItemStack(MechanicalContent.itemGear, 1, tier)
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT) override def renderDynamic(pos: Vector3, frame: Float, pass: Int)
|
||||
@SideOnly(Side.CLIENT) override def renderDynamic(pos: Vector3, frame: Float, pass: Int)
|
||||
{
|
||||
if (pass == 0)
|
||||
{
|
||||
if (pass == 0)
|
||||
{
|
||||
RenderGear.INSTANCE.renderDynamic(this, pos.x, pos.y, pos.z, tier)
|
||||
}
|
||||
RenderGear.INSTANCE.renderDynamic(this, pos.x, pos.y, pos.z, tier)
|
||||
}
|
||||
}
|
||||
|
||||
override def load(nbt: NBTTagCompound)
|
||||
{
|
||||
super.load(nbt)
|
||||
getMultiBlock.load(nbt)
|
||||
}
|
||||
override def load(nbt: NBTTagCompound)
|
||||
{
|
||||
super.load(nbt)
|
||||
getMultiBlock.load(nbt)
|
||||
}
|
||||
|
||||
override def save(nbt: NBTTagCompound)
|
||||
{
|
||||
super.save(nbt)
|
||||
getMultiBlock.save(nbt)
|
||||
}
|
||||
override def save(nbt: NBTTagCompound)
|
||||
{
|
||||
super.save(nbt)
|
||||
getMultiBlock.save(nbt)
|
||||
}
|
||||
|
||||
override def getMultiBlockVectors: java.util.List[resonant.lib.transform.vector.Vector3] =
|
||||
{
|
||||
val vec = new resonant.lib.transform.vector.Vector3(this.x, this.y, this.z)
|
||||
var array: java.util.List[resonant.lib.transform.vector.Vector3] = vec.getAround(this.world, placementSide, 1)
|
||||
return array
|
||||
}
|
||||
override def getMultiBlockVectors: java.util.List[resonant.lib.transform.vector.Vector3] =
|
||||
{
|
||||
val vec = new resonant.lib.transform.vector.Vector3(this.x, this.y, this.z)
|
||||
var array: java.util.List[resonant.lib.transform.vector.Vector3] = vec.getAround(this.world, placementSide, 1)
|
||||
return array
|
||||
}
|
||||
|
||||
def getWorld: World =
|
||||
{
|
||||
return world
|
||||
}
|
||||
def getWorld: World =
|
||||
{
|
||||
return world
|
||||
}
|
||||
|
||||
def onMultiBlockChanged
|
||||
def onMultiBlockChanged
|
||||
{
|
||||
if (world != null)
|
||||
{
|
||||
if (world != null)
|
||||
{
|
||||
tile.notifyPartChange(this)
|
||||
if (!world.isRemote)
|
||||
{
|
||||
sendDescUpdate
|
||||
}
|
||||
}
|
||||
tile.notifyPartChange(this)
|
||||
if (!world.isRemote)
|
||||
{
|
||||
sendDescUpdate
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def getMultiBlock: GearMultiBlockHandler =
|
||||
{
|
||||
if (multiBlock == null) multiBlock = new GearMultiBlockHandler(this)
|
||||
return multiBlock
|
||||
}
|
||||
def getMultiBlock: GearMultiBlockHandler =
|
||||
{
|
||||
if (multiBlock == null) multiBlock = new GearMultiBlockHandler(this)
|
||||
return multiBlock
|
||||
}
|
||||
|
||||
override def getNode(nodeType: Class[_ <: INode], from: ForgeDirection): INode =
|
||||
{
|
||||
if (nodeType.isAssignableFrom(node.getClass)) return getMultiBlock.get.node
|
||||
return null
|
||||
}
|
||||
override def getNode[N <: INode](nodeType: Class[_ <: N], from: ForgeDirection): N =
|
||||
{
|
||||
if (nodeType.isAssignableFrom(mechanicalNode.getClass))
|
||||
return getMultiBlock.get.mechanicalNode.asInstanceOf[N]
|
||||
|
||||
/** Multipart Bounds */
|
||||
def getOcclusionBoxes: java.lang.Iterable[Cuboid6] =
|
||||
{
|
||||
val list: java.util.List[Cuboid6] = new util.ArrayList[Cuboid6];
|
||||
for (v <- CuboidShapes.PANEL(this.placementSide.ordinal))
|
||||
{
|
||||
list.add(v)
|
||||
}
|
||||
return list
|
||||
}
|
||||
return null.asInstanceOf[N]
|
||||
}
|
||||
|
||||
def getSlotMask: Int =
|
||||
/** Multipart Bounds */
|
||||
def getOcclusionBoxes: java.lang.Iterable[Cuboid6] =
|
||||
{
|
||||
val list: java.util.List[Cuboid6] = new util.ArrayList[Cuboid6];
|
||||
for (v <- CuboidShapes.PANEL(this.placementSide.ordinal))
|
||||
{
|
||||
return 1 << this.placementSide.ordinal
|
||||
list.add(v)
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
def getBounds: Cuboid6 =
|
||||
{
|
||||
return FaceMicroClass.aBounds(0x10 | this.placementSide.ordinal)
|
||||
}
|
||||
def getSlotMask: Int =
|
||||
{
|
||||
return 1 << this.placementSide.ordinal
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT) override def getRenderBounds: Cuboid6 =
|
||||
{
|
||||
return Cuboid6.full.copy.expand(multiBlockRadius)
|
||||
}
|
||||
def getBounds: Cuboid6 =
|
||||
{
|
||||
return FaceMicroClass.aBounds(0x10 | this.placementSide.ordinal)
|
||||
}
|
||||
|
||||
override def toString: java.lang.String =
|
||||
{
|
||||
return "[PartGear]" + x + "x " + y + "y " + z + "z " + getSlotMask + "s "
|
||||
}
|
||||
@SideOnly(Side.CLIENT) override def getRenderBounds: Cuboid6 = Cuboid6.full.copy.expand(multiBlockRadius)
|
||||
|
||||
override def toString = "[PartGear]" + x + "x " + y + "y " + z + "z " + getSlotMask + "s "
|
||||
}
|
|
@ -60,7 +60,7 @@ class RenderGear extends ISimpleItemRenderer
|
|||
GL11.glPushMatrix
|
||||
GL11.glTranslatef(x.asInstanceOf[Float] + 0.5f, y.asInstanceOf[Float] + 0.5f, z.asInstanceOf[Float] + 0.5f)
|
||||
GL11.glPushMatrix
|
||||
renderGear(part.placementSide.ordinal, part.tier, part.getMultiBlock.isConstructed, Math.toDegrees(part.node.renderAngle))
|
||||
renderGear(part.placementSide.ordinal, part.tier, part.getMultiBlock.isConstructed, Math.toDegrees(part.mechanicalNode.renderAngle))
|
||||
GL11.glPopMatrix
|
||||
GL11.glPopMatrix
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ object PartGearShaft
|
|||
class PartGearShaft extends PartMechanical
|
||||
{
|
||||
//Constructor
|
||||
node = new GearShaftNode(this)
|
||||
mechanicalNode = new GearShaftNode(this)
|
||||
|
||||
override def preparePlacement(side: Int, itemDamage: Int)
|
||||
{
|
||||
|
|
|
@ -53,7 +53,7 @@ import resonantinduction.core.Reference
|
|||
{
|
||||
glRotatef(90, 0, 0, 1)
|
||||
}
|
||||
GL11.glRotatef(Math.toDegrees(part.node.renderAngle).asInstanceOf[Float], 0, 1, 0)
|
||||
GL11.glRotatef(Math.toDegrees(part.mechanicalNode.renderAngle).asInstanceOf[Float], 0, 1, 0)
|
||||
|
||||
if (part.tier == 1)
|
||||
{
|
||||
|
|
|
@ -1,39 +1,46 @@
|
|||
package resonantinduction.mechanical.mech.turbine
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import net.minecraftforge.fluids.{FluidTank, Fluid, FluidStack, FluidTankInfo}
|
||||
import net.minecraftforge.fluids.{Fluid, FluidStack, FluidTank, FluidTankInfo}
|
||||
import resonant.api.IBoilHandler
|
||||
import resonant.lib.content.prefab.TElectric
|
||||
import resonant.lib.content.prefab.{TElectric, TEnergyStorage}
|
||||
import resonantinduction.core.{Reference, Settings}
|
||||
|
||||
class TileElectricTurbine extends TileTurbine with IBoilHandler with TElectric {
|
||||
|
||||
var tank : FluidTank = new FluidTank(1000);
|
||||
class TileElectricTurbine extends TileTurbine with IBoilHandler with TElectric with TEnergyStorage
|
||||
{
|
||||
var tank: FluidTank = new FluidTank(1000)
|
||||
maxPower = 5000000
|
||||
|
||||
override def update {
|
||||
if (getMultiBlock.isConstructed) {
|
||||
override def update
|
||||
{
|
||||
if (getMultiBlock.isConstructed)
|
||||
{
|
||||
mechanicalNode.torque = defaultTorque * 500 * getArea
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
mechanicalNode.torque = defaultTorque * 500
|
||||
}
|
||||
super.update
|
||||
}
|
||||
|
||||
def onProduce {
|
||||
def onProduce
|
||||
{
|
||||
energy.receiveEnergy((power * Settings.turbineOutputMultiplier).asInstanceOf[Long], true)
|
||||
}
|
||||
|
||||
override def playSound {
|
||||
if (this.worldObj.getWorldTime % 1200 == 0) {
|
||||
override def playSound
|
||||
{
|
||||
if (this.worldObj.getWorldTime % 1200 == 0)
|
||||
{
|
||||
val maxVelocity: Double = (getMaxPower / mechanicalNode.torque) * 4
|
||||
val percentage: Float = Math.max(mechanicalNode.angularVelocity * 4 / maxVelocity.asInstanceOf[Float], 1.0f).asInstanceOf[Float]
|
||||
this.worldObj.playSoundEffect(this.xCoord, this.yCoord, this.zCoord, Reference.prefix + "turbine", percentage, 1.0f)
|
||||
}
|
||||
}
|
||||
|
||||
def canFill(from: ForgeDirection, fluid: Fluid): Boolean = {
|
||||
def canFill(from: ForgeDirection, fluid: Fluid): Boolean =
|
||||
{
|
||||
return from == ForgeDirection.DOWN && fluid.getName.contains("steam")
|
||||
}
|
||||
|
||||
|
@ -45,8 +52,9 @@ class TileElectricTurbine extends TileTurbine with IBoilHandler with TElectric {
|
|||
|
||||
override def canDrain(from: ForgeDirection, fluid: Fluid): Boolean = false
|
||||
|
||||
override def getTankInfo(from: ForgeDirection): Array[FluidTankInfo] = {
|
||||
val re : Array[FluidTankInfo] = new Array[FluidTankInfo](1)
|
||||
override def getTankInfo(from: ForgeDirection): Array[FluidTankInfo] =
|
||||
{
|
||||
val re: Array[FluidTankInfo] = new Array[FluidTankInfo](1)
|
||||
re(1) = tank.getInfo
|
||||
return re
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue