Skip to content

Commit

Permalink
feat: Add Better Clouds compatibility
Browse files Browse the repository at this point in the history
(cherry picked from commit 682ff73)
  • Loading branch information
Steveplays28 committed Dec 7, 2023
1 parent b363d6e commit a85de5e
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 40 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
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;
Expand Down Expand Up @@ -38,5 +42,16 @@ 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.worldRenderingSpeedMultiplier; i++) {
MinecraftClient.getInstance().worldRenderer.tick();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class RealisticSleepConfig implements ConfigData {
@ConfigEntry.Gui.Tooltip
public double fluidRandomTickSpeedMultiplier = 1d;
@ConfigEntry.Gui.Tooltip
public float cloudSpeedMultiplier = 25f;
public float worldRenderingSpeedMultiplier = 25f;

@ConfigEntry.Gui.Tooltip
public long tickDelay = -1;
Expand Down

This file was deleted.

4 changes: 2 additions & 2 deletions src/main/resources/assets/realisticsleep/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
"text.autoconfig.realisticsleep.option.blockRandomTickSpeedMultiplier.@Tooltip": "How many times faster blocks should random tick. Enable at your own risk, may cause huge TPS loss!",
"text.autoconfig.realisticsleep.option.fluidRandomTickSpeedMultiplier": "Fluid random tick speed multiplier",
"text.autoconfig.realisticsleep.option.fluidRandomTickSpeedMultiplier.@Tooltip": "How many times faster fluids should random tick. Enable at your own risk, may cause huge TPS loss!",
"text.autoconfig.realisticsleep.option.cloudSpeedMultiplier": "Cloud speed multiplier",
"text.autoconfig.realisticsleep.option.cloudSpeedMultiplier.@Tooltip": "How many times faster clouds should move.",
"text.autoconfig.realisticsleep.option.worldRenderingSpeedMultiplier": "World rendering speed multiplier",
"text.autoconfig.realisticsleep.option.worldRenderingSpeedMultiplier.@Tooltip": "How many times faster clouds should move, rain should fall, and thunder should strike.",
"text.autoconfig.realisticsleep.option.tickDelay": "Tick delay",
"text.autoconfig.realisticsleep.option.tickDelay.@Tooltip": "Adds an amount of ticks delay to every tick, so time goes slower.",
"realisticsleep.text.sleep_message": "%d/%d players are sleeping through this ",
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/data/realisticsleep/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
"text.autoconfig.realisticsleep.option.blockRandomTickSpeedMultiplier.@Tooltip": "How many times faster blocks should random tick. Enable at your own risk, may cause huge TPS loss!",
"text.autoconfig.realisticsleep.option.fluidRandomTickSpeedMultiplier": "Fluid random tick speed multiplier",
"text.autoconfig.realisticsleep.option.fluidRandomTickSpeedMultiplier.@Tooltip": "How many times faster fluids should random tick. Enable at your own risk, may cause huge TPS loss!",
"text.autoconfig.realisticsleep.option.cloudSpeedMultiplier": "Cloud speed multiplier",
"text.autoconfig.realisticsleep.option.cloudSpeedMultiplier.@Tooltip": "How many times faster clouds should move.",
"text.autoconfig.realisticsleep.option.worldRenderingSpeedMultiplier": "World rendering speed multiplier",
"text.autoconfig.realisticsleep.option.worldRenderingSpeedMultiplier.@Tooltip": "How many times faster clouds should move, rain should fall, and thunder should strike.",
"text.autoconfig.realisticsleep.option.tickDelay": "Tick delay",
"text.autoconfig.realisticsleep.option.tickDelay.@Tooltip": "Adds an amount of ticks delay to every tick, so time goes slower.",
"realisticsleep.text.sleep_message": "%d/%d players are sleeping through this ",
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@
"fabric": ">=${fabric_version}"
},
"suggests": {
"modmenu": ">=${modmenu_version}"
"modmenu": ">=${modmenu_version}",
"sodium": "*",
"better-clouds": "*"
},
"conflicts": {
"tawct": "*",
Expand Down
3 changes: 0 additions & 3 deletions src/main/resources/realisticsleep.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
"SleepManagerMixin",
"accessor.ServerWorldAccessor"
],
"client": [
"WorldRendererMixin"
],
"injectors": {
"defaultRequire": 1
}
Expand Down

0 comments on commit a85de5e

Please sign in to comment.