--- a/net/minecraft/server/PlayerChunkMap.java +++ b/net/minecraft/server/PlayerChunkMap.java @@ -38,6 +38,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 { @@ -186,9 +187,12 @@ return completablefuture1.thenApply((list1) -> { List 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 either = (Either) iterator.next(); Optional optional = either.left(); @@ -286,7 +290,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); @@ -297,7 +301,6 @@ } } - protected void unloadChunks(BooleanSupplier booleansupplier) { GameProfilerFiller gameprofilerfiller = this.world.getMethodProfiler(); @@ -336,7 +339,7 @@ private void a(long i, PlayerChunk playerchunk) { CompletableFuture completablefuture = playerchunk.getChunkSave(); - Consumer consumer = (ichunkaccess) -> { + Consumer consumer = (ichunkaccess) -> { // CraftBukkit - decompile error CompletableFuture completablefuture1 = playerchunk.getChunkSave(); if (completablefuture1 != completablefuture) { @@ -485,7 +488,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 }); } @@ -566,7 +569,7 @@ long i = playerchunk.h().pair(); playerchunk.getClass(); - mailbox.a((Object) ChunkTaskQueueSorter.a(runnable, i, playerchunk::getTicketLevel)); + mailbox.a(ChunkTaskQueueSorter.a(runnable, i, playerchunk::getTicketLevel)); // CraftBukkit - decompile error }); } @@ -583,7 +586,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) -> { @@ -597,7 +600,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; } @@ -611,7 +614,7 @@ return chunk; }); }, (runnable) -> { - this.mailboxMain.a((Object) ChunkTaskQueueSorter.a(playerchunk, runnable)); + this.mailboxMain.a(ChunkTaskQueueSorter.a(playerchunk, runnable)); // CraftBukkit - decompile error }); } @@ -675,9 +678,10 @@ ChunkCoordIntPair chunkcoordintpair = playerchunk.h(); Packet[] apacket = new Packet[2]; + int finall = l; // CraftBukkit - decompile error this.a(chunkcoordintpair, false).forEach((entityplayer) -> { int i1 = b(chunkcoordintpair, entityplayer, true); - boolean flag = i1 <= l; + boolean flag = i1 <= finall; // CraftBukkit - decompile error boolean flag1 = i1 <= this.viewDistance; this.sendChunk(entityplayer, chunkcoordintpair, apacket, flag, flag1); @@ -732,7 +736,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) { @@ -1052,7 +1056,7 @@ public final Set 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); @@ -1121,6 +1125,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); }