Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
mcchampions committed Nov 9, 2024
2 parents c1fe40a + 1425b6d commit 85b3050
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ public void tick(Block b, SlimefunBlockData blockData) {
if (connectorNodes.isEmpty() && terminusNodes.isEmpty()) {
updateHologram(b, "§4找不到能源网络", blockData::isPendingRemove);
} else {
int supply = tickAllGenerators(timestamp::getAndAdd) + tickAllCapacitors();
int generatorsSupply = tickAllGenerators(timestamp::getAndAdd);
int capacitorsSupply = tickAllCapacitors();
int supply = NumberUtils.flowSafeAddition(generatorsSupply, capacitorsSupply);
int remainingEnergy = supply;
int demand = 0;

Expand Down Expand Up @@ -156,7 +158,7 @@ public void tick(Block b, SlimefunBlockData blockData) {

if (charge < capacity) {
int availableSpace = capacity - charge;
demand += availableSpace;
demand = NumberUtils.flowSafeAddition(demand, availableSpace);

if (remainingEnergy > 0) {
if (remainingEnergy > availableSpace) {
Expand Down Expand Up @@ -271,7 +273,7 @@ private int tickAllGenerators(LongConsumer timings) {
loc.getWorld().createExplosion(loc, 0F, false);
});
} else {
supply = MathUtil.saturatedAdd(supply, energy);
supply = NumberUtils.flowSafeAddition(supply, energy);
}
} catch (RuntimeException | LinkageError throwable) {
explodedBlocks.add(loc);
Expand All @@ -294,7 +296,7 @@ private int tickAllCapacitors() {
int supply = 0;

for (Map.Entry<Location, EnergyNetComponent> entry : capacitors.entrySet()) {
supply = MathUtil.saturatedAdd(supply, entry.getValue().getCharge(entry.getKey()));
supply = NumberUtils.flowSafeAddition(supply, entry.getValue().getCharge(entry.getKey()));
}

return supply;
Expand Down

0 comments on commit 85b3050

Please sign in to comment.