Removed unused methods from MechanicalNode

This commit is contained in:
Calclavia 2014-11-09 13:44:38 +08:00
parent 274442fb31
commit e0f341753f
12 changed files with 206 additions and 327 deletions

View file

@ -29,18 +29,16 @@ trait TMechanicalNode extends INode with IVectorWorld
/**
* Gets the angular velocity of the mechanical device from a specific side
*
* @param from - The side of the mechanical device
* @return Angular velocity in meters per second
*/
def angularVelocity(from: ForgeDirection): Double
def angularVelocity: Double
/**
* Gets the torque of the mechanical device from a specific side
*
* @param from - The side of the mechanical device
* @return force
*/
def torque(from: ForgeDirection): Double
def torque: Double
/**
* Does the direction flip on this side for rotation

View file

@ -60,18 +60,18 @@ class TileMotor extends TileNode(Material.iron) with TElectric with IRotatable
def receiveMechanical
{
val power: Double = mechNode.torque(ForgeDirection.UNKNOWN) * mechNode.angularVelocity(ForgeDirection.UNKNOWN)
val power: Double = mechNode.torque * mechNode.angularVelocity
val receive: Double = 0 // dcNode.addEnergy(ForgeDirection.UNKNOWN, power, true)
if (receive > 0)
{
val percentageUsed: Double = receive / power
mechNode.rotate(this, -mechNode.torque(ForgeDirection.UNKNOWN) * percentageUsed, -mechNode.angularVelocity(ForgeDirection.UNKNOWN) * percentageUsed)
mechNode.rotate(this, -mechNode.torque * percentageUsed, -mechNode.angularVelocity * percentageUsed)
}
}
def produceMechanical
{
val extract: Double = 0 //dcNode.removeEnergy(ForgeDirection.UNKNOWN, dcNode.getEnergy(ForgeDirection.UNKNOWN), false)
val extract: Double = 0 //dcNode.removeEnergy(ForgeDirection.UNKNOWN, dcNode.getEnergy, false)
if (extract > 0)
{
val torqueRatio: Long = ((gearRatio + 1) / 2.2d * (extract)).asInstanceOf[Long]
@ -81,12 +81,12 @@ class TileMotor extends TileNode(Material.iron) with TElectric with IRotatable
val maxTorque: Double = (extract) / maxAngularVelocity
var setAngularVelocity: Double = maxAngularVelocity
var setTorque: Double = maxTorque
val currentTorque: Double = Math.abs(mechNode.torque(ForgeDirection.UNKNOWN))
val currentTorque: Double = Math.abs(mechNode.torque)
if (currentTorque != 0)
{setTorque = Math.min(setTorque, maxTorque) * (mechNode.torque(ForgeDirection.UNKNOWN) / currentTorque)}
val currentVelo: Double = Math.abs(mechNode.angularVelocity(ForgeDirection.UNKNOWN))
if (currentVelo != 0) setAngularVelocity = Math.min(+setAngularVelocity, maxAngularVelocity) * (mechNode.angularVelocity(ForgeDirection.UNKNOWN) / currentVelo)
mechNode.rotate(this, setTorque - mechNode.torque(ForgeDirection.UNKNOWN), setAngularVelocity - mechNode.angularVelocity(ForgeDirection.UNKNOWN))
{setTorque = Math.min(setTorque, maxTorque) * (mechNode.torque / currentTorque)}
val currentVelo: Double = Math.abs(mechNode.angularVelocity)
if (currentVelo != 0) setAngularVelocity = Math.min(+setAngularVelocity, maxAngularVelocity) * (mechNode.angularVelocity / currentVelo)
mechNode.rotate(this, setTorque - mechNode.torque, setAngularVelocity - mechNode.angularVelocity)
// dcNode.removeEnergy(ForgeDirection.UNKNOWN, Math.abs(setTorque * setAngularVelocity).asInstanceOf[Long], true)
}
}

View file

@ -172,9 +172,9 @@ class PartMultimeter extends PartFace with IRedstonePart with IPacketReceiver wi
if (instance != null)
{
getNetwork.torqueGraph.queue(instance.torque(receivingSide))
getNetwork.angularVelocityGraph.queue(instance.angularVelocity(receivingSide))
getNetwork.powerGraph.queue(instance.torque(receivingSide) * instance.angularVelocity(receivingSide))
getNetwork.torqueGraph.queue(instance.torque)
getNetwork.angularVelocityGraph.queue(instance.angularVelocity)
getNetwork.powerGraph.queue(instance.torque * instance.angularVelocity)
}
}
if (tileEntity.isInstanceOf[IFluidHandler])

View file

@ -19,11 +19,11 @@ class PumpNode(parent: INodeProvider) extends NodePressure(parent)
{
if (dir == pump.getDirection)
{
return Math.max(Math.abs(pump.mechanicalNode.torque(ForgeDirection.UNKNOWN) / 8000d), 2).asInstanceOf[Int]
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(ForgeDirection.UNKNOWN) / 8000d), 2).asInstanceOf[Int]
return -Math.max(Math.abs(pump.mechanicalNode.torque / 8000d), 2).asInstanceOf[Int]
}
}
return 0

View file

@ -109,8 +109,8 @@ public class DebugFrameMechanical extends FrameNodeDebug
{
case 0: return dir;
case 1: return node;
case 2: return node.torque(dir);
case 3: return node.angularVelocity(dir);
case 2: return node.torque();
case 3: return node.angularVelocity();
}
}
return "00000";

View file

@ -140,14 +140,12 @@ abstract class PartMechanical extends PartAbstract with JNormalOcclusion with TF
{
placementSide = ForgeDirection.getOrientation(nbt.getByte("side"))
tier = nbt.getByte("tier")
mechanicalNode.load(nbt)
}
override def save(nbt: NBTTagCompound)
{
nbt.setByte("side", placementSide.ordinal.asInstanceOf[Byte])
nbt.setByte("tier", tier.asInstanceOf[Byte])
mechanicalNode.save(nbt)
}
protected def getItem: ItemStack

View file

@ -26,7 +26,7 @@ abstract class TileMechanical(material: Material) extends TileNode(material) wit
/** External debug GUI */
var frame: DebugFrameMechanical = null
mechanicalNode.onStateChanged = () => if (!world.isRemote && ticks % 3 == 0) sendPacket(1)
mechanicalNode.onVelocityChanged = () => if (!world.isRemote && ticks % 3 == 0) sendPacket(1)
nodes.add(mechanicalNode)
override def update()

View file

@ -1,12 +1,10 @@
package resonantinduction.mechanical.mech.grid
import net.minecraft.nbt.NBTTagCompound
import net.minecraftforge.common.util.ForgeDirection
import resonant.api.grid.{INodeProvider, IUpdate}
import resonant.api.grid.INodeProvider
import resonant.lib.grid.GridNode
import resonant.lib.grid.node.NodeGrid
import resonant.lib.transform.vector.IVectorWorld
import resonant.lib.utility.nbt.ISaveObj
import resonantinduction.core.interfaces.TMechanicalNode
import resonantinduction.core.prefab.node.TMultipartNode
@ -15,129 +13,47 @@ import resonantinduction.core.prefab.node.TMultipartNode
*
* @author Calclavia, Darkguardsman
*/
class MechanicalNode(parent: INodeProvider) extends NodeGrid[MechanicalNode](parent) with TMultipartNode[MechanicalNode] with TMechanicalNode with ISaveObj with IVectorWorld
class MechanicalNode(parent: INodeProvider) extends NodeGrid[MechanicalNode](parent) with TMultipartNode[MechanicalNode] with TMechanicalNode with IVectorWorld
{
/**
* Allows the node to share its power with other nodes
*/
var torque: Double = 0
var prevTorque: Double = .0
var prevAngularVelocity: Double = .0
var angularVelocity: Double = 0
var torque = 0D
var angularVelocity = 0D
protected[grid] var bufferTorque = 0D
protected[grid] var bufferAngle = 0D
/**
* Current angle of rotation, mainly used for rendering
*/
var renderAngle: Double = 0
/**
* Angle of rotation of last update
*/
var prev_angle: Double = 0
var acceleration: Float = 2f
protected var maxDeltaAngle: Double = Math.toRadians(120)
protected var load = 0.2
var load = 0.2
/**
* Events
*/
var onStateChanged: () => Unit = () => ()
var onTorqueChanged: () => Unit = () => ()
var onVelocityChanged: () => Unit = () => ()
private var prevTime = 0L
private var angle = 0D
/**
* An arbitrary angle value computed based on velocity
* @return The angle in radians
*/
def renderAngle: Double =
{
val deltaTime = (System.currentTimeMillis() - prevTime) / 1000D
prevTime = System.currentTimeMillis()
angle = (angle + deltaTime * angularVelocity) % (2 * Math.PI)
return angle
}
override def getRadius(dir: ForgeDirection, `with`: TMechanicalNode): Double = 0.5
override def angularVelocity(side: ForgeDirection): Double = angularVelocity
override def torque(side: ForgeDirection): Double = torque
override def inverseRotation(side: ForgeDirection): Boolean = false
/*
override def update(deltaTime: Double)
{
if (angularVelocity >= 0)
{
renderAngle += Math.min(angularVelocity, this.maxDeltaAngle) * deltaTime
}
else
{
renderAngle += Math.max(angularVelocity, -this.maxDeltaAngle) * deltaTime
}
if (renderAngle >= Math.PI * 2)
{
revolve
renderAngle = renderAngle % (Math.PI * 2)
}
if (world != null && !world.isRemote)
{
val acceleration: Double = this.acceleration * deltaTime
if (Math.abs(prevAngularVelocity - angularVelocity) > 0.01f)
{
prevAngularVelocity = angularVelocity
onStateChanged()
}
if (Math.abs(prevTorque - torque) > 0.01f)
{
prevTorque = torque
onStateChanged()
}
val torqueLoss: Double = Math.min(Math.abs(getTorque), (Math.abs(getTorque * getTorqueLoad) + getTorqueLoad / 10) * deltaTime)
torque += (if (torque > 0) -torqueLoss else torqueLoss)
val velocityLoss: Double = Math.min(Math.abs(getAngularSpeed), (Math.abs(getAngularSpeed * getAngularVelocityLoad) + getAngularVelocityLoad / 10) * deltaTime)
angularVelocity += (if (angularVelocity > 0) -velocityLoss else velocityLoss)
if (getEnergy <= 0)
{
angularVelocity = ({torque = 0; torque})
}
power = getEnergy / deltaTime
if (sharePower)
{
directionMap.foreach
{
case (adjacentMech: MechanicalNode, dir: ForgeDirection) =>
{
if (adjacentMech != null)
{
val ratio: Double = adjacentMech.getRadius(dir.getOpposite, this) / getRadius(dir, adjacentMech)
val inverseRotation: Boolean = this.inverseRotation(dir) && adjacentMech.inverseRotation(dir.getOpposite)
val inversion: Int = if (inverseRotation) -1 else 1
val targetTorque: Double = inversion * adjacentMech.getTorque / ratio
val applyTorque: Double = targetTorque * acceleration
if (Math.abs(torque + applyTorque) < Math.abs(targetTorque))
{
torque += applyTorque
}
else if (Math.abs(torque - applyTorque) > Math.abs(targetTorque))
{
torque -= applyTorque
}
val targetVelocity: Double = inversion * adjacentMech.getAngularSpeed * ratio
val applyVelocity: Double = targetVelocity * acceleration
if (Math.abs(angularVelocity + applyVelocity) < Math.abs(targetVelocity))
{
angularVelocity += applyVelocity
}
else if (Math.abs(angularVelocity - applyVelocity) > Math.abs(targetVelocity))
{
angularVelocity -= applyVelocity
}
}
}
}
}
}
prev_angle = renderAngle
}
*/
/**
* Called when one revolution is made.
*/
protected def revolve
@deprecated
protected def revolve()
{
}
@ -147,10 +63,6 @@ override def update(deltaTime: Double)
bufferAngle += angle
}
private def getTorque: Double = if (angularVelocity != 0) torque else 0
private def getAngularSpeed: Double = if (torque != 0) angularVelocity else 0
/**
* The percentage of torque loss every second
*/
@ -161,34 +73,11 @@ override def update(deltaTime: Double)
*/
def getAngularVelocityLoad: Double = load
def getEnergy: Double =
{
return getTorque * getAngularSpeed
}
def getPower: Double =
{
return 0//getMechanicalGrid.power
}
def load(nbt: NBTTagCompound)
{
torque = nbt.getDouble("torque")
angularVelocity = nbt.getDouble("angularVelocity")
}
def save(nbt: NBTTagCompound)
{
nbt.setDouble("torque", torque)
nbt.setDouble("angularVelocity", angularVelocity)
}
def getPower: Double = getMechanicalGrid.power
def getMechanicalGrid: MechanicalGrid = super.getGrid.asInstanceOf[MechanicalGrid]
override def newGrid: GridNode[MechanicalNode] = new MechanicalGrid
override def isValidConnection(other: AnyRef): Boolean =
{
return other.isInstanceOf[MechanicalNode]
}
override def isValidConnection(other: AnyRef): Boolean = other.isInstanceOf[MechanicalNode]
}

View file

@ -8,9 +8,6 @@ import resonantinduction.mechanical.mech.grid.MechanicalNode
*/
class NodeMechanicalPiston(parent: TileMechanicalPiston) extends MechanicalNode(parent)
{
//Constructor
maxDeltaAngle = Math.toRadians(45)
override def canConnect(dir: ForgeDirection): Boolean =
{
return dir ne (getParent.asInstanceOf[TileMechanicalPiston]).getDirection

View file

@ -9,205 +9,205 @@ import resonant.api.IRotatable
import resonant.api.recipe.{MachineRecipes, RecipeResource}
import resonant.content.factory.resources.RecipeType
import resonant.lib.prefab.damage.CustomDamageSource
import resonant.lib.transform.region.Cuboid
import resonant.lib.transform.vector.Vector3
import resonant.lib.utility.Timer
import resonantinduction.core.{Reference, ResonantInduction}
import resonantinduction.mechanical.mech.TileMechanical
import resonant.lib.transform.region.Cuboid
import resonant.lib.transform.vector.Vector3
/**
* @author Calclavia
*/
object TileGrindingWheel
{
final val PROCESS_TIME: Int = 20 * 20
/**
* A map of ItemStacks and their remaining grind-time left.
*/
final val TIMER_GRIND_ITEM: Timer[EntityItem] = new Timer[EntityItem]
final val PROCESS_TIME: Int = 20 * 20
/**
* A map of ItemStacks and their remaining grind-time left.
*/
final val TIMER_GRIND_ITEM: Timer[EntityItem] = new Timer[EntityItem]
}
class TileGrindingWheel extends TileMechanical(Material.rock) with IRotatable
{
var grindingItem: EntityItem = null
private final val requiredTorque: Long = 250
private var counter: Double = 0
var grindingItem: EntityItem = null
private final val requiredTorque: Long = 250
private var counter: Double = 0
//Constructor
mechanicalNode = new GrinderNode(this)
bounds(new Cuboid(0.05f, 0.05f, 0.05f, 0.95f, 0.95f, 0.95f))
isOpaqueCube(false)
normalRender(false)
setTextureName("material_steel_dark")
//Constructor
mechanicalNode = new GrinderNode(this)
bounds(new Cuboid(0.05f, 0.05f, 0.05f, 0.95f, 0.95f, 0.95f))
isOpaqueCube(false)
normalRender(false)
setTextureName("material_steel_dark")
override def update
override def update
{
super.update
counter = Math.max(counter + Math.abs(mechanicalNode.torque), 0)
doWork
}
override def collide(entity: Entity)
{
if (entity.isInstanceOf[EntityItem])
{
super.update
counter = Math.max(counter + Math.abs(mechanicalNode.torque), 0)
doWork
(entity.asInstanceOf[EntityItem]).age -= 1
}
override def collide(entity: Entity)
if (canWork)
{
if (entity.isInstanceOf[EntityItem])
if (entity.isInstanceOf[EntityItem])
{
if (canGrind((entity.asInstanceOf[EntityItem]).getEntityItem))
{
(entity.asInstanceOf[EntityItem]).age -= 1
if (grindingItem == null)
{
grindingItem = entity.asInstanceOf[EntityItem]
}
if (!TileGrindingWheel.TIMER_GRIND_ITEM.containsKey(entity.asInstanceOf[EntityItem]))
{
TileGrindingWheel.TIMER_GRIND_ITEM.put(entity.asInstanceOf[EntityItem], TileGrindingWheel.PROCESS_TIME)
}
}
if (canWork)
else
{
if (entity.isInstanceOf[EntityItem])
entity.setPosition(entity.posX, entity.posY - 1.2, entity.posZ)
}
}
else
{
entity.attackEntityFrom(new CustomDamageSource("grinder", this), 2)
}
}
if (mechanicalNode.angularVelocity != 0)
{
var dir: ForgeDirection = getDirection
dir = ForgeDirection.getOrientation(if (!(dir.ordinal % 2 == 0)) dir.ordinal - 1 else dir.ordinal).getOpposite
val speed: Double = mechanicalNode.angularVelocity / 20
var speedX: Double = dir.offsetX * speed
var speedZ: Double = dir.offsetZ * speed
var speedY: Double = Math.random * speed
if (Math.abs(speedX) > 1)
{
speedX = if (speedX > 0) 1 else -1
}
if (Math.abs(speedZ) > 1)
{
speedZ = if (speedZ > 0) 1 else -1
}
if (Math.abs(speedZ) > 1)
{
speedY = if (speedY > 0) 1 else -1
}
entity.addVelocity(speedX, speedY, speedZ)
}
}
/**
* Can this machine work this tick?
*
* @return
*/
def canWork: Boolean =
{
return counter >= requiredTorque
}
def doWork
{
if (canWork)
{
var didWork: Boolean = false
if (grindingItem != null)
{
if (TileGrindingWheel.TIMER_GRIND_ITEM.containsKey(grindingItem) && !grindingItem.isDead && toVector3.add(0.5).distance(new Vector3(grindingItem)) < 1)
{
val timeLeft: Int = TileGrindingWheel.TIMER_GRIND_ITEM.decrease(grindingItem)
if (timeLeft <= 0)
{
if (this.doGrind(grindingItem))
{
if (canGrind((entity.asInstanceOf[EntityItem]).getEntityItem))
{
if (grindingItem == null)
{
grindingItem = entity.asInstanceOf[EntityItem]
}
if (!TileGrindingWheel.TIMER_GRIND_ITEM.containsKey(entity.asInstanceOf[EntityItem]))
{
TileGrindingWheel.TIMER_GRIND_ITEM.put(entity.asInstanceOf[EntityItem], TileGrindingWheel.PROCESS_TIME)
}
}
else
{
entity.setPosition(entity.posX, entity.posY - 1.2, entity.posZ)
}
grindingItem.getEntityItem.stackSize -= 1;
if (grindingItem.getEntityItem.stackSize <= 0)
{
grindingItem.setDead
TileGrindingWheel.TIMER_GRIND_ITEM.remove(grindingItem)
grindingItem = null
}
else
{
grindingItem.setEntityItemStack(grindingItem.getEntityItem)
TileGrindingWheel.TIMER_GRIND_ITEM.put(grindingItem, TileGrindingWheel.PROCESS_TIME)
}
}
}
else
{
grindingItem.delayBeforeCanPickup = 20
if (grindingItem.getEntityItem.getItem.isInstanceOf[ItemBlock])
{
ResonantInduction.proxy.renderBlockParticle(worldObj, new Vector3(grindingItem), new Vector3((Math.random - 0.5f) * 3, (Math.random - 0.5f) * 3, (Math.random - 0.5f) * 3), 3, 1)
}
else
{
entity.attackEntityFrom(new CustomDamageSource("grinder", this), 2)
worldObj.spawnParticle("crit", grindingItem.posX, grindingItem.posY, grindingItem.posZ, (Math.random - 0.5f) * 3, (Math.random - 0.5f) * 3, (Math.random - 0.5f) * 3)
}
}
didWork = true
}
if (mechanicalNode.angularVelocity(ForgeDirection.UNKNOWN) != 0)
else
{
var dir: ForgeDirection = getDirection
dir = ForgeDirection.getOrientation(if (!(dir.ordinal % 2 == 0)) dir.ordinal - 1 else dir.ordinal).getOpposite
val speed: Double = mechanicalNode.angularVelocity(ForgeDirection.UNKNOWN) / 20
var speedX: Double = dir.offsetX * speed
var speedZ: Double = dir.offsetZ * speed
var speedY: Double = Math.random * speed
if (Math.abs(speedX) > 1)
{
speedX = if (speedX > 0) 1 else -1
}
if (Math.abs(speedZ) > 1)
{
speedZ = if (speedZ > 0) 1 else -1
}
if (Math.abs(speedZ) > 1)
{
speedY = if (speedY > 0) 1 else -1
}
entity.addVelocity(speedX, speedY, speedZ)
TileGrindingWheel.TIMER_GRIND_ITEM.remove(grindingItem)
grindingItem = null
}
}
/**
* Can this machine work this tick?
*
* @return
*/
def canWork: Boolean =
{
return counter >= requiredTorque
}
def doWork
{
if (canWork)
}
if (didWork)
{
if (this.ticks % 8 == 0)
{
var didWork: Boolean = false
if (grindingItem != null)
{
if (TileGrindingWheel.TIMER_GRIND_ITEM.containsKey(grindingItem) && !grindingItem.isDead && toVector3.add(0.5).distance(new Vector3(grindingItem)) < 1)
{
val timeLeft: Int = TileGrindingWheel.TIMER_GRIND_ITEM.decrease(grindingItem)
if (timeLeft <= 0)
{
if (this.doGrind(grindingItem))
{
grindingItem.getEntityItem.stackSize -= 1;
if (grindingItem.getEntityItem.stackSize <= 0)
{
grindingItem.setDead
TileGrindingWheel.TIMER_GRIND_ITEM.remove(grindingItem)
grindingItem = null
}
else
{
grindingItem.setEntityItemStack(grindingItem.getEntityItem)
TileGrindingWheel.TIMER_GRIND_ITEM.put(grindingItem, TileGrindingWheel.PROCESS_TIME)
}
}
}
else
{
grindingItem.delayBeforeCanPickup = 20
if (grindingItem.getEntityItem.getItem.isInstanceOf[ItemBlock])
{
ResonantInduction.proxy.renderBlockParticle(worldObj, new Vector3(grindingItem), new Vector3((Math.random - 0.5f) * 3, (Math.random - 0.5f) * 3, (Math.random - 0.5f) * 3), 3, 1)
}
else
{
worldObj.spawnParticle("crit", grindingItem.posX, grindingItem.posY, grindingItem.posZ, (Math.random - 0.5f) * 3, (Math.random - 0.5f) * 3, (Math.random - 0.5f) * 3)
}
}
didWork = true
}
else
{
TileGrindingWheel.TIMER_GRIND_ITEM.remove(grindingItem)
grindingItem = null
}
}
if (didWork)
{
if (this.ticks % 8 == 0)
{
worldObj.playSoundEffect(this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5, Reference.prefix + "grinder", 0.5f, 1)
}
counter -= requiredTorque
}
worldObj.playSoundEffect(this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5, Reference.prefix + "grinder", 0.5f, 1)
}
counter -= requiredTorque
}
}
}
def canGrind(itemStack: ItemStack): Boolean =
{
return MachineRecipes.INSTANCE.getOutput(RecipeType.GRINDER.name, itemStack).length > 0
}
def canGrind(itemStack: ItemStack): Boolean =
{
return MachineRecipes.INSTANCE.getOutput(RecipeType.GRINDER.name, itemStack).length > 0
}
private def doGrind(entity: EntityItem): Boolean =
private def doGrind(entity: EntityItem): Boolean =
{
val itemStack: ItemStack = entity.getEntityItem
val results: Array[RecipeResource] = MachineRecipes.INSTANCE.getOutput(RecipeType.GRINDER.name, itemStack)
for (resource <- results)
{
val itemStack: ItemStack = entity.getEntityItem
val results: Array[RecipeResource] = MachineRecipes.INSTANCE.getOutput(RecipeType.GRINDER.name, itemStack)
for (resource <- results)
{
val outputStack: ItemStack = resource.getItemStack
if (!this.worldObj.isRemote)
{
val entityItem: EntityItem = new EntityItem(this.worldObj, entity.posX, entity.posY - 1.2, entity.posZ, outputStack)
entityItem.delayBeforeCanPickup = 20
entityItem.motionX = 0
entityItem.motionY = 0
entityItem.motionZ = 0
this.worldObj.spawnEntityInWorld(entityItem)
}
}
return results.length > 0
val outputStack: ItemStack = resource.getItemStack
if (!this.worldObj.isRemote)
{
val entityItem: EntityItem = new EntityItem(this.worldObj, entity.posX, entity.posY - 1.2, entity.posZ, outputStack)
entityItem.delayBeforeCanPickup = 20
entityItem.motionX = 0
entityItem.motionY = 0
entityItem.motionZ = 0
this.worldObj.spawnEntityInWorld(entityItem)
}
}
return results.length > 0
}
override def getDirection: ForgeDirection =
override def getDirection: ForgeDirection =
{
if (worldObj != null)
{
if (worldObj != null)
{
return ForgeDirection.getOrientation(getBlockMetadata)
}
return ForgeDirection.UNKNOWN
return ForgeDirection.getOrientation(getBlockMetadata)
}
return ForgeDirection.UNKNOWN
}
override def setDirection(direction: ForgeDirection)
{
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, direction.ordinal, 3)
}
override def setDirection(direction: ForgeDirection)
{
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, direction.ordinal, 3)
}
}

View file

@ -10,9 +10,6 @@ import resonantinduction.mechanical.mech.grid.MechanicalNode
*/
class MixerNode(parent: INodeProvider) extends MechanicalNode(parent)
{
//Constructor
maxDeltaAngle = Math.toRadians(45)
override def canConnect(direction: ForgeDirection): Boolean =
{
return direction == ForgeDirection.DOWN || direction == ForgeDirection.UP

View file

@ -99,7 +99,7 @@ class TileMixer extends TileMechanical(Material.iron)
*/
def canWork: Boolean =
{
return mechanicalNode.angularVelocity(ForgeDirection.UNKNOWN) != 0 && !areaBlockedFromMoving
return mechanicalNode.angularVelocity != 0 && !areaBlockedFromMoving
}
def doWork
@ -113,7 +113,7 @@ class TileMixer extends TileMechanical(Material.iron)
val entity: Entity = obj.asInstanceOf[Entity]
val originalPosition: Vector3 = new Vector3(entity)
val relativePosition: Vector3 = originalPosition.clone.subtract(toVector3.add(0.5))
relativePosition.transform(new Quaternion(-mechanicalNode.angularVelocity(ForgeDirection.UNKNOWN), new Vector3(1, 0, 0)))
relativePosition.transform(new Quaternion(-mechanicalNode.angularVelocity, new Vector3(1, 0, 0)))
val newPosition: Vector3 = toVector3.add(0.5).add(relativePosition)
val difference: Vector3 = newPosition.subtract(originalPosition).multiply(0.5)
entity.addVelocity(difference.x, difference.y, difference.z)