Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-27 03:12:37 +01:00
Simplify and clean up sendChunk
Hopefully, that doesn't cause any issues
Dieser Commit ist enthalten in:
Ursprung
69ddac00e1
Commit
ae31d8312f
@ -198,53 +198,26 @@ public final class BukkitAdapter_1_16_5 extends NMSAdapter {
|
||||
if (playerChunk == null) {
|
||||
return;
|
||||
}
|
||||
if (playerChunk.hasBeenLoaded()) {
|
||||
ChunkCoordIntPair chunkCoordIntPair = new ChunkCoordIntPair(chunkX, chunkZ);
|
||||
Optional<Chunk> optional = ((Either) playerChunk.a().getNow(PlayerChunk.UNLOADED_CHUNK)).left();
|
||||
if (optional.isPresent()) {
|
||||
PacketPlayOutMapChunk chunkpacket = new PacketPlayOutMapChunk(optional.get(), 65535);
|
||||
playerChunk.players.a(chunkCoordIntPair, false).forEach(p -> {
|
||||
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(),
|
||||
ChunkCoordIntPair chunkCoordIntPair = new ChunkCoordIntPair(chunkX, chunkZ);
|
||||
Optional<Chunk> optional = ((Either) playerChunk.a().getNow(PlayerChunk.UNLOADED_CHUNK)).left();
|
||||
Chunk chunk = optional.orElseGet(() ->
|
||||
nmsWorld.getChunkProvider().getChunkAtIfLoadedImmediately(chunkX, chunkZ));
|
||||
if (chunk == null) {
|
||||
return;
|
||||
}
|
||||
PacketPlayOutMapChunk chunkPacket = new PacketPlayOutMapChunk(chunk, 65535);
|
||||
playerChunk.players.a(chunkCoordIntPair, false).forEach(p -> {
|
||||
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);
|
||||
playerChunk.players.a(chunkCoordIntPair, false).forEach(p -> {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
playerChunk.players.a(chunkCoordIntPair, false).forEach(p -> {
|
||||
p.playerConnection.sendPacket(packet);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren