diff --git a/src/main/java/com/github/steveplays28/realisticsleep/config/ModMenuIntegration.java b/src/main/java/com/github/steveplays28/realisticsleep/client/compat/ModMenuIntegration.java similarity index 77% rename from src/main/java/com/github/steveplays28/realisticsleep/config/ModMenuIntegration.java rename to src/main/java/com/github/steveplays28/realisticsleep/client/compat/ModMenuIntegration.java index 97b523d..3ec0e38 100644 --- a/src/main/java/com/github/steveplays28/realisticsleep/config/ModMenuIntegration.java +++ b/src/main/java/com/github/steveplays28/realisticsleep/client/compat/ModMenuIntegration.java @@ -1,5 +1,6 @@ -package com.github.steveplays28.realisticsleep.config; +package com.github.steveplays28.realisticsleep.client.compat; +import com.github.steveplays28.realisticsleep.config.RealisticSleepConfig; import com.terraformersmc.modmenu.api.ConfigScreenFactory; import com.terraformersmc.modmenu.api.ModMenuApi; import me.shedaniel.autoconfig.AutoConfig; diff --git a/src/main/java/com/github/steveplays28/realisticsleep/mixin/ServerPlayerEntityMixin.java b/src/main/java/com/github/steveplays28/realisticsleep/mixin/ServerPlayerEntityMixin.java index 69c7048..0f1c928 100644 --- a/src/main/java/com/github/steveplays28/realisticsleep/mixin/ServerPlayerEntityMixin.java +++ b/src/main/java/com/github/steveplays28/realisticsleep/mixin/ServerPlayerEntityMixin.java @@ -1,6 +1,6 @@ package com.github.steveplays28.realisticsleep.mixin; -import com.github.steveplays28.realisticsleep.SleepMath; +import com.github.steveplays28.realisticsleep.util.SleepMathUtil; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraft.server.network.ServerPlayerEntity; @@ -28,13 +28,13 @@ public ServerPlayerEntityMixin(EntityType type, World world) { @Inject(method = "wakeUp(ZZ)V", at = @At(value = "HEAD")) public void wakeUpInject(boolean skipSleepTimer, boolean updateSleepingPlayers, CallbackInfo ci) { - if (!SleepMath.isNightTime(getWorld().getTimeOfDay())) { + if (!SleepMathUtil.isNightTime(getWorld().getTimeOfDay())) { // Return if we shouldn't send the dawn message if (!config.sendDawnMessage || config.dawnMessage.isEmpty()) return; // Send dawn HUD message to player sendMessage(Text.of(config.dawnMessage), true); - } else if (config.allowDaySleeping && SleepMath.isNightTime(getWorld().getTimeOfDay())) { //Only shows this message if day sleeping is allowed + } else if (config.allowDaySleeping && SleepMathUtil.isNightTime(getWorld().getTimeOfDay())) { //Only shows this message if day sleeping is allowed // Return if we shouldn't send the dawn or dusk message if (!config.sendDuskMessage || config.duskMessage.isEmpty()) return; diff --git a/src/main/java/com/github/steveplays28/realisticsleep/mixin/ServerWorldMixin.java b/src/main/java/com/github/steveplays28/realisticsleep/mixin/ServerWorldMixin.java index 8141af8..ad29aea 100644 --- a/src/main/java/com/github/steveplays28/realisticsleep/mixin/ServerWorldMixin.java +++ b/src/main/java/com/github/steveplays28/realisticsleep/mixin/ServerWorldMixin.java @@ -1,6 +1,6 @@ package com.github.steveplays28.realisticsleep.mixin; -import com.github.steveplays28.realisticsleep.SleepMath; +import com.github.steveplays28.realisticsleep.util.SleepMathUtil; import net.minecraft.network.packet.s2c.play.WorldTimeUpdateS2CPacket; import net.minecraft.server.MinecraftServer; import net.minecraft.server.network.ServerPlayerEntity; @@ -32,7 +32,7 @@ import static com.github.steveplays28.realisticsleep.RealisticSleep.MOD_ID; import static com.github.steveplays28.realisticsleep.RealisticSleep.config; -import static com.github.steveplays28.realisticsleep.SleepMath.DAY_LENGTH; +import static com.github.steveplays28.realisticsleep.util.SleepMathUtil.DAY_LENGTH; @Mixin(ServerWorld.class) public abstract class ServerWorldMixin extends World { @@ -83,10 +83,10 @@ public void tickInject(BooleanSupplier shouldKeepTicking, CallbackInfo ci) { int sleepingPlayerCount = sleepManager.getSleeping(); // TODO: Don't assume the TPS is 20 int secondsUntilAwake = Math.abs( - SleepMath.calculateSecondsUntilAwake((int) worldProperties.getTimeOfDay() % DAY_LENGTH, nightTimeStepPerTick, 20)); + SleepMathUtil.calculateSecondsUntilAwake((int) worldProperties.getTimeOfDay() % DAY_LENGTH, nightTimeStepPerTick, 20)); //Gets the remainder of the current time of day, as this number never actually resets each day(from my own testing) - int ticksUntilAwake = SleepMath.calculateTicksUntilAwake((int) worldProperties.getTimeOfDay() % DAY_LENGTH); + int ticksUntilAwake = SleepMathUtil.calculateTicksUntilAwake((int) worldProperties.getTimeOfDay() % DAY_LENGTH); // Check if the night has (almost) ended and the weather should be skipped if (secondsUntilAwake <= 2 && shouldSkipWeather) { @@ -104,9 +104,9 @@ public void tickInject(BooleanSupplier shouldKeepTicking, CallbackInfo ci) { double sleepingRatio = (double) sleepingPlayerCount / playerCount; double sleepingPercentage = sleepingRatio * 100; - nightTimeStepPerTick = SleepMath.calculateNightTimeStepPerTick(sleepingRatio, config.sleepSpeedMultiplier, nightTimeStepPerTick); + nightTimeStepPerTick = SleepMathUtil.calculateNightTimeStepPerTick(sleepingRatio, config.sleepSpeedMultiplier, nightTimeStepPerTick); nightTimeStepPerTickRounded = (int) Math.round(nightTimeStepPerTick); - var isNight = SleepMath.isNightTime(worldProperties.getTimeOfDay()); + var isNight = SleepMathUtil.isNightTime(worldProperties.getTimeOfDay()); var nightDayOrThunderstormText = Text.translatable( String.format("%s.text.%s", MOD_ID, worldProperties.isThundering() ? "thunderstorm" : isNight ? "night" : "day")); @@ -247,7 +247,7 @@ private void clearWeather() { if (doWeatherCycle && (worldProperties.isRaining() || worldProperties.isThundering())) { // Reset weather clock and clear weather - var nextRainTime = (int) (DAY_LENGTH * SleepMath.getRandomNumberInRange(0.5, 7.5)); + var nextRainTime = (int) (DAY_LENGTH * SleepMathUtil.getRandomNumberInRange(0.5, 7.5)); worldProperties.setRainTime(nextRainTime); worldProperties.setThunderTime(nextRainTime + (Math.random() > 0 ? 1 : -1)); diff --git a/src/main/java/com/github/steveplays28/realisticsleep/SleepMath.java b/src/main/java/com/github/steveplays28/realisticsleep/util/SleepMathUtil.java similarity index 93% rename from src/main/java/com/github/steveplays28/realisticsleep/SleepMath.java rename to src/main/java/com/github/steveplays28/realisticsleep/util/SleepMathUtil.java index 6c993c1..f9ceb7a 100644 --- a/src/main/java/com/github/steveplays28/realisticsleep/SleepMath.java +++ b/src/main/java/com/github/steveplays28/realisticsleep/util/SleepMathUtil.java @@ -1,8 +1,8 @@ -package com.github.steveplays28.realisticsleep; +package com.github.steveplays28.realisticsleep.util; import static com.github.steveplays28.realisticsleep.RealisticSleep.config; -public class SleepMath { +public class SleepMathUtil { public static final int DAY_LENGTH = 24000; public static final int SUNRISE_WAKE_UP = 23449; public static final int SUNSET_WAKE_UP = 12449; diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index db8beab..65c13e6 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -35,7 +35,7 @@ "com.github.steveplays28.realisticsleep.RealisticSleep" ], "modmenu": [ - "com.github.steveplays28.realisticsleep.config.ModMenuIntegration" + "com.github.steveplays28.realisticsleep.client.compat.ModMenuIntegration" ] }, "mixins": [