Reimplement runLater without relying on MC's renderTaskQueue
Cause it's gone in 1.21.9, and really not necessary to begin with since we have our own executor already.
This commit is contained in:
@@ -8,8 +8,6 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Mutable;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
import java.util.Queue;
|
||||
|
||||
//#if MC>=11800
|
||||
//$$ import java.util.function.Supplier;
|
||||
//#endif
|
||||
@@ -25,6 +23,7 @@ import java.util.concurrent.CompletableFuture;
|
||||
//#if MC<11400
|
||||
//$$ import net.minecraft.client.resources.IResourcePack;
|
||||
//$$ import java.util.List;
|
||||
//$$ import java.util.Queue;
|
||||
//#endif
|
||||
|
||||
@Mixin(MinecraftClient.class)
|
||||
@@ -53,8 +52,6 @@ public interface MinecraftAccessor {
|
||||
//#endif
|
||||
|
||||
//#if MC>=11400
|
||||
@Accessor
|
||||
Queue<Runnable> getRenderTaskQueue();
|
||||
//#else
|
||||
//$$ @Accessor
|
||||
//$$ Queue<FutureTask<?>> getScheduledTasks();
|
||||
|
||||
@@ -5,6 +5,8 @@ import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.util.crash.CrashException;
|
||||
import net.minecraft.util.thread.ReentrantThreadExecutor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
@@ -82,10 +84,13 @@ public class SchedulerImpl implements Scheduler {
|
||||
}
|
||||
}
|
||||
public final ReplayModExecutor executor = new ReplayModExecutor("Client/ReplayMod");
|
||||
private final List<Runnable> delayedTasks = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void runTasks() {
|
||||
executor.runTasks();
|
||||
delayedTasks.forEach(executor::send);
|
||||
delayedTasks.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -100,15 +105,8 @@ public class SchedulerImpl implements Scheduler {
|
||||
}
|
||||
|
||||
private void runLater(Runnable runnable, Runnable defer) {
|
||||
if (mc.isOnThread() && inRunLater && !inRenderTaskQueue) {
|
||||
((MinecraftAccessor) mc).getRenderTaskQueue().offer(() -> {
|
||||
inRenderTaskQueue = true;
|
||||
try {
|
||||
defer.run();
|
||||
} finally {
|
||||
inRenderTaskQueue = false;
|
||||
}
|
||||
});
|
||||
if (mc.isOnThread() && inRunLater) {
|
||||
delayedTasks.add(defer);
|
||||
} else {
|
||||
executor.send(() -> {
|
||||
inRunLater = true;
|
||||
|
||||
Reference in New Issue
Block a user