Simplify and clean up sendChunk

Hopefully, that doesn't cause any issues
Dieser Commit ist enthalten in:
Hannes Greule 2021-04-12 00:23:42 +02:00
Ursprung 69ddac00e1
Commit ae31d8312f

Datei anzeigen

@ -198,15 +198,17 @@ public final class BukkitAdapter_1_16_5 extends NMSAdapter {
if (playerChunk == null) { if (playerChunk == null) {
return; return;
} }
if (playerChunk.hasBeenLoaded()) {
ChunkCoordIntPair chunkCoordIntPair = new ChunkCoordIntPair(chunkX, chunkZ); ChunkCoordIntPair chunkCoordIntPair = new ChunkCoordIntPair(chunkX, chunkZ);
Optional<Chunk> optional = ((Either) playerChunk.a().getNow(PlayerChunk.UNLOADED_CHUNK)).left(); Optional<Chunk> optional = ((Either) playerChunk.a().getNow(PlayerChunk.UNLOADED_CHUNK)).left();
if (optional.isPresent()) { Chunk chunk = optional.orElseGet(() ->
PacketPlayOutMapChunk chunkpacket = new PacketPlayOutMapChunk(optional.get(), 65535); nmsWorld.getChunkProvider().getChunkAtIfLoadedImmediately(chunkX, chunkZ));
if (chunk == null) {
return;
}
PacketPlayOutMapChunk chunkPacket = new PacketPlayOutMapChunk(chunk, 65535);
playerChunk.players.a(chunkCoordIntPair, false).forEach(p -> { playerChunk.players.a(chunkCoordIntPair, false).forEach(p -> {
p.playerConnection.sendPacket(chunkpacket); p.playerConnection.sendPacket(chunkPacket);
}); });
if (lighting) { if (lighting) {
//This needs to be true otherwise Minecraft will update lighting from/at the chunk edges (bad) //This needs to be true otherwise Minecraft will update lighting from/at the chunk edges (bad)
boolean trustEdges = true; boolean trustEdges = true;
@ -217,35 +219,6 @@ public final class BukkitAdapter_1_16_5 extends NMSAdapter {
p.playerConnection.sendPacket(packet); p.playerConnection.sendPacket(packet);
}); });
} }
} else if (PaperLib.isPaper()) {
//Require generic here to work with multiple dependencies trying to take control.
PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<?> objects =
nmsWorld.getChunkProvider().playerChunkMap.playerViewDistanceNoTickMap
.getObjectsInRange(chunkX, chunkZ);
if (objects == null) {
return;
}
for (Object obj : objects.getBackingSet()) {
if (obj == null) {
continue;
}
EntityPlayer p = (EntityPlayer) obj;
Chunk chunk = nmsWorld.getChunkProvider().getChunkAtIfLoadedImmediately(chunkX, chunkZ);
if (chunk != null) {
PacketPlayOutMapChunk chunkpacket = new PacketPlayOutMapChunk(chunk, 65535);
p.playerConnection.sendPacket(chunkpacket);
if (lighting) {
//This needs to be true otherwise Minecraft will update lighting from/at the chunk edges (bad)
boolean trustEdges = true;
PacketPlayOutLightUpdate packet = new PacketPlayOutLightUpdate(chunkCoordIntPair,
nmsWorld.getChunkProvider().getLightEngine(), trustEdges);
p.playerConnection.sendPacket(packet);
}
}
}
}
}
} }
/* /*