mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-03-03 08:41:28 +01:00
Delay scheduled tasks so they don't end up being excuted immediately. Might help prevent crashes like #95
This commit is contained in:
parent
cdb06be7ad
commit
8a13b02809
1 changed files with 4 additions and 4 deletions
|
@ -6,8 +6,8 @@ import java.util.function.Consumer;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.world.ServerWorld;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class AwaitTickQueue {
|
public interface AwaitTickQueue {
|
||||||
public static void scheduleTask(World reference, Consumer<World> task, int ticksLater) {
|
static void scheduleTask(World reference, Consumer<World> task, int ticksLater) {
|
||||||
if (reference instanceof ServerWorld serverWorld) {
|
if (reference instanceof ServerWorld serverWorld) {
|
||||||
CompletableFuture.runAsync(() -> {
|
CompletableFuture.runAsync(() -> {
|
||||||
task.accept(serverWorld);
|
task.accept(serverWorld);
|
||||||
|
@ -15,11 +15,11 @@ public class AwaitTickQueue {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void scheduleTask(World reference, Consumer<World> task) {
|
static void scheduleTask(World reference, Consumer<World> task) {
|
||||||
if (reference instanceof ServerWorld serverWorld) {
|
if (reference instanceof ServerWorld serverWorld) {
|
||||||
CompletableFuture.runAsync(() -> {
|
CompletableFuture.runAsync(() -> {
|
||||||
task.accept(serverWorld);
|
task.accept(serverWorld);
|
||||||
}, serverWorld.getServer());
|
}, CompletableFuture.delayedExecutor(1, TimeUnit.MILLISECONDS, serverWorld.getServer()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue