fix: remove synchronisation on chunk GET when sending packet

This commit is contained in:
dordsor21 2024-07-02 18:51:11 +01:00
parent 15c6027958
commit a14bb7ed2c
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B
5 changed files with 72 additions and 92 deletions

View File

@ -350,7 +350,6 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
MinecraftServer.getServer().execute(() -> { MinecraftServer.getServer().execute(() -> {
ClientboundLevelChunkWithLightPacket packet; ClientboundLevelChunkWithLightPacket packet;
if (PaperLib.isPaper()) { if (PaperLib.isPaper()) {
synchronized (chunk) {
packet = new ClientboundLevelChunkWithLightPacket( packet = new ClientboundLevelChunkWithLightPacket(
levelChunk, levelChunk,
nmsWorld.getChunkSource().getLightEngine(), nmsWorld.getChunkSource().getLightEngine(),
@ -359,9 +358,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
true, true,
false // last false is to not bother with x-ray false // last false is to not bother with x-ray
); );
}
} else { } else {
synchronized (chunk) {
// deprecated on paper - deprecation suppressed // deprecated on paper - deprecation suppressed
packet = new ClientboundLevelChunkWithLightPacket( packet = new ClientboundLevelChunkWithLightPacket(
levelChunk, levelChunk,
@ -371,7 +368,6 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
true true
); );
} }
}
nearbyPlayers(nmsWorld, coordIntPair).forEach(p -> p.connection.send(packet)); nearbyPlayers(nmsWorld, coordIntPair).forEach(p -> p.connection.send(packet));
}); });
} }

View File

@ -364,7 +364,6 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
MinecraftServer.getServer().execute(() -> { MinecraftServer.getServer().execute(() -> {
ClientboundLevelChunkWithLightPacket packet; ClientboundLevelChunkWithLightPacket packet;
if (PaperLib.isPaper()) { if (PaperLib.isPaper()) {
synchronized (chunk) {
packet = new ClientboundLevelChunkWithLightPacket( packet = new ClientboundLevelChunkWithLightPacket(
levelChunk, levelChunk,
nmsWorld.getChunkSource().getLightEngine(), nmsWorld.getChunkSource().getLightEngine(),
@ -372,9 +371,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
null, null,
false // last false is to not bother with x-ray false // last false is to not bother with x-ray
); );
}
} else { } else {
synchronized (chunk) {
// deprecated on paper - deprecation suppressed // deprecated on paper - deprecation suppressed
packet = new ClientboundLevelChunkWithLightPacket( packet = new ClientboundLevelChunkWithLightPacket(
levelChunk, levelChunk,
@ -383,7 +380,6 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
null null
); );
} }
}
nearbyPlayers(nmsWorld, coordIntPair).forEach(p -> p.connection.send(packet)); nearbyPlayers(nmsWorld, coordIntPair).forEach(p -> p.connection.send(packet));
}); });
} }

View File

@ -364,7 +364,6 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
MinecraftServer.getServer().execute(() -> { MinecraftServer.getServer().execute(() -> {
ClientboundLevelChunkWithLightPacket packet; ClientboundLevelChunkWithLightPacket packet;
if (PaperLib.isPaper()) { if (PaperLib.isPaper()) {
synchronized (chunk) {
packet = new ClientboundLevelChunkWithLightPacket( packet = new ClientboundLevelChunkWithLightPacket(
levelChunk, levelChunk,
nmsWorld.getChunkSource().getLightEngine(), nmsWorld.getChunkSource().getLightEngine(),
@ -372,9 +371,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
null, null,
false // last false is to not bother with x-ray false // last false is to not bother with x-ray
); );
}
} else { } else {
synchronized (chunk) {
// deprecated on paper - deprecation suppressed // deprecated on paper - deprecation suppressed
packet = new ClientboundLevelChunkWithLightPacket( packet = new ClientboundLevelChunkWithLightPacket(
levelChunk, levelChunk,
@ -383,7 +380,6 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
null null
); );
} }
}
nearbyPlayers(nmsWorld, coordIntPair).forEach(p -> p.connection.send(packet)); nearbyPlayers(nmsWorld, coordIntPair).forEach(p -> p.connection.send(packet));
}); });
} }

View File

@ -353,7 +353,6 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
MinecraftServer.getServer().execute(() -> { MinecraftServer.getServer().execute(() -> {
ClientboundLevelChunkWithLightPacket packet; ClientboundLevelChunkWithLightPacket packet;
if (PaperLib.isPaper()) { if (PaperLib.isPaper()) {
synchronized (chunk) {
packet = new ClientboundLevelChunkWithLightPacket( packet = new ClientboundLevelChunkWithLightPacket(
levelChunk, levelChunk,
nmsWorld.getChunkSource().getLightEngine(), nmsWorld.getChunkSource().getLightEngine(),
@ -361,9 +360,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
null, null,
false // last false is to not bother with x-ray false // last false is to not bother with x-ray
); );
}
} else { } else {
synchronized (chunk) {
// deprecated on paper - deprecation suppressed // deprecated on paper - deprecation suppressed
packet = new ClientboundLevelChunkWithLightPacket( packet = new ClientboundLevelChunkWithLightPacket(
levelChunk, levelChunk,
@ -372,7 +369,6 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
null null
); );
} }
}
nearbyPlayers(nmsWorld, coordIntPair).forEach(p -> p.connection.send(packet)); nearbyPlayers(nmsWorld, coordIntPair).forEach(p -> p.connection.send(packet));
}); });
} }

View File

@ -361,7 +361,6 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
MinecraftServer.getServer().execute(() -> { MinecraftServer.getServer().execute(() -> {
ClientboundLevelChunkWithLightPacket packet; ClientboundLevelChunkWithLightPacket packet;
if (PaperLib.isPaper()) { if (PaperLib.isPaper()) {
synchronized (chunk) {
packet = new ClientboundLevelChunkWithLightPacket( packet = new ClientboundLevelChunkWithLightPacket(
levelChunk, levelChunk,
nmsWorld.getChunkSource().getLightEngine(), nmsWorld.getChunkSource().getLightEngine(),
@ -369,9 +368,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
null, null,
false // last false is to not bother with x-ray false // last false is to not bother with x-ray
); );
}
} else { } else {
synchronized (chunk) {
// deprecated on paper - deprecation suppressed // deprecated on paper - deprecation suppressed
packet = new ClientboundLevelChunkWithLightPacket( packet = new ClientboundLevelChunkWithLightPacket(
levelChunk, levelChunk,
@ -380,7 +377,6 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
null null
); );
} }
}
nearbyPlayers(nmsWorld, coordIntPair).forEach(p -> p.connection.send(packet)); nearbyPlayers(nmsWorld, coordIntPair).forEach(p -> p.connection.send(packet));
}); });
} }