Fixed big gear side connections
This commit is contained in:
parent
8b7ae367e6
commit
109b2c89c7
|
@ -11,21 +11,6 @@ import resonant.lib.transform.vector.IVectorWorld
|
|||
*/
|
||||
trait TMechanicalNode extends INode with IVectorWorld
|
||||
{
|
||||
/**
|
||||
* Gets the radius of the gear in meters. Used to calculate torque and gear ratio for connections.
|
||||
* Is not applied to direct face to face connections
|
||||
*
|
||||
* @param side - side of the machine
|
||||
* @return radius in meters of the rotation peace
|
||||
*/
|
||||
def getRadius(side: ForgeDirection, from: TMechanicalNode): Double = 0.5
|
||||
|
||||
/**
|
||||
* The mechanical ratio. The higher the ratio, the more torque but less angular velocity.
|
||||
* @return A double greater than zero
|
||||
*/
|
||||
def ratio = 1D
|
||||
|
||||
/**
|
||||
* Gets the angular velocity of the mechanical device from a specific side
|
||||
*
|
||||
|
|
|
@ -53,17 +53,6 @@ abstract class PartMechanical extends PartAbstract with JNormalOcclusion with TF
|
|||
this.tier = itemDamage
|
||||
}
|
||||
|
||||
override def activate(player: EntityPlayer, hit: MovingObjectPosition, item: ItemStack): Boolean =
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
println("Angle: " + mechanicalNode.prevAngle)
|
||||
sendPacket(2)
|
||||
}
|
||||
|
||||
super.activate(player, hit, item)
|
||||
}
|
||||
|
||||
override def write(packet: MCDataOutput, id: Int)
|
||||
{
|
||||
super.write(packet, id)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package resonantinduction.mechanical.mech.gear
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraft.item.Item
|
||||
import net.minecraft.world.World
|
||||
|
||||
|
@ -7,8 +8,5 @@ class ItemHandCrank extends Item
|
|||
{
|
||||
setMaxStackSize(1)
|
||||
|
||||
def shouldPassSneakingClickToBlock(world: World, x: Int, y: Int, z: Int): Boolean =
|
||||
{
|
||||
return true
|
||||
}
|
||||
override def doesSneakBypassUse(world: World, x: Int, y: Int, z: Int, player: EntityPlayer) = true
|
||||
}
|
|
@ -32,14 +32,14 @@ class NodeGear(parent: PartGear) extends NodeMechanical(parent: PartGear)
|
|||
}
|
||||
}
|
||||
|
||||
override def getAngularVelocityLoad: Double =
|
||||
override def reconstruct()
|
||||
{
|
||||
return gear.tier match
|
||||
if (!parent.getMultiBlock.isPrimary)
|
||||
{
|
||||
case 0 => 0.1
|
||||
case 1 => 0.2
|
||||
case 2 => 0.1
|
||||
parent.getMultiBlock.getPrimary.mechanicalNode.reconstruct()
|
||||
}
|
||||
|
||||
super.reconstruct()
|
||||
}
|
||||
|
||||
override def rebuild()
|
||||
|
@ -199,8 +199,9 @@ class NodeGear(parent: PartGear) extends NodeMechanical(parent: PartGear)
|
|||
|
||||
override def inverseRotation(other: TMechanicalNode): Boolean = !other.isInstanceOf[GearShaftNode] || (other.isInstanceOf[GearShaftNode] && parent.placementSide.offset < Vector3.zero)
|
||||
|
||||
override def ratio = if (gear.getMultiBlock.isConstructed) 1.5f else super.ratio
|
||||
override def momentOfInertia = if (gear.getMultiBlock.isConstructed) 1.5f else super.momentOfInertia
|
||||
|
||||
/*
|
||||
override def getRadius(dir: ForgeDirection, other: TMechanicalNode): Double =
|
||||
{
|
||||
//The ratio is the same if it is a gear placed back to back with each other OR a shaft
|
||||
|
@ -213,5 +214,5 @@ class NodeGear(parent: PartGear) extends NodeMechanical(parent: PartGear)
|
|||
return super.getRadius(dir, other)
|
||||
|
||||
return if (gear.getMultiBlock.isConstructed) 1.5f else super.getRadius(dir, other)
|
||||
}
|
||||
}*/
|
||||
}
|
|
@ -40,6 +40,11 @@ class PartGear extends PartMechanical with IMultiBlockStructure[PartGear]
|
|||
{
|
||||
if (getMultiBlock.isPrimary)
|
||||
markVelocityUpdate = true
|
||||
|
||||
if(mechanicalNode.angularVelocity == 0)
|
||||
{
|
||||
//mark
|
||||
}
|
||||
}
|
||||
|
||||
mechanicalNode.onGridReconstruct = () => if (world != null && !world.isRemote) sendPacket(2)
|
||||
|
@ -54,7 +59,7 @@ class PartGear extends PartMechanical with IMultiBlockStructure[PartGear]
|
|||
if (manualCrankTime > 0)
|
||||
{
|
||||
//A punch his around 5000 Newtons
|
||||
mechanicalNode.rotate(if (isClockwiseCrank) 50 else -50)
|
||||
mechanicalNode.rotate((if (isClockwiseCrank) 3 else -3) * manualCrankTime)
|
||||
manualCrankTime -= 1
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +70,8 @@ class PartGear extends PartMechanical with IMultiBlockStructure[PartGear]
|
|||
override def activate(player: EntityPlayer, hit: MovingObjectPosition, itemStack: ItemStack): Boolean =
|
||||
{
|
||||
if (!world.isRemote)
|
||||
println(mechanicalNode.connections)
|
||||
println(mechanicalNode)
|
||||
|
||||
if (itemStack != null && itemStack.getItem.isInstanceOf[ItemHandCrank])
|
||||
{
|
||||
if (!world.isRemote && ControlKeyModifer.isControlDown(player))
|
||||
|
@ -95,13 +101,13 @@ class PartGear extends PartMechanical with IMultiBlockStructure[PartGear]
|
|||
override def preRemove
|
||||
{
|
||||
super.preRemove
|
||||
getMultiBlock.deconstruct
|
||||
getMultiBlock.deconstruct()
|
||||
}
|
||||
|
||||
/** Is this gear block the one in the center-edge of the multiblock that can interact with other
|
||||
* gears?
|
||||
*
|
||||
* @return */
|
||||
* @return*/
|
||||
def isCenterMultiBlock: Boolean =
|
||||
{
|
||||
if (!getMultiBlock.isConstructed)
|
||||
|
@ -155,14 +161,16 @@ class PartGear extends PartMechanical with IMultiBlockStructure[PartGear]
|
|||
return world
|
||||
}
|
||||
|
||||
def onMultiBlockChanged
|
||||
def onMultiBlockChanged()
|
||||
{
|
||||
if (world != null)
|
||||
{
|
||||
tile.notifyPartChange(this)
|
||||
|
||||
if (!world.isRemote)
|
||||
{
|
||||
sendDescUpdate
|
||||
mechanicalNode.reconstruct()
|
||||
sendDescUpdate()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,19 +14,9 @@ class GearShaftNode(parent: PartGearShaft) extends NodeMechanical(parent)
|
|||
{
|
||||
return shaft.tier match
|
||||
{
|
||||
case 0 => 0.03
|
||||
case 1 => 0.02
|
||||
case 2 => 0.01
|
||||
}
|
||||
}
|
||||
|
||||
override def getAngularVelocityLoad: Double =
|
||||
{
|
||||
return shaft.tier match
|
||||
{
|
||||
case 0 => 0.03
|
||||
case 1 => 0.02
|
||||
case 2 => 0.01
|
||||
case 0 => 15
|
||||
case 1 => 10
|
||||
case 2 => 5
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -66,14 +66,14 @@ class MechanicalGrid extends GridNode[NodeMechanical](classOf[NodeMechanical]) w
|
|||
val prevAngularVelocity = n.angularVelocity
|
||||
|
||||
val inversion = if (spinMap(n)) 1 else -1
|
||||
n.torque = deltaTorque * n.ratio * inversion
|
||||
n.torque = deltaTorque * inversion
|
||||
val angularAcceleration = deltaTorque / n.momentOfInertia
|
||||
n.angularVelocity = angularAcceleration / n.ratio * deltaTime * inversion
|
||||
n.angularVelocity = angularAcceleration * deltaTime * inversion
|
||||
|
||||
if (Math.abs(prevTorque - n.torque) >= 0.1)
|
||||
if (Math.abs(n.torque - prevTorque) >= 0.1)
|
||||
n.onTorqueChanged()
|
||||
|
||||
if (Math.abs(prevAngularVelocity - n.angularVelocity) >= 0.01)
|
||||
if (Math.abs(n.angularVelocity - prevAngularVelocity) >= 0.001)
|
||||
n.onVelocityChanged()
|
||||
|
||||
//Clear buffers
|
||||
|
|
|
@ -81,12 +81,6 @@ class NodeMechanical(parent: INodeProvider) extends NodeGrid[NodeMechanical](par
|
|||
bufferTorque += torque
|
||||
}
|
||||
|
||||
/**
|
||||
* The percentage of angular velocity loss every second
|
||||
*/
|
||||
def getAngularVelocityLoad: Double = getLoad
|
||||
|
||||
//TODO: Create new grids automatically?
|
||||
def power: Double = torque * angularVelocity
|
||||
|
||||
def getMechanicalGrid: MechanicalGrid = super.grid.asInstanceOf[MechanicalGrid]
|
||||
|
|
Loading…
Reference in a new issue