mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-03-02 08:14:33 +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.world.World;
|
||||
|
||||
public class AwaitTickQueue {
|
||||
public static void scheduleTask(World reference, Consumer<World> task, int ticksLater) {
|
||||
public interface AwaitTickQueue {
|
||||
static void scheduleTask(World reference, Consumer<World> task, int ticksLater) {
|
||||
if (reference instanceof ServerWorld serverWorld) {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
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) {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
task.accept(serverWorld);
|
||||
}, serverWorld.getServer());
|
||||
}, CompletableFuture.delayedExecutor(1, TimeUnit.MILLISECONDS, serverWorld.getServer()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue