46 lines
2.6 KiB
Diff
46 lines
2.6 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: PureGero <puregero@gmail.com>
|
|
Date: Sat, 25 Dec 2021 18:34:04 +1000
|
|
Subject: [PATCH] Run tasks while reading poi data
|
|
|
|
Original license: GPLv3
|
|
Original project: https://github.com/MultiPaper/MultiPaper
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java b/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java
|
|
index 210b0cdd4831421c8f43c3d823ac8e962b56bbbc..a52955c51988c821ab00f0c2298193aaa8126330 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java
|
|
@@ -1,5 +1,6 @@
|
|
package net.minecraft.world.entity.ai.village.poi;
|
|
|
|
+import com.destroystokyo.paper.io.PaperFileIOThread;
|
|
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; // Paper
|
|
import com.mojang.datafixers.DataFixer;
|
|
import com.mojang.datafixers.util.Pair;
|
|
@@ -11,6 +12,7 @@ import java.nio.file.Path;
|
|
import java.util.Comparator;
|
|
import java.util.List;
|
|
import java.util.Optional;
|
|
+import java.util.concurrent.CompletableFuture;
|
|
import java.util.function.BiConsumer;
|
|
import java.util.function.BiPredicate;
|
|
import java.util.function.BooleanSupplier;
|
|
@@ -460,9 +462,15 @@ public class PoiManager extends SectionStorage<PoiSection> {
|
|
@Override
|
|
public net.minecraft.nbt.CompoundTag read(ChunkPos chunkcoordintpair) throws java.io.IOException {
|
|
if (this.world != null && Thread.currentThread() != com.destroystokyo.paper.io.PaperFileIOThread.Holder.INSTANCE) {
|
|
- net.minecraft.nbt.CompoundTag ret = com.destroystokyo.paper.io.PaperFileIOThread.Holder.INSTANCE
|
|
+ // MultiPaper start - don't block the main thread, run tasks in the meantime
|
|
+ CompletableFuture<PaperFileIOThread.ChunkData> completablefuture = com.destroystokyo.paper.io.PaperFileIOThread.Holder.INSTANCE
|
|
.loadChunkDataAsyncFuture(this.world, chunkcoordintpair.x, chunkcoordintpair.z, com.destroystokyo.paper.io.IOUtil.getPriorityForCurrentThread(),
|
|
- true, false, true).join().poiData;
|
|
+ true, false, true);
|
|
+ if (!completablefuture.isDone()) {
|
|
+ world.chunkSource.mainThreadProcessor.managedBlock(completablefuture::isDone);
|
|
+ }
|
|
+ net.minecraft.nbt.CompoundTag ret = completablefuture.join().poiData;
|
|
+ // MultiPaper end
|
|
|
|
if (ret == com.destroystokyo.paper.io.PaperFileIOThread.FAILURE_VALUE) {
|
|
throw new java.io.IOException("See logs for further detail");
|