diff options
author | Luck <git@lucko.me> | 2021-08-19 20:50:08 +0100 |
---|---|---|
committer | Luck <git@lucko.me> | 2021-08-19 20:50:15 +0100 |
commit | 65e216657e4ac86d4e1a1bee30033d9b27f5f217 (patch) | |
tree | 52d5b7f3abd5dd3e2f134a0c08aa2705effd6c5c /spark-forge/src | |
parent | c4f96ced241802e40076d704b8977e2b35aff2b6 (diff) | |
download | spark-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.java | 23 |
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(); } } |