Fixed wind turbine connections
This commit is contained in:
parent
fcbab8cb3b
commit
305d43917e
|
@ -4,7 +4,6 @@ import codechicken.lib.data.{MCDataInput, MCDataOutput}
|
|||
import codechicken.multipart._
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import resonant.lib.grid.UpdateTicker
|
||||
import resonant.lib.transform.vector.VectorWorld
|
||||
import resonantinduction.core.prefab.part.connector.{PartAbstract, TPartNodeProvider}
|
||||
import resonantinduction.mechanical.mech.grid.NodeMechanical
|
||||
|
@ -22,7 +21,7 @@ abstract class PartMechanical extends PartAbstract with JNormalOcclusion with TF
|
|||
def mechanicalNode_=(mech: NodeMechanical)
|
||||
{
|
||||
_mechanicalNode = mech
|
||||
mechanicalNode.onVelocityChanged = () => UpdateTicker.world.enqueue(() => sendPacket(1))
|
||||
mechanicalNode.onVelocityChanged = () => if (world != null) sendPacket(1)
|
||||
nodes.add(mechanicalNode)
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ abstract class TileMechanical(material: Material) extends SpatialTile(material:
|
|||
{
|
||||
_mechanicalNode = newNode
|
||||
mechanicalNode.onVelocityChanged = () => sendPacket(1)
|
||||
nodes.remove(nodes.filter(_.isInstanceOf[NodeMechanical]))
|
||||
nodes.removeAll(nodes.filter(_.isInstanceOf[NodeMechanical]))
|
||||
nodes.add(mechanicalNode)
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,9 @@ abstract class TileMechanical(material: Material) extends SpatialTile(material:
|
|||
override def use(player: EntityPlayer, side: Int, hit: Vector3): Boolean =
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
println(mechanicalNode)
|
||||
}
|
||||
|
||||
//Debugging
|
||||
val itemStack: ItemStack = player.getHeldItem
|
||||
|
|
|
@ -66,7 +66,7 @@ class PartGear extends PartMechanical with IMultiBlockStructure[PartGear]
|
|||
override def activate(player: EntityPlayer, hit: MovingObjectPosition, itemStack: ItemStack): Boolean =
|
||||
{
|
||||
if (!world.isRemote)
|
||||
println(mechanicalNode.grid)
|
||||
println(mechanicalNode)
|
||||
|
||||
if (itemStack != null && itemStack.getItem.isInstanceOf[ItemHandCrank])
|
||||
{
|
||||
|
|
|
@ -71,6 +71,7 @@ class MechanicalGrid extends GridNode[NodeMechanical](classOf[NodeMechanical]) w
|
|||
|
||||
if (passed.size > 1)
|
||||
{
|
||||
//Pass energy to every single node
|
||||
val prev = passed(passed.size - 2)
|
||||
val ratio = curr.radius(prev) / prev.radius(curr)
|
||||
val invert = if (curr.inverseRotation(prev)) -1 else 1
|
||||
|
|
|
@ -23,12 +23,23 @@ class NodeTurbine(parent: TileTurbine) extends NodeMechanical(parent)
|
|||
* Moment of inertia = m * r * r
|
||||
* Where "m" is the mass and "r" is the radius of the object.
|
||||
*/
|
||||
override def radius(other: TNodeMechanical) = parent.multiBlockRadius
|
||||
override def radius(other: TNodeMechanical): Double =
|
||||
{
|
||||
val deltaPos = other.asInstanceOf[NodeMechanical].toVectorWorld - toVectorWorld
|
||||
|
||||
if (deltaPos.normalize.toForgeDirection == parent.getDirection)
|
||||
return super.radius(other)
|
||||
|
||||
return parent.multiBlockRadius
|
||||
}
|
||||
|
||||
def turbine: TileTurbine = getParent.asInstanceOf[TileTurbine]
|
||||
|
||||
override def canConnect[B](other: B, from: ForgeDirection): Boolean =
|
||||
override def canConnect[B <: NodeMechanical](other: B, from: ForgeDirection): Boolean =
|
||||
{
|
||||
if (!other.isInstanceOf[NodeTurbine])
|
||||
println(other.getClass + " vs " + turbine.getDirection)
|
||||
|
||||
return turbine.getMultiBlock.isPrimary && other.isInstanceOf[NodeMechanical] && !other.isInstanceOf[NodeTurbine] && from == turbine.getDirection
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue