fix: smoother time transition
This commit is contained in:
3 files changed
+13
-6
No files matched your search
@@ -1,7 +1,6 @@
|
||||
package io.ib67.sfcraft.mixin.server;
|
||||
|
||||
import io.ib67.sfcraft.module.randomevt.longnight.LongNightEvent;
|
||||
import io.ib67.sfcraft.util.Helper;
|
||||
import io.ib67.sfcraft.util.MixinHelper;
|
||||
import io.ib67.sfcraft.util.SFConsts;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -12,11 +11,12 @@ import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(MinecraftServer.class)
|
||||
public class MinecraftServerMixin {
|
||||
public abstract class MinecraftServerMixin {
|
||||
|
||||
@ModifyConstant(method = "tickWorlds", constant = @Constant(intValue = 20))
|
||||
private int speedUpAtNight(int constant) {
|
||||
if (LongNightEvent.isRunning()) {
|
||||
return 5;
|
||||
if (MixinHelper.spedUp) {
|
||||
return 2;
|
||||
}
|
||||
return constant;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package io.ib67.sfcraft.mixin.server;
|
||||
|
||||
import io.ib67.sfcraft.mixin.server.bridge.ServerWorldBridge;
|
||||
import io.ib67.sfcraft.util.MixinHelper;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.world.GameRules;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.*;
|
||||
|
||||
@Mixin(ServerWorld.class)
|
||||
@@ -13,8 +13,10 @@ public abstract class ServerWorldMixin {
|
||||
public long setTimeOfDay(long timeOfDay) {
|
||||
int i = ((ServerWorld) (Object) this).getGameRules().getInt(GameRules.PLAYERS_SLEEPING_PERCENTAGE);
|
||||
if (((ServerWorldBridge) this).getSleepManager().canSkipNight(i)) {
|
||||
MixinHelper.spedUp = true;
|
||||
return timeOfDay + 10;
|
||||
}
|
||||
MixinHelper.spedUp = false;
|
||||
return timeOfDay;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package io.ib67.sfcraft.util;
|
||||
|
||||
public class MixinHelper {
|
||||
public static boolean spedUp;
|
||||
}
|
||||
Reference in new issue
Block a user