diff --git a/src/main/java/de/scribble/lp/tasmod/mixin/MixinMinecraftServer.java b/src/main/java/de/scribble/lp/tasmod/mixin/MixinMinecraftServer.java index 9a54bd17..cf3a34a7 100644 --- a/src/main/java/de/scribble/lp/tasmod/mixin/MixinMinecraftServer.java +++ b/src/main/java/de/scribble/lp/tasmod/mixin/MixinMinecraftServer.java @@ -37,7 +37,7 @@ public long modifyMSPT(long fiftyLong) { @Redirect(method = "run", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;tick()V", ordinal = 1)) public void redirectTick(MinecraftServer server) { this.tick(); - if (SavestateHandler.state==SavestateState.WASLOADING) { + if (SavestateHandler.state == SavestateState.WASLOADING) { SavestateHandler.state = SavestateState.NONE; SavestateHandler.playerLoadSavestateEventServer(); } @@ -77,11 +77,11 @@ public long redirectMathMax(long oneLong, long i) { @Shadow private Queue> futureTaskQueue; - + @Shadow private NetworkSystem networkSystem; - - private int faketick=0; + + private int faketick = 0; @Redirect(method = "run", at = @At(value = "INVOKE", target = "Ljava/lang/Thread;sleep(J)V")) public void redirectThreadSleep(long msToTick) { @@ -93,13 +93,15 @@ public void redirectThreadSleep(long msToTick) { msToTick = 1L; } for (long o = 0; o < msToTick; o++) { - if(TickrateChangerServer.TICKS_PER_SECOND==0) { - currentTime=System.currentTimeMillis(); + if (TickrateChangerServer.TICKS_PER_SECOND == 0) { + currentTime = System.currentTimeMillis(); faketick++; - if(faketick>=20) { - faketick=0; + if (faketick >= 20) { + faketick = 0; networkSystem.networkTick(); - runPendingCommands(); + if (((MinecraftServer) (Object) this).isDedicatedServer()) { + runPendingCommands(); + } } } if (TickrateChangerServer.INTERRUPT) { @@ -116,7 +118,7 @@ public void redirectThreadSleep(long msToTick) { } } } - + try { Thread.sleep(1L); } catch (InterruptedException e) { @@ -128,14 +130,14 @@ public void redirectThreadSleep(long msToTick) { @SideOnly(Side.SERVER) private void runPendingCommands() { - if((MinecraftServer)(Object)this instanceof net.minecraft.server.dedicated.DedicatedServer) { - net.minecraft.server.dedicated.DedicatedServer server=(net.minecraft.server.dedicated.DedicatedServer)(MinecraftServer)(Object)this; + if ((MinecraftServer) (Object) this instanceof net.minecraft.server.dedicated.DedicatedServer) { + net.minecraft.server.dedicated.DedicatedServer server = (net.minecraft.server.dedicated.DedicatedServer) (MinecraftServer) (Object) this; server.executePendingCommands(); } } // ===================================================================================================================================== - + // @Inject(method = "tick", at = @At("HEAD")) // public void lagServer(CallbackInfo ci) { // if(SavestateEvents.lagServer) { @@ -147,7 +149,7 @@ private void runPendingCommands() { // } // } // } - + // @ModifyVariable(method = "run", at = @At(value = "STORE"), index = 5, ordinal = 2) // public long limitLag(long j) { // if(j>(500L*(20/TickrateChangerServer.TICKS_PER_SECOND))){ @@ -155,5 +157,5 @@ private void runPendingCommands() { // } // return j; // } - + }