Skip to content

Commit

Permalink
another fix for the clutch bug? Maybe the last time? Version bump to …
Browse files Browse the repository at this point in the history
…1.15.9
  • Loading branch information
jrddunbr committed Oct 20, 2019
1 parent b458cf5 commit befafb7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
MAJORVERSION = 1
MINORVERSION = 15
REVISION = 7
REVISION = 9

GROUP = 'net.electricalage.eln'
ARCHIVE_NAME = 'ElectricalAge-jrddunbr'
MAPURL = 'https://eln.ja13.org/worlds/latest.zip'
MAPURL = 'https://ll.ja13.org/worlds/latest.zip'


BUILD_HOST = 'unknown'
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/mods/eln/mechanical/Clutch.kt
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ class ClutchElement(node: TransparentNode, desc_: TransparentNodeDescriptor) : S
val rRads = rightShaft.rads
leftShaft = ShaftNetwork(this, front.left())
rightShaft = ShaftNetwork(this, front.right())
leftShaft.rads = if (lRads.isNaN()) 0.0 else lRads
rightShaft.rads = if (rRads.isNaN()) 0.0 else rRads
leftShaft.rads = if (lRads.isFinite()) lRads else 0.0
rightShaft.rads = if (rRads.isFinite()) rRads else 0.0
// These calls can still change the speed via mergeShaft
leftShaft.connectShaft(this, front.left())
rightShaft.connectShaft(this, front.right())
Expand Down Expand Up @@ -214,7 +214,7 @@ class ClutchElement(node: TransparentNode, desc_: TransparentNodeDescriptor) : S
inner class ClutchPostProcess : IProcess {
override fun process(time: Double) {
val clutching = inputGate.normalized
if (clutching == 0.0 || clutching.isNaN()) {
if (clutching == 0.0 || !clutching.isFinite()) {
// Utils.println("CP.p: stop: no input")
slipping = true
return
Expand All @@ -240,7 +240,7 @@ class ClutchElement(node: TransparentNode, desc_: TransparentNodeDescriptor) : S

if(leftShaft == rightShaft) Utils.println("WARN (ClutchProcess): Networks are the same!")

val mass = (if (leftShaft.mass.isNaN()) 1.0 else leftShaft.mass) + (if (rightShaft.mass.isNaN()) 1.0 else rightShaft.mass)
val mass = (if (leftShaft.mass.isFinite()) leftShaft.mass else 1.0) + (if (rightShaft.mass.isFinite()) rightShaft.mass else 1.0)
val slower: ShaftNetwork
val faster: ShaftNetwork
val slowerIdx: Int
Expand Down
15 changes: 7 additions & 8 deletions src/main/java/mods/eln/mechanical/ShaftNetwork.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import net.minecraft.server.MinecraftServer
import java.lang.Double.isNaN
import java.util.*


// Speed above which shafts will (by default) explode.
val absoluteMaximumShaftSpeed = 1000.0
// "Standard" drag, in J/t per rad.
Expand All @@ -40,7 +39,7 @@ open class ShaftNetwork() : INBTTReady {
// This has to remain overridable/RO because of things like the fixed shaft - Grissess
open val mass: Double
get() {
return if (_mass.isNaN()) 0.0 else _mass
return if (_mass.isFinite()) _mass else 0.0
}
fun updateCache() {
parts.forEach { elements.add(it.element) }
Expand Down Expand Up @@ -73,21 +72,21 @@ open class ShaftNetwork() : INBTTReady {
// Aggregate properties of the (current) shaft:
var _rads = 0.0
open var rads: Double
get() = if (_rads.isNaN()) 0.0 else _rads
get() = if (_rads.isFinite()) _rads else 0.0
set(v) {
if (!v.isNaN())
if (v.isFinite())
_rads = v
afterSetRads()
}
var radsLastPublished = rads

var energy: Double
get() = if (mass.isNaN() || rads.isNaN()) 0.0 else mass * rads * rads * 0.5 * Eln.shaftEnergyFactor
get() = if (mass.isFinite() && rads.isFinite()) mass * rads * rads * 0.5 * Eln.shaftEnergyFactor else 0.0
set(value) {
if(value < 0 || value.isNaN())
if(value < 0 || !value.isFinite())
rads = 0.0
else
rads = Math.sqrt(2 * value / ((if(mass.isNaN()) 0.0 else mass) * Eln.shaftEnergyFactor))
rads = Math.sqrt(2 * value / ((if(mass.isFinite()) mass else 0.0) * Eln.shaftEnergyFactor))
}

fun afterSetRads() {
Expand Down Expand Up @@ -292,7 +291,7 @@ open class ShaftNetwork() : INBTTReady {

override fun readFromNBT(nbt: NBTTagCompound, str: String?) {
rads = nbt.getFloat(str + "rads").toDouble()
if(isNaN(rads)) rads = 0.0
if(!rads.isFinite()) rads = 0.0
// Utils.println(String.format("SN.rFN: load %s r=%f", this, rads))
}

Expand Down

0 comments on commit befafb7

Please sign in to comment.