1 parent
17de3ea21e
commit
b77268553e
2 files changed
+28
-8
No files matched your search
@@ -39,7 +39,7 @@ public abstract class MinecraftServer_scarpetMixin extends ReentrantThreadExecut
|
||||
{
|
||||
timeReference = field_4557 = Util.getMeasuringTimeMs();
|
||||
tick(isAhead);
|
||||
runTask();
|
||||
while(runTask()) {Thread.yield();}
|
||||
}
|
||||
|
||||
@Inject(method = "tick", at = @At(
|
||||
|
||||
@@ -4,6 +4,7 @@ import carpet.helpers.TickSpeed;
|
||||
import carpet.utils.CarpetProfiler;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.ServerTask;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.util.profiler.DisableableProfiler;
|
||||
import net.minecraft.util.thread.ReentrantThreadExecutor;
|
||||
@@ -50,6 +51,8 @@ public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExec
|
||||
|
||||
@Shadow private volatile boolean loading;
|
||||
|
||||
@Shadow public abstract Iterable<ServerWorld> getWorlds();
|
||||
|
||||
CarpetProfiler.ProfilerToken currentSection;
|
||||
|
||||
private float carpetMsptAccum = 0.0f;
|
||||
@@ -120,16 +123,16 @@ public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExec
|
||||
|
||||
this.profiler.startTick();
|
||||
this.profiler.push("tick");
|
||||
this.tick(TickSpeed.time_warp_start_time != 0 ? ()->!hasRunningTasks() : this::shouldKeepTicking);
|
||||
this.tick(TickSpeed.time_warp_start_time != 0 ? ()->true : this::shouldKeepTicking);
|
||||
this.profiler.swap("nextTickWait");
|
||||
if (TickSpeed.time_warp_start_time != 0) // clearing all hanging tasks no matter what when warping
|
||||
{
|
||||
while(this.runEveryTask()) {Thread.yield();}
|
||||
}
|
||||
this.field_19249 = true;
|
||||
this.field_19248 = Math.max(Util.getMeasuringTimeMs() + /*50L*/ msThisTick, this.timeReference);
|
||||
if (TickSpeed.time_warp_start_time != 0)
|
||||
{
|
||||
runTasks();
|
||||
runTasks(() -> !hasRunningTasks() );
|
||||
}
|
||||
else { this.method_16208(); }
|
||||
// run all tasks (this will not do a lot when warping), but that's fine since we already run them
|
||||
this.method_16208();
|
||||
this.profiler.pop();
|
||||
this.profiler.endTick();
|
||||
this.loading = true;
|
||||
@@ -137,6 +140,23 @@ public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExec
|
||||
|
||||
}
|
||||
|
||||
|
||||
private boolean runEveryTask() {
|
||||
if (super.runTask()) {
|
||||
return true;
|
||||
} else {
|
||||
if (true) { // unconditionally this time
|
||||
for(ServerWorld serverlevel : getWorlds()) {
|
||||
if (serverlevel.getChunkManager().executeQueuedTasks()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "tick", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/PlayerManager;saveAllPlayerData()V",
|
||||
|
||||
Reference in new issue
Block a user