diff --git a/src/main/java/com/github/steveplays28/realisticsleep/RealisticSleep.java b/src/main/java/com/github/steveplays28/realisticsleep/RealisticSleep.java index a643df4..5b97fad 100644 --- a/src/main/java/com/github/steveplays28/realisticsleep/RealisticSleep.java +++ b/src/main/java/com/github/steveplays28/realisticsleep/RealisticSleep.java @@ -1,15 +1,11 @@ package com.github.steveplays28.realisticsleep; -import com.github.steveplays28.realisticsleep.api.RealisticSleepApi; import com.github.steveplays28.realisticsleep.config.RealisticSleepConfig; import me.shedaniel.autoconfig.AutoConfig; import me.shedaniel.autoconfig.serializer.GsonConfigSerializer; import net.fabricmc.api.ModInitializer; -import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; import net.fabricmc.fabric.api.entity.event.v1.EntitySleepEvents; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.world.ClientWorld; import net.minecraft.util.ActionResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -42,16 +38,5 @@ public void onInitialize() { return ActionResult.PASS; })); - - // Tick the world renderer faster while sleeping - ClientTickEvents.START_WORLD_TICK.register(this::tickWorldRendererFasterWhileSleeping); - } - - private void tickWorldRendererFasterWhileSleeping(ClientWorld world) { - if (RealisticSleepApi.isSleeping(world)) { - for (int i = 0; i < config.worldRendererTickSpeedMultiplier; i++) { - MinecraftClient.getInstance().worldRenderer.tick(); - } - } } } diff --git a/src/main/java/com/github/steveplays28/realisticsleep/client/compat/RealisticSleepClient.java b/src/main/java/com/github/steveplays28/realisticsleep/client/compat/RealisticSleepClient.java new file mode 100644 index 0000000..a80f110 --- /dev/null +++ b/src/main/java/com/github/steveplays28/realisticsleep/client/compat/RealisticSleepClient.java @@ -0,0 +1,27 @@ +package com.github.steveplays28.realisticsleep.client.compat; + +import com.github.steveplays28.realisticsleep.api.RealisticSleepApi; +import net.fabricmc.api.ClientModInitializer; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.world.ClientWorld; + +import static com.github.steveplays28.realisticsleep.RealisticSleep.config; + +@Environment(EnvType.CLIENT) +public class RealisticSleepClient implements ClientModInitializer { + @Override + public void onInitializeClient() { + ClientTickEvents.START_WORLD_TICK.register(this::tickWorldRendererFasterWhileSleeping); + } + + private void tickWorldRendererFasterWhileSleeping(ClientWorld world) { + if (RealisticSleepApi.isSleeping(world)) { + for (int i = 0; i < config.worldRendererTickSpeedMultiplier; i++) { + MinecraftClient.getInstance().worldRenderer.tick(); + } + } + } +} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 69687b2..81c4218 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -34,6 +34,9 @@ "main": [ "com.github.steveplays28.realisticsleep.RealisticSleep" ], + "client": [ + "com.github.steveplays28.realisticsleep.client.compat.RealisticSleepClient" + ], "modmenu": [ "com.github.steveplays28.realisticsleep.client.compat.ModMenuIntegration" ]