Merge branch 'master' into 1.16
# Conflicts: # src/main/java/carpet/mixins/MinecraftServer_tickspeedMixin.java
This commit is contained in:
commit
7a70e00076
2 files changed
+28
-8
No files matched your search
@@ -43,7 +43,7 @@ public abstract class MinecraftServer_scarpetMixin extends ReentrantThreadExecut
|
|||||||
{
|
{
|
||||||
timeReference = lastTimeReference = Util.getMeasuringTimeMs();
|
timeReference = lastTimeReference = Util.getMeasuringTimeMs();
|
||||||
tick(isAhead);
|
tick(isAhead);
|
||||||
runTask();
|
while(runTask()) {Thread.yield();}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import carpet.utils.CarpetProfiler;
|
|||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.ServerTask;
|
import net.minecraft.server.ServerTask;
|
||||||
import net.minecraft.util.TickDurationMonitor;
|
import net.minecraft.util.TickDurationMonitor;
|
||||||
|
import net.minecraft.server.world.ServerWorld;
|
||||||
import net.minecraft.util.Util;
|
import net.minecraft.util.Util;
|
||||||
import net.minecraft.util.profiler.Profiler;
|
import net.minecraft.util.profiler.Profiler;
|
||||||
import net.minecraft.util.thread.ReentrantThreadExecutor;
|
import net.minecraft.util.thread.ReentrantThreadExecutor;
|
||||||
@@ -51,6 +52,8 @@ public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExec
|
|||||||
|
|
||||||
@Shadow private boolean waitingForNextTick;
|
@Shadow private boolean waitingForNextTick;
|
||||||
|
|
||||||
|
@Shadow public abstract Iterable<ServerWorld> getWorlds();
|
||||||
|
|
||||||
CarpetProfiler.ProfilerToken currentSection;
|
CarpetProfiler.ProfilerToken currentSection;
|
||||||
|
|
||||||
private float carpetMsptAccum = 0.0f;
|
private float carpetMsptAccum = 0.0f;
|
||||||
@@ -117,16 +120,16 @@ public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExec
|
|||||||
this.startMonitor(tickDurationMonitor);
|
this.startMonitor(tickDurationMonitor);
|
||||||
this.profiler.startTick();
|
this.profiler.startTick();
|
||||||
this.profiler.push("tick");
|
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");
|
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.waitingForNextTick = true;
|
this.waitingForNextTick = true;
|
||||||
this.field_19248 = Math.max(Util.getMeasuringTimeMs() + /*50L*/ msThisTick, this.timeReference);
|
this.field_19248 = Math.max(Util.getMeasuringTimeMs() + /*50L*/ msThisTick, this.timeReference);
|
||||||
if (TickSpeed.time_warp_start_time != 0)
|
// run all tasks (this will not do a lot when warping), but that's fine since we already run them
|
||||||
{
|
this.method_16208();
|
||||||
runTasks();
|
|
||||||
runTasks(() -> !hasRunningTasks() );
|
|
||||||
}
|
|
||||||
else { this.method_16208(); }
|
|
||||||
this.profiler.pop();
|
this.profiler.pop();
|
||||||
this.profiler.endTick();
|
this.profiler.endTick();
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
@@ -134,6 +137,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(
|
@Inject(method = "tick", at = @At(
|
||||||
value = "INVOKE",
|
value = "INVOKE",
|
||||||
target = "Lnet/minecraft/server/PlayerManager;saveAllPlayerData()V",
|
target = "Lnet/minecraft/server/PlayerManager;saveAllPlayerData()V",
|
||||||
|
|||||||
Reference in new issue
Block a user