From fb53db0025a883bd9b798ddef13196a0b3d05e75 Mon Sep 17 00:00:00 2001 From: liach Date: Sun, 12 Jan 2020 14:19:18 +0000 Subject: Update fabric mod to 1.15.1 --- .../me/lucko/spark/fabric/FabricTickCounter.java | 34 ++++++++++++++-------- 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'spark-fabric/src/main/java/me/lucko/spark/fabric/FabricTickCounter.java') 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); } } } -- cgit