Skip to content

Commit

Permalink
chore: use extra variable to track on other thread
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex4386 committed Jun 19, 2024
1 parent 6e76994 commit bfa60ef
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public class VolcanoLavaFlow implements Listener {

private int configuredLavaInflux = -1;
private double queuedLavaInflux = 0;
private double prevQueuedLavaInflux = 0;

// core methods
public VolcanoLavaFlow(VolcanoVent vent) {
Expand Down Expand Up @@ -1586,15 +1587,19 @@ private void autoFlowLava() {
}
}

prevQueuedLavaInflux = queuedLavaInflux;
queuedLavaInflux = 0;
}

public boolean consumeLavaInflux(double amount) {
if (queuedLavaInflux < amount) {
double realQueuedLavaInflux = Math.max(queuedLavaInflux, prevQueuedLavaInflux);

if (realQueuedLavaInflux < amount) {
return false;
}

queuedLavaInflux -= amount;
realQueuedLavaInflux -= amount;
prevQueuedLavaInflux = realQueuedLavaInflux;
return true;
}

Expand Down

0 comments on commit bfa60ef

Please sign in to comment.