From 530b22d89be5ded6c2842d03987e7527a365281f Mon Sep 17 00:00:00 2001 From: Jika Date: Sun, 19 Oct 2025 11:05:07 +0200 Subject: [PATCH] small fix --- .../KineticOutputHatchBlockEntity.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/imbgt/kineticbridge/blockentity/KineticOutputHatchBlockEntity.java b/src/main/java/com/imbgt/kineticbridge/blockentity/KineticOutputHatchBlockEntity.java index 1dfd429..bb5a570 100644 --- a/src/main/java/com/imbgt/kineticbridge/blockentity/KineticOutputHatchBlockEntity.java +++ b/src/main/java/com/imbgt/kineticbridge/blockentity/KineticOutputHatchBlockEntity.java @@ -65,7 +65,7 @@ public class KineticOutputHatchBlockEntity extends GeneratingKineticBlockEntity private float generatedSpeed = 0.0f; private float lastGeneratedSpeed = 0.0f; private boolean metaUnloaded = false; - private float turbineOcV = 0.0f; + private long turbineOcV = 0L; private int lastCoils = 0; public KineticOutputHatchBlockEntity(BlockEntityType type, BlockPos pos, BlockState blockState) { @@ -96,6 +96,11 @@ public class KineticOutputHatchBlockEntity extends GeneratingKineticBlockEntity int rotorSpeed = turbine.getRotorSpeed(); int maxRotorSpeed = turbine.getMaxRotorHolderSpeed(); + if (maxRotorSpeed <= 0) { + this.generatedSpeed = 0; + finalizeKinetics(); + return; + } float nextSpeed = ((float) rotorSpeed / (float) maxRotorSpeed) * TARGET_RPM; this.generatedSpeed = (float) Math.ceil(nextSpeed); @@ -195,8 +200,9 @@ public class KineticOutputHatchBlockEntity extends GeneratingKineticBlockEntity if (turbine == null) { return 0; } - if (this.turbineOcV != turbine.getOverclockVoltage()) { - this.turbineOcV = turbine.getOverclockVoltage(); + long overclockVoltage = turbine.getOverclockVoltage(); + if (this.turbineOcV != overclockVoltage) { + this.turbineOcV = overclockVoltage; setChanged(); sendData(); } @@ -236,7 +242,7 @@ public class KineticOutputHatchBlockEntity extends GeneratingKineticBlockEntity } super.read(tag, clientPacket); this.generatedSpeed = tag.getFloat("GeneratedSpeed"); - this.turbineOcV = tag.getFloat("TurbineOcV"); + this.turbineOcV = tag.getLong("TurbineOcV"); this.lastCoils = tag.getInt("LastCoils"); } @@ -244,7 +250,7 @@ public class KineticOutputHatchBlockEntity extends GeneratingKineticBlockEntity protected void write(CompoundTag tag, boolean clientPacket) { super.write(tag, clientPacket); tag.putFloat("GeneratedSpeed", this.generatedSpeed); - tag.putFloat("TurbineOcV", this.turbineOcV); + tag.putLong("TurbineOcV", this.turbineOcV); tag.putInt("LastCoils", this.lastCoils); }