Skip to content

Commit

Permalink
Change RateLimit to use TimingUtil.elapsed()
Browse files Browse the repository at this point in the history
  • Loading branch information
zbx1425 committed Aug 14, 2023
1 parent 48eac5c commit ac3b900
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ configure(subprojects.findAll {it.name != 'rhino'}) {
}

dependencies {
annotationProcessor 'systems.manifold:manifold-preprocessor:2023.1.11'
annotationProcessor 'systems.manifold:manifold-preprocessor:+'
minecraft "com.mojang:minecraft:${minecraft_version}"
mappings parchment_not_avail ? loom.officialMojangMappings() : loom.layered() {
officialMojangMappings()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ public void load(Map<ResourceLocation, String> scripts) {
scope.put(classToLoad.substring(classToLoad.lastIndexOf(".") + 1), scope,
new NativeJavaClass(scope, classToLoadClass));
}
scope.put("CompoundTag", scope, new NativeJavaClass(scope, CompoundTag.class));
scope.put("foundMadParticle", scope, true);
} catch (ClassNotFoundException ignored) {
// Main.LOGGER.warn("MadParticle", ignored);
scope.put("foundMadParticle", scope, false);
}
scope.put("CompoundTag", scope, new NativeJavaClass(scope, CompoundTag.class));

ScriptResourceUtil.scriptsToExecute = new ArrayList<>(scripts.entrySet());
for (int i = 0; i < ScriptResourceUtil.scriptsToExecute.size(); i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

public class RateLimit {

private long lastTime = 0;
private final long interval;
private double lastTime = 0;
private final double interval;

public RateLimit(float interval) {
this.interval = (long)(interval * 1000);
public RateLimit(double interval) {
this.interval = interval;
}

public boolean shouldUpdate() {
long now = System.currentTimeMillis();
double now = TimingUtil.elapsed();
if (now - lastTime > interval) {
lastTime = now;
return true;
Expand Down

0 comments on commit ac3b900

Please sign in to comment.