diff --git a/src/main/java/cam72cam/immersiverailroading/gui/overlay/Readouts.java b/src/main/java/cam72cam/immersiverailroading/gui/overlay/Readouts.java index add52f74e..7d0c460d8 100644 --- a/src/main/java/cam72cam/immersiverailroading/gui/overlay/Readouts.java +++ b/src/main/java/cam72cam/immersiverailroading/gui/overlay/Readouts.java @@ -43,8 +43,11 @@ public float getValue(EntityRollingStock stock, float lever) { case LIQUID: return stock instanceof FreightTank ? ((FreightTank) stock).getPercentLiquidFull() / 100f : 0; case SPEED: - return (float)Math.abs(((EntityMoveableRollingStock)stock).getCurrentSpeed().metric() / - (stock instanceof Locomotive ? ((Locomotive) stock).getDefinition().getMaxSpeed(stock.gauge).metric() : 200)); + double maxSpeed = (stock instanceof Locomotive ? ((Locomotive) stock).getDefinition().getMaxSpeed(stock.gauge).metric() : 0); + if (maxSpeed == 0) { + maxSpeed = 200; + } + return (float)Math.abs(((EntityMoveableRollingStock)stock).getCurrentSpeed().metric() / maxSpeed); case TEMPERATURE: if (stock instanceof LocomotiveSteam) { return ((LocomotiveSteam) stock).getBoilerTemperature() / 100f; diff --git a/src/main/java/cam72cam/immersiverailroading/model/part/ValveGear.java b/src/main/java/cam72cam/immersiverailroading/model/part/ValveGear.java index d8a761d0c..e7f3a71ea 100644 --- a/src/main/java/cam72cam/immersiverailroading/model/part/ValveGear.java +++ b/src/main/java/cam72cam/immersiverailroading/model/part/ValveGear.java @@ -233,6 +233,9 @@ public void update(Vec3d particlePos, boolean enteredStroke, boolean drain_enabl double speed = Math.abs(stock.getCurrentSpeed().minecraft()); double maxSpeed = Math.abs(stock.getDefinition().getMaxSpeed(stock.gauge).minecraft()); + if (maxSpeed == 0) { + maxSpeed = 200; + } float volume = (float) Math.max(1-speed/maxSpeed, 0.3) * Math.abs(stock.getThrottle() * stock.getReverser()); volume = (float) Math.sqrt(volume); double fraction = 3;