Implemented Lenz's law and counter-emf
This commit is contained in:
parent
87e3ff33ca
commit
8ad5a353c1
|
@ -8,7 +8,6 @@ import io.netty.buffer.ByteBuf
|
|||
import net.minecraft.block.material.Material
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.entity.EntityLivingBase
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
import net.minecraft.util.ResourceLocation
|
||||
|
@ -272,16 +271,4 @@ class TileBattery extends SpatialTile(Material.iron) with TIO with TElectric wit
|
|||
super.writeToNBT(nbt)
|
||||
energy.save(nbt)
|
||||
}
|
||||
|
||||
override protected def use(player: EntityPlayer, side: Int, hit: Vector3): Boolean =
|
||||
{
|
||||
if (player.isSneaking)
|
||||
{
|
||||
//Temporary AC frequency testing feature
|
||||
electricNode.frequency = (electricNode.frequency + 10) % 60
|
||||
return true
|
||||
}
|
||||
|
||||
return super.use(player, side, hit)
|
||||
}
|
||||
}
|
|
@ -93,7 +93,7 @@ class TileMotor extends SpatialTile(Material.iron) with TIO with TElectric with
|
|||
*
|
||||
* After differentiation via chain rule:
|
||||
* emf = NBAwSin(wt)
|
||||
* emfMax = NBAw
|
||||
* emfMax = NBAw for direct current
|
||||
* where w = angular velocity
|
||||
*/
|
||||
val inducedEmf = TileMotor.motorConstant * mechNode.angularVelocity // * Math.sin(mechNode.angularVelocity * System.currentTimeMillis() / 1000d)
|
||||
|
@ -102,10 +102,9 @@ class TileMotor extends SpatialTile(Material.iron) with TIO with TElectric with
|
|||
* Produce torque based on current.
|
||||
* T = NBA * I / (2pi)
|
||||
*/
|
||||
//TODO: Torque should be based on the current, as a result of counter-emf
|
||||
val torque = TileMotor.motorConstant * ((electricNode.voltage - inducedEmf) / electricNode.resistance) / (2 * Math.PI)
|
||||
val torque = TileMotor.motorConstant * electricNode.current / (2 * Math.PI)
|
||||
mechNode.accelerate(torque)
|
||||
// electricNode.generateVoltage(inducedEmf * -1)
|
||||
electricNode.generateVoltage(inducedEmf)
|
||||
}
|
||||
|
||||
override def setIO(dir: ForgeDirection, ioType: Int)
|
||||
|
|
|
@ -61,7 +61,7 @@ class PartGear extends PartMechanical with IMultiBlockStructure[PartGear]
|
|||
{
|
||||
if (itemStack != null && itemStack.getItem.isInstanceOf[ItemHandCrank])
|
||||
{
|
||||
mechanicalNode.accelerate((if (player.isSneaking) 1 else -1) * 4000)
|
||||
mechanicalNode.accelerate((if (player.isSneaking) 1 else -1) * 1000)
|
||||
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.02f)
|
||||
return true
|
||||
|
@ -82,8 +82,6 @@ class PartGear extends PartMechanical with IMultiBlockStructure[PartGear]
|
|||
getMultiBlock.deconstruct()
|
||||
}
|
||||
|
||||
override def getMultiBlock: GearMultiBlockHandler = multiBlock
|
||||
|
||||
/**
|
||||
* Is this gear block the one in the center-edge of the multiblock that can interact with other gears?
|
||||
* @return Returning true implies that this gear is able to connect to other ones side-by-side.
|
||||
|
@ -117,6 +115,8 @@ class PartGear extends PartMechanical with IMultiBlockStructure[PartGear]
|
|||
getMultiBlock.save(nbt)
|
||||
}
|
||||
|
||||
override def getMultiBlock: GearMultiBlockHandler = multiBlock
|
||||
|
||||
override def getMultiBlockVectors: java.util.List[resonant.lib.transform.vector.Vector3] = new resonant.lib.transform.vector.Vector3().getAround(this.world, placementSide, 1)
|
||||
|
||||
def getWorld: World =
|
||||
|
|
Loading…
Reference in New Issue