Skip to content

Commit

Permalink
Merge pull request #1383 from Gu-ZT/releases/1.21
Browse files Browse the repository at this point in the history
修复集电器周期问题,修复电网停摆后不执行电网刻逻辑的问题
  • Loading branch information
Gu-ZT authored Dec 20, 2024
2 parents ff4bf67 + c39c83b commit 6964505
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
14 changes: 6 additions & 8 deletions src/main/java/dev/dubhe/anvilcraft/api/power/PowerGrid.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +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);
return;
}
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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
Expand Down

0 comments on commit 6964505

Please sign in to comment.