geforkt von Mirrors/FastAsyncWorldEdit
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) {
|
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();
|
Chunk chunk = optional.orElseGet(() ->
|
||||||
if (optional.isPresent()) {
|
nmsWorld.getChunkProvider().getChunkAtIfLoadedImmediately(chunkX, chunkZ));
|
||||||
PacketPlayOutMapChunk chunkpacket = new PacketPlayOutMapChunk(optional.get(), 65535);
|
if (chunk == null) {
|
||||||
playerChunk.players.a(chunkCoordIntPair, false).forEach(p -> {
|
return;
|
||||||
p.playerConnection.sendPacket(chunkpacket);
|
}
|
||||||
});
|
PacketPlayOutMapChunk chunkPacket = new PacketPlayOutMapChunk(chunk, 65535);
|
||||||
|
playerChunk.players.a(chunkCoordIntPair, false).forEach(p -> {
|
||||||
if (lighting) {
|
p.playerConnection.sendPacket(chunkPacket);
|
||||||
//This needs to be true otherwise Minecraft will update lighting from/at the chunk edges (bad)
|
});
|
||||||
boolean trustEdges = true;
|
if (lighting) {
|
||||||
PacketPlayOutLightUpdate packet =
|
//This needs to be true otherwise Minecraft will update lighting from/at the chunk edges (bad)
|
||||||
new PacketPlayOutLightUpdate(chunkCoordIntPair, nmsWorld.getChunkProvider().getLightEngine(),
|
boolean trustEdges = true;
|
||||||
|
PacketPlayOutLightUpdate packet =
|
||||||
|
new PacketPlayOutLightUpdate(chunkCoordIntPair, nmsWorld.getChunkProvider().getLightEngine(),
|
||||||
trustEdges);
|
trustEdges);
|
||||||
playerChunk.players.a(chunkCoordIntPair, false).forEach(p -> {
|
playerChunk.players.a(chunkCoordIntPair, false).forEach(p -> {
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren