From c6890982531a35312c58a42c8dcb71492968d33a Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 4 Jan 2022 20:05:35 +0700 Subject: [PATCH] Make energy counter be more consistent with lastTick --- .../mc/otm/block/entity/BlockEntityEnergyCounter.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/BlockEntityEnergyCounter.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/BlockEntityEnergyCounter.kt index 65c7f2662..1f4c8fc0d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/BlockEntityEnergyCounter.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/BlockEntityEnergyCounter.kt @@ -37,7 +37,8 @@ class BlockEntityEnergyCounter(p_155229_: BlockPos, p_155230_: BlockState) : Blo fun size() = history.size operator fun get(i: Int) = history[i] - val lastTick: Fraction get() = history[historyTick] + var lastTick: Fraction = Fraction.ZERO + private set fun getHistory(ticks: Int): Array { require(!(ticks < 1 || ticks >= history.size)) { "Invalid history length provided" } @@ -339,6 +340,7 @@ class BlockEntityEnergyCounter(p_155229_: BlockPos, p_155230_: BlockState) : Blo } fun tick() { + lastTick = history[historyTick] historyTick = (historyTick + 1) % history.size history[historyTick] = Fraction.ZERO }