From c0a276acf784a20d1437b68d85cf35dc821a110c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9leste=20Wouters?= Date: Thu, 5 Sep 2024 13:18:23 +0200 Subject: [PATCH] Emit ComputerCraft events from Speedometers/Stressometers - Emit CC event `overstressed` from Stressometers - Emit CC event `stress_change` from Stressometers - 2 arguments: stress (SU), capacity (SU) - Emit CC event `speed_change` from Speedometers - 1 argument: speed (RPM) --- .../events/KineticsChangeEvent.java | 17 +++++++++++++++++ .../peripherals/SpeedGaugePeripheral.java | 10 ++++++++++ .../peripherals/StressGaugePeripheral.java | 13 +++++++++++++ .../kinetics/base/KineticBlockEntity.java | 5 +++++ .../kinetics/gauge/SpeedGaugeBlockEntity.java | 2 ++ .../kinetics/gauge/StressGaugeBlockEntity.java | 3 +++ 6 files changed, 50 insertions(+) create mode 100644 src/main/java/com/simibubi/create/compat/computercraft/events/KineticsChangeEvent.java diff --git a/src/main/java/com/simibubi/create/compat/computercraft/events/KineticsChangeEvent.java b/src/main/java/com/simibubi/create/compat/computercraft/events/KineticsChangeEvent.java new file mode 100644 index 0000000000..4918c8155c --- /dev/null +++ b/src/main/java/com/simibubi/create/compat/computercraft/events/KineticsChangeEvent.java @@ -0,0 +1,17 @@ +package com.simibubi.create.compat.computercraft.events; + +public class KineticsChangeEvent implements ComputerEvent { + + public float speed; + public float capacity; + public float stress; + public boolean overStressed; + + public KineticsChangeEvent(float speed, float capacity, float stress, boolean overStressed) { + this.speed = speed; + this.capacity = capacity; + this.stress = stress; + this.overStressed = overStressed; + } + +} diff --git a/src/main/java/com/simibubi/create/compat/computercraft/implementation/peripherals/SpeedGaugePeripheral.java b/src/main/java/com/simibubi/create/compat/computercraft/implementation/peripherals/SpeedGaugePeripheral.java index d6ff9d20bf..af5afc98f6 100644 --- a/src/main/java/com/simibubi/create/compat/computercraft/implementation/peripherals/SpeedGaugePeripheral.java +++ b/src/main/java/com/simibubi/create/compat/computercraft/implementation/peripherals/SpeedGaugePeripheral.java @@ -2,6 +2,9 @@ package com.simibubi.create.compat.computercraft.implementation.peripherals; import org.jetbrains.annotations.NotNull; + +import com.simibubi.create.compat.computercraft.events.ComputerEvent; +import com.simibubi.create.compat.computercraft.events.KineticsChangeEvent; import com.simibubi.create.content.kinetics.gauge.SpeedGaugeBlockEntity; import dan200.computercraft.api.lua.LuaFunction; @@ -17,6 +20,13 @@ public class SpeedGaugePeripheral extends SyncedPeripheral