2015-05-25 12:37:24 +02:00
|
|
|
--- a/net/minecraft/server/PlayerChunkMap.java
|
|
|
|
+++ b/net/minecraft/server/PlayerChunkMap.java
|
2019-06-21 12:00:00 +02:00
|
|
|
@@ -37,6 +37,7 @@
|
2019-05-14 02:00:00 +02:00
|
|
|
import org.apache.commons.lang3.mutable.MutableBoolean;
|
2019-04-23 04:00:00 +02:00
|
|
|
import org.apache.logging.log4j.LogManager;
|
|
|
|
import org.apache.logging.log4j.Logger;
|
2019-05-16 01:11:20 +02:00
|
|
|
+import org.bukkit.entity.Player; // CraftBukkit
|
2019-04-23 04:00:00 +02:00
|
|
|
|
|
|
|
public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
|
|
|
|
|
2019-07-08 04:14:16 +02:00
|
|
|
@@ -58,7 +59,7 @@
|
|
|
|
private final Mailbox<ChunkTaskQueueSorter.a<Runnable>> mailboxWorldGen;
|
|
|
|
private final Mailbox<ChunkTaskQueueSorter.a<Runnable>> mailboxMain;
|
|
|
|
public final WorldLoadListener worldLoadListener;
|
|
|
|
- private final PlayerChunkMap.a u;
|
|
|
|
+ public final PlayerChunkMap.a u; // CraftBukkit - private -> public // PAIL chunkDistanceManager
|
|
|
|
private final AtomicInteger v;
|
|
|
|
private final DefinedStructureManager definedStructureManager;
|
|
|
|
private final File x;
|
2019-07-13 20:19:44 +02:00
|
|
|
@@ -67,6 +68,31 @@
|
|
|
|
private final Queue<Runnable> A;
|
|
|
|
private int viewDistance;
|
|
|
|
|
|
|
|
+ // CraftBukkit start - recursion-safe executor for Chunk loadCallback() and unloadCallback()
|
|
|
|
+ public final CallbackExecutor callbackExecutor = new CallbackExecutor();
|
|
|
|
+ public static final class CallbackExecutor implements java.util.concurrent.Executor, Runnable {
|
|
|
|
+
|
|
|
|
+ private Runnable queued;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void execute(Runnable runnable) {
|
|
|
|
+ if (queued != null) {
|
|
|
|
+ throw new IllegalStateException("Already queued");
|
|
|
|
+ }
|
|
|
|
+ queued = runnable;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void run() {
|
|
|
|
+ Runnable task = queued;
|
|
|
|
+ queued = null;
|
|
|
|
+ if (task != null) {
|
|
|
|
+ task.run();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ // CraftBukkit end
|
|
|
|
+
|
|
|
|
public PlayerChunkMap(WorldServer worldserver, File file, DataFixer datafixer, DefinedStructureManager definedstructuremanager, Executor executor, IAsyncTaskHandler<Runnable> iasynctaskhandler, ILightAccess ilightaccess, ChunkGenerator<?> chunkgenerator, WorldLoadListener worldloadlistener, Supplier<WorldPersistentData> supplier, int i) {
|
|
|
|
super(new File(worldserver.getWorldProvider().getDimensionManager().a(file), "region"), datafixer);
|
|
|
|
this.visibleChunks = this.updatingChunks.clone();
|
|
|
|
@@ -184,9 +210,12 @@
|
2019-04-23 04:00:00 +02:00
|
|
|
|
|
|
|
return completablefuture1.thenApply((list1) -> {
|
|
|
|
List<IChunkAccess> list2 = Lists.newArrayList();
|
|
|
|
- final int l1 = 0;
|
|
|
|
+ // CraftBukkit start - decompile error
|
|
|
|
+ int cnt = 0;
|
|
|
|
|
|
|
|
- for (Iterator iterator = list1.iterator(); iterator.hasNext(); ++l1) {
|
|
|
|
+ for (Iterator iterator = list1.iterator(); iterator.hasNext(); ++cnt) {
|
|
|
|
+ final int l1 = cnt;
|
2016-12-06 12:05:58 +01:00
|
|
|
+ // CraftBukkit end
|
2019-04-23 04:00:00 +02:00
|
|
|
final Either<IChunkAccess, PlayerChunk.Failure> either = (Either) iterator.next();
|
|
|
|
Optional<IChunkAccess> optional = either.left();
|
|
|
|
|
2019-07-13 20:19:44 +02:00
|
|
|
@@ -284,7 +313,7 @@
|
2019-05-14 02:00:00 +02:00
|
|
|
PlayerChunkMap.LOGGER.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", this.x.getName());
|
|
|
|
} else {
|
|
|
|
this.visibleChunks.values().stream().filter(PlayerChunk::hasBeenLoaded).forEach((playerchunk) -> {
|
|
|
|
- IChunkAccess ichunkaccess = (IChunkAccess) playerchunk.getChunkSave().getNow((Object) null);
|
|
|
|
+ IChunkAccess ichunkaccess = (IChunkAccess) playerchunk.getChunkSave().getNow(null); // CraftBukkit - decompile error
|
2016-12-06 12:05:58 +01:00
|
|
|
|
2019-05-14 02:00:00 +02:00
|
|
|
if (ichunkaccess instanceof ProtoChunkExtension || ichunkaccess instanceof Chunk) {
|
|
|
|
this.saveChunk(ichunkaccess);
|
2019-07-13 20:19:44 +02:00
|
|
|
@@ -295,7 +324,6 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
2019-04-26 08:56:49 +02:00
|
|
|
}
|
|
|
|
-
|
|
|
|
protected void unloadChunks(BooleanSupplier booleansupplier) {
|
|
|
|
GameProfilerFiller gameprofilerfiller = this.world.getMethodProfiler();
|
2019-04-23 04:00:00 +02:00
|
|
|
|
2019-07-13 20:19:44 +02:00
|
|
|
@@ -334,7 +362,7 @@
|
2019-05-27 22:30:00 +02:00
|
|
|
|
|
|
|
private void a(long i, PlayerChunk playerchunk) {
|
|
|
|
CompletableFuture<IChunkAccess> completablefuture = playerchunk.getChunkSave();
|
|
|
|
- Consumer consumer = (ichunkaccess) -> {
|
|
|
|
+ Consumer<IChunkAccess> consumer = (ichunkaccess) -> { // CraftBukkit - decompile error
|
|
|
|
CompletableFuture<IChunkAccess> completablefuture1 = playerchunk.getChunkSave();
|
|
|
|
|
|
|
|
if (completablefuture1 != completablefuture) {
|
2019-07-13 20:19:44 +02:00
|
|
|
@@ -483,7 +511,7 @@
|
2019-05-27 22:30:00 +02:00
|
|
|
return CompletableFuture.completedFuture(Either.right(playerchunk_failure));
|
2019-04-23 04:00:00 +02:00
|
|
|
});
|
2019-05-27 22:30:00 +02:00
|
|
|
}, (runnable) -> {
|
|
|
|
- this.mailboxWorldGen.a((Object) ChunkTaskQueueSorter.a(playerchunk, runnable));
|
|
|
|
+ this.mailboxWorldGen.a(ChunkTaskQueueSorter.a(playerchunk, runnable)); // CraftBukkit - decompile error
|
|
|
|
});
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
2019-05-27 22:30:00 +02:00
|
|
|
|
2019-07-13 20:19:44 +02:00
|
|
|
@@ -564,7 +592,7 @@
|
2019-06-21 12:00:00 +02:00
|
|
|
long i = playerchunk.i().pair();
|
2016-05-10 13:47:39 +02:00
|
|
|
|
2019-04-23 04:00:00 +02:00
|
|
|
playerchunk.getClass();
|
2019-05-14 02:00:00 +02:00
|
|
|
- mailbox.a((Object) ChunkTaskQueueSorter.a(runnable, i, playerchunk::getTicketLevel));
|
|
|
|
+ mailbox.a(ChunkTaskQueueSorter.a(runnable, i, playerchunk::getTicketLevel)); // CraftBukkit - decompile error
|
2019-04-23 04:00:00 +02:00
|
|
|
});
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
2019-04-23 04:00:00 +02:00
|
|
|
|
2019-07-13 20:19:44 +02:00
|
|
|
@@ -581,7 +609,7 @@
|
2019-04-23 04:00:00 +02:00
|
|
|
return Either.left(chunk);
|
|
|
|
});
|
|
|
|
}, (runnable) -> {
|
|
|
|
- this.mailboxMain.a((Object) ChunkTaskQueueSorter.a(playerchunk, runnable));
|
|
|
|
+ this.mailboxMain.a(ChunkTaskQueueSorter.a(playerchunk, runnable)); // CraftBukkit - decompile error
|
|
|
|
});
|
|
|
|
|
|
|
|
completablefuture1.thenAcceptAsync((either) -> {
|
2019-07-13 20:19:44 +02:00
|
|
|
@@ -595,7 +623,7 @@
|
2019-04-23 04:00:00 +02:00
|
|
|
return Either.left(chunk);
|
|
|
|
});
|
|
|
|
}, (runnable) -> {
|
|
|
|
- this.mailboxMain.a((Object) ChunkTaskQueueSorter.a(playerchunk, runnable));
|
|
|
|
+ this.mailboxMain.a(ChunkTaskQueueSorter.a(playerchunk, runnable)); // CraftBukkit - decompile error
|
|
|
|
});
|
|
|
|
return completablefuture1;
|
|
|
|
}
|
2019-07-13 20:19:44 +02:00
|
|
|
@@ -609,7 +637,7 @@
|
2019-05-14 02:00:00 +02:00
|
|
|
return chunk;
|
|
|
|
});
|
|
|
|
}, (runnable) -> {
|
|
|
|
- this.mailboxMain.a((Object) ChunkTaskQueueSorter.a(playerchunk, runnable));
|
|
|
|
+ this.mailboxMain.a(ChunkTaskQueueSorter.a(playerchunk, runnable)); // CraftBukkit - decompile error
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-07-13 20:19:44 +02:00
|
|
|
@@ -724,7 +752,7 @@
|
2019-05-14 02:00:00 +02:00
|
|
|
private NBTTagCompound readChunkData(ChunkCoordIntPair chunkcoordintpair) throws IOException {
|
2019-04-23 04:00:00 +02:00
|
|
|
NBTTagCompound nbttagcompound = this.read(chunkcoordintpair);
|
|
|
|
|
|
|
|
- return nbttagcompound == null ? null : this.getChunkData(this.world.getWorldProvider().getDimensionManager(), this.m, nbttagcompound);
|
|
|
|
+ return nbttagcompound == null ? null : this.getChunkData(this.world.getWorldProvider().getDimensionManager(), this.m, nbttagcompound, chunkcoordintpair, world); // CraftBukkit
|
|
|
|
}
|
|
|
|
|
2019-06-02 11:51:26 +02:00
|
|
|
boolean isOutsideOfRange(ChunkCoordIntPair chunkcoordintpair) {
|
2019-07-13 20:19:44 +02:00
|
|
|
@@ -1056,7 +1084,7 @@
|
2019-04-23 04:00:00 +02:00
|
|
|
public final Set<EntityPlayer> trackedPlayers = Sets.newHashSet();
|
|
|
|
|
|
|
|
public EntityTracker(Entity entity, int i, int j, boolean flag) {
|
|
|
|
- this.trackerEntry = new EntityTrackerEntry(PlayerChunkMap.this.world, entity, j, flag, this::broadcast);
|
|
|
|
+ this.trackerEntry = new EntityTrackerEntry(PlayerChunkMap.this.world, entity, j, flag, this::broadcast, trackedPlayers); // CraftBukkit
|
|
|
|
this.tracker = entity;
|
|
|
|
this.trackingDistance = i;
|
|
|
|
this.e = SectionPosition.a(entity);
|
2019-07-13 20:19:44 +02:00
|
|
|
@@ -1109,7 +1137,7 @@
|
2019-07-10 11:56:39 +02:00
|
|
|
|
|
|
|
public void updatePlayer(EntityPlayer entityplayer) {
|
|
|
|
if (entityplayer != this.tracker) {
|
|
|
|
- Vec3D vec3d = (new Vec3D(entityplayer.locX, entityplayer.locY, entityplayer.locZ)).d(this.trackerEntry.b());
|
|
|
|
+ Vec3D vec3d = (new Vec3D(entityplayer.locX, entityplayer.locY, entityplayer.locZ)).d(this.tracker.ci()); // MC-155077, SPIGOT-5113 // PAIL getPositionVector
|
|
|
|
int i = Math.min(this.trackingDistance, (PlayerChunkMap.this.viewDistance - 1) * 16);
|
|
|
|
boolean flag = vec3d.x >= (double) (-i) && vec3d.x <= (double) i && vec3d.z >= (double) (-i) && vec3d.z <= (double) i && this.tracker.a(entityplayer);
|
|
|
|
|
2019-07-13 20:19:44 +02:00
|
|
|
@@ -1125,6 +1153,17 @@
|
2019-04-23 04:00:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // CraftBukkit start - respect vanish API
|
|
|
|
+ if (this.tracker instanceof EntityPlayer) {
|
|
|
|
+ Player player = ((EntityPlayer) this.tracker).getBukkitEntity();
|
|
|
|
+ if (!entityplayer.getBukkitEntity().canSee(player)) {
|
|
|
|
+ flag1 = false;
|
|
|
|
+ }
|
|
|
|
+ }
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
2019-04-23 04:00:00 +02:00
|
|
|
+ entityplayer.removeQueue.remove(Integer.valueOf(this.tracker.getId()));
|
|
|
|
+ // CraftBukkit end
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
2019-04-23 04:00:00 +02:00
|
|
|
if (flag1 && this.trackedPlayers.add(entityplayer)) {
|
|
|
|
this.trackerEntry.b(entityplayer);
|
|
|
|
}
|