run all tasks when warping

This commit is contained in:
gnembon committed 2020-02-27 23:01:23 -04:00
1 parent f4fd31e9fa
commit b8521c8bbf
1 file changed
+14 -2
@@ -3,8 +3,10 @@ package carpet.mixins;
import carpet.helpers.TickSpeed;
import carpet.utils.CarpetProfiler;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.ServerTask;
import net.minecraft.util.Util;
import net.minecraft.util.profiler.DisableableProfiler;
import net.minecraft.util.thread.ReentrantThreadExecutor;
import org.apache.logging.log4j.Logger;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
@@ -17,7 +19,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.function.BooleanSupplier;
@Mixin(MinecraftServer.class)
public abstract class MinecraftServer_tickspeedMixin
public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExecutor<ServerTask>
{
@Shadow private volatile boolean running;
@@ -31,6 +33,11 @@ public abstract class MinecraftServer_tickspeedMixin
@Shadow @Final private DisableableProfiler profiler;
public MinecraftServer_tickspeedMixin(String name)
{
super(name);
}
@Shadow protected abstract void tick(BooleanSupplier booleanSupplier_1);
@Shadow protected abstract boolean shouldKeepTicking();
@@ -117,7 +124,12 @@ public abstract class MinecraftServer_tickspeedMixin
this.profiler.swap("nextTickWait");
this.field_19249 = true;
this.field_19248 = Math.max(Util.getMeasuringTimeMs() + /*50L*/ msThisTick, this.timeReference);
this.method_16208();
if (TickSpeed.time_warp_start_time != 0)
{
runTasks();
runTasks(() -> !hasRunningTasks() );
}
else { this.method_16208(); }
this.profiler.pop();
this.profiler.endTick();
this.loading = true;