Skip to content

Commit

Permalink
Re-add poll rate
Browse files Browse the repository at this point in the history
  • Loading branch information
tr7zw committed Aug 2, 2024
1 parent 01dfe34 commit 7bc5a66
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/main/java/dev/tr7zw/exordium/components/BufferInstance.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.List;
import java.util.function.Supplier;

import dev.tr7zw.exordium.ExordiumModBase;
import dev.tr7zw.exordium.render.BufferedComponent;
import dev.tr7zw.exordium.util.PacingTracker;
import dev.tr7zw.exordium.util.ReloadListener;
Expand Down Expand Up @@ -50,8 +51,7 @@ public boolean renderBuffer(int ticks, T context) {
return false;
}

boolean updateFrame = buffer.screenChanged()
|| (pacing.isCooldownOver() && (hasUpdate() || component.hasChanged(ticks, context)));
boolean updateFrame = buffer.screenChanged() || (pacing.isCooldownOver() && hasUpdate(ticks, context));

if (updateFrame) {
// start capturing
Expand All @@ -64,12 +64,17 @@ public boolean renderBuffer(int ticks, T context) {
return true;
}

private boolean hasUpdate() {
private boolean hasUpdate(int ticks, T context) {
for (Supplier<Boolean> listener : updateListeners) {
if (listener.get()) {
return true;
}
}
if (component.hasChanged(ticks, context)) {
return true;
}
// nothing changed, so wait the poll rate for the next check
pacing.setCooldown(System.currentTimeMillis() + (1000 / ExordiumModBase.instance.config.pollRate));
return false;
}

Expand Down

0 comments on commit 7bc5a66

Please sign in to comment.