aboutsummaryrefslogtreecommitdiff
path: root/spark-fabric/src/main/java/me/lucko/spark/fabric/FabricTickCounter.java
diff options
context:
space:
mode:
authorliach <liach@users.noreply.github.com>2020-01-12 14:19:18 +0000
committerLuck <git@lucko.me>2020-01-12 14:19:44 +0000
commitfb53db0025a883bd9b798ddef13196a0b3d05e75 (patch)
treec76f7f7f441aa5e0d0cd49a363549b8bd284ab86 /spark-fabric/src/main/java/me/lucko/spark/fabric/FabricTickCounter.java
parent2fe79f4140011f93df1567afcc9b75fababa187e (diff)
downloadspark-fb53db0025a883bd9b798ddef13196a0b3d05e75.tar.gz
spark-fb53db0025a883bd9b798ddef13196a0b3d05e75.tar.bz2
spark-fb53db0025a883bd9b798ddef13196a0b3d05e75.zip
Update fabric mod to 1.15.1
Diffstat (limited to 'spark-fabric/src/main/java/me/lucko/spark/fabric/FabricTickCounter.java')
-rw-r--r--spark-fabric/src/main/java/me/lucko/spark/fabric/FabricTickCounter.java34
1 files changed, 22 insertions, 12 deletions
diff --git a/spark-fabric/src/main/java/me/lucko/spark/fabric/FabricTickCounter.java b/spark-fabric/src/main/java/me/lucko/spark/fabric/FabricTickCounter.java
index ce58dcf..7781e03 100644
--- a/spark-fabric/src/main/java/me/lucko/spark/fabric/FabricTickCounter.java
+++ b/spark-fabric/src/main/java/me/lucko/spark/fabric/FabricTickCounter.java
@@ -22,35 +22,45 @@ package me.lucko.spark.fabric;
import me.lucko.spark.common.sampler.AbstractTickCounter;
import me.lucko.spark.common.sampler.TickCounter;
+import net.fabricmc.fabric.api.event.client.ClientTickCallback;
+import net.fabricmc.fabric.api.event.server.ServerTickCallback;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.server.MinecraftServer;
public abstract class FabricTickCounter extends AbstractTickCounter implements TickCounter {
+ protected boolean closed = false;
+
@Override
- public void onTick() {
- super.onTick();
+ public void close() {
+ this.closed = true;
}
- public static final class Server extends FabricTickCounter {
+ public static final class Server extends FabricTickCounter implements ServerTickCallback {
@Override
- public void start() {
- FabricSparkGameHooks.INSTANCE.addServerCounter(this);
+ public void tick(MinecraftServer minecraftServer) {
+ if (!this.closed) {
+ onTick();
+ }
}
@Override
- public void close() {
- FabricSparkGameHooks.INSTANCE.removeServerCounter(this);
+ public void start() {
+ ServerTickCallback.EVENT.register(this);
}
}
- public static final class Client extends FabricTickCounter {
+ public static final class Client extends FabricTickCounter implements ClientTickCallback {
@Override
- public void start() {
- FabricSparkGameHooks.INSTANCE.addClientCounter(this);
+ public void tick(MinecraftClient minecraftClient) {
+ if (!this.closed) {
+ onTick();
+ }
}
@Override
- public void close() {
- FabricSparkGameHooks.INSTANCE.removeClientCounter(this);
+ public void start() {
+ ClientTickCallback.EVENT.register(this);
}
}
}