diff --git a/src/main/java/dev/dubhe/anvilcraft/api/power/PowerGrid.java b/src/main/java/dev/dubhe/anvilcraft/api/power/PowerGrid.java index 977219bb6..0ada61173 100644 --- a/src/main/java/dev/dubhe/anvilcraft/api/power/PowerGrid.java +++ b/src/main/java/dev/dubhe/anvilcraft/api/power/PowerGrid.java @@ -119,11 +119,12 @@ protected void tick() { for (IPowerStorage storage : this.storages) { need -= storage.getOutputPower(); storages.add(storage); - if (need <= 0) break; - } - if (need > 0) this.update(false); - else for (IPowerStorage storage : storages) { - this.generate += storage.extract(this.consume - this.generate); + if (need <= 0) { + for (IPowerStorage selectStorage : storages) { + this.generate += selectStorage.extract(this.consume - this.generate); + } + break; + } } } this.gridTick(); diff --git a/src/main/java/dev/dubhe/anvilcraft/block/entity/ChargeCollectorBlockEntity.java b/src/main/java/dev/dubhe/anvilcraft/block/entity/ChargeCollectorBlockEntity.java index 8ab4ceeae..480e0152b 100644 --- a/src/main/java/dev/dubhe/anvilcraft/block/entity/ChargeCollectorBlockEntity.java +++ b/src/main/java/dev/dubhe/anvilcraft/block/entity/ChargeCollectorBlockEntity.java @@ -98,16 +98,12 @@ public void saveAdditional(@NotNull CompoundTag tag, HolderLookup.@NotNull Provi @Override public void gridTick() { - if (this.cooldownCount > 1) { - this.cooldownCount -= 1; - return; - } + if (level == null || level.isClientSide()) return; + if (this.cooldownCount-- > 1) return; this.cooldownCount = COOLDOWN; int oldPower = this.power; this.power = (int) Math.floor(this.chargeCount); - if (power != oldPower && grid != null) { - grid.markChanged(); - } + if (power != oldPower && grid != null) grid.markChanged(); this.chargeCount = 0; time++; }