mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-11 17:31:06 +01:00
150 lines
7.1 KiB
Diff
150 lines
7.1 KiB
Diff
--- a/net/minecraft/server/PlayerChunkMap.java
|
|
+++ b/net/minecraft/server/PlayerChunkMap.java
|
|
@@ -37,6 +37,7 @@
|
|
import org.apache.commons.lang3.mutable.MutableBoolean;
|
|
import org.apache.logging.log4j.LogManager;
|
|
import org.apache.logging.log4j.Logger;
|
|
+import org.bukkit.entity.Player; // CraftBukkit
|
|
|
|
public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
|
|
|
|
@@ -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;
|
|
@@ -184,9 +185,12 @@
|
|
|
|
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;
|
|
+ // CraftBukkit end
|
|
final Either<IChunkAccess, PlayerChunk.Failure> either = (Either) iterator.next();
|
|
Optional<IChunkAccess> optional = either.left();
|
|
|
|
@@ -284,7 +288,7 @@
|
|
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
|
|
|
|
if (ichunkaccess instanceof ProtoChunkExtension || ichunkaccess instanceof Chunk) {
|
|
this.saveChunk(ichunkaccess);
|
|
@@ -295,7 +299,6 @@
|
|
}
|
|
|
|
}
|
|
-
|
|
protected void unloadChunks(BooleanSupplier booleansupplier) {
|
|
GameProfilerFiller gameprofilerfiller = this.world.getMethodProfiler();
|
|
|
|
@@ -334,7 +337,7 @@
|
|
|
|
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) {
|
|
@@ -483,7 +486,7 @@
|
|
return CompletableFuture.completedFuture(Either.right(playerchunk_failure));
|
|
});
|
|
}, (runnable) -> {
|
|
- this.mailboxWorldGen.a((Object) ChunkTaskQueueSorter.a(playerchunk, runnable));
|
|
+ this.mailboxWorldGen.a(ChunkTaskQueueSorter.a(playerchunk, runnable)); // CraftBukkit - decompile error
|
|
});
|
|
}
|
|
|
|
@@ -564,7 +567,7 @@
|
|
long i = playerchunk.i().pair();
|
|
|
|
playerchunk.getClass();
|
|
- mailbox.a((Object) ChunkTaskQueueSorter.a(runnable, i, playerchunk::getTicketLevel));
|
|
+ mailbox.a(ChunkTaskQueueSorter.a(runnable, i, playerchunk::getTicketLevel)); // CraftBukkit - decompile error
|
|
});
|
|
}
|
|
|
|
@@ -581,7 +584,7 @@
|
|
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) -> {
|
|
@@ -595,7 +598,7 @@
|
|
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;
|
|
}
|
|
@@ -609,7 +612,7 @@
|
|
return chunk;
|
|
});
|
|
}, (runnable) -> {
|
|
- this.mailboxMain.a((Object) ChunkTaskQueueSorter.a(playerchunk, runnable));
|
|
+ this.mailboxMain.a(ChunkTaskQueueSorter.a(playerchunk, runnable)); // CraftBukkit - decompile error
|
|
});
|
|
}
|
|
|
|
@@ -724,7 +727,7 @@
|
|
private NBTTagCompound readChunkData(ChunkCoordIntPair chunkcoordintpair) throws IOException {
|
|
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
|
|
}
|
|
|
|
boolean isOutsideOfRange(ChunkCoordIntPair chunkcoordintpair) {
|
|
@@ -1056,7 +1059,7 @@
|
|
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);
|
|
@@ -1109,7 +1112,7 @@
|
|
|
|
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);
|
|
|
|
@@ -1125,6 +1128,17 @@
|
|
}
|
|
}
|
|
|
|
+ // CraftBukkit start - respect vanish API
|
|
+ if (this.tracker instanceof EntityPlayer) {
|
|
+ Player player = ((EntityPlayer) this.tracker).getBukkitEntity();
|
|
+ if (!entityplayer.getBukkitEntity().canSee(player)) {
|
|
+ flag1 = false;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ entityplayer.removeQueue.remove(Integer.valueOf(this.tracker.getId()));
|
|
+ // CraftBukkit end
|
|
+
|
|
if (flag1 && this.trackedPlayers.add(entityplayer)) {
|
|
this.trackerEntry.b(entityplayer);
|
|
}
|