aboutsummaryrefslogtreecommitdiff
path: root/spark-forge/src
diff options
context:
space:
mode:
authorLuck <git@lucko.me>2021-08-19 20:50:08 +0100
committerLuck <git@lucko.me>2021-08-19 20:50:15 +0100
commit65e216657e4ac86d4e1a1bee30033d9b27f5f217 (patch)
tree52d5b7f3abd5dd3e2f134a0c08aa2705effd6c5c /spark-forge/src
parentc4f96ced241802e40076d704b8977e2b35aff2b6 (diff)
downloadspark-65e216657e4ac86d4e1a1bee30033d9b27f5f217.tar.gz
spark-65e216657e4ac86d4e1a1bee30033d9b27f5f217.tar.bz2
spark-65e216657e4ac86d4e1a1bee30033d9b27f5f217.zip
Abstract tick reporter
Diffstat (limited to 'spark-forge/src')
-rw-r--r--spark-forge/src/main/java/me/lucko/spark/forge/ForgeTickReporter.java23
1 files changed, 6 insertions, 17 deletions
diff --git a/spark-forge/src/main/java/me/lucko/spark/forge/ForgeTickReporter.java b/spark-forge/src/main/java/me/lucko/spark/forge/ForgeTickReporter.java
index d03b2d6..c33443b 100644
--- a/spark-forge/src/main/java/me/lucko/spark/forge/ForgeTickReporter.java
+++ b/spark-forge/src/main/java/me/lucko/spark/forge/ForgeTickReporter.java
@@ -20,18 +20,16 @@
package me.lucko.spark.forge;
-import me.lucko.spark.common.tick.AbstractTickReporter;
+import me.lucko.spark.common.tick.SimpleTickReporter;
import me.lucko.spark.common.tick.TickReporter;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
-public class ForgeTickReporter extends AbstractTickReporter implements TickReporter {
+public class ForgeTickReporter extends SimpleTickReporter implements TickReporter {
private final TickEvent.Type type;
- private long start = 0;
-
public ForgeTickReporter(TickEvent.Type type) {
this.type = type;
}
@@ -43,19 +41,9 @@ public class ForgeTickReporter extends AbstractTickReporter implements TickRepor
}
switch (e.phase) {
- case START:
- this.start = System.nanoTime();
- break;
- case END:
- if (this.start == 0) {
- return;
- }
-
- double duration = (System.nanoTime() - this.start) / 1000000d;
- onTick(duration);
- break;
- default:
- throw new AssertionError(e.phase);
+ case START -> onStart();
+ case END -> onEnd();
+ default -> throw new AssertionError(e.phase);
}
}
@@ -67,6 +55,7 @@ public class ForgeTickReporter extends AbstractTickReporter implements TickRepor
@Override
public void close() {
MinecraftForge.EVENT_BUS.unregister(this);
+ super.close();
}
}