Synchronize DataPaletteBlock instead of ReentrantLock
Mojang has flaws in their logic about chunks being concurrently wrote to. So we constantly see crashes around multiple threads writing. Additionally, java has optimized synchronization so well that its in many times faster than trying to manage read wrote locks for low contention situations. And this is extremely a low contention situation. Fixes #3293 Fixes #2493
This commit is contained in:
@@ -1119,7 +1119,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
private DataPalette<T> h; private DataPalette<T> getDataPalette() { return this.h; } // Paper - OBFHELPER
|
||||
private int i; private int getBitsPerObject() { return this.i; } // Paper - OBFHELPER
|
||||
@@ -0,0 +0,0 @@ public class DataPaletteBlock<T> implements DataPaletteExpandable<T> {
|
||||
this.j.unlock();
|
||||
//this.j.unlock(); // Paper - disable this
|
||||
}
|
||||
|
||||
- public DataPaletteBlock(DataPalette<T> datapalette, RegistryBlockID<T> registryblockid, Function<NBTTagCompound, T> function, Function<T, NBTTagCompound> function1, T t0) {
|
||||
@@ -1181,12 +1181,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
}
|
||||
|
||||
- public void writeDataPaletteBlock(PacketDataSerializer packetDataSerializer) { this.b(packetDataSerializer); } // Paper - OBFHELPER
|
||||
- public void b(PacketDataSerializer packetdataserializer) {
|
||||
- public synchronized void b(PacketDataSerializer packetdataserializer) { // Paper - synchronize
|
||||
+ // Paper start - Anti-Xray - Add chunk packet info
|
||||
+ @Deprecated public void writeDataPaletteBlock(PacketDataSerializer packetDataSerializer) { this.b(packetDataSerializer); } // OBFHELPER // Notice for updates: Please make sure this method isn't used anywhere
|
||||
+ @Deprecated public void b(PacketDataSerializer packetdataserializer) { this.writeDataPaletteBlock(packetdataserializer, null, 0); } // Notice for updates: Please make sure this method isn't used anywhere
|
||||
+ public void writeDataPaletteBlock(PacketDataSerializer packetDataSerializer, ChunkPacketInfo<T> chunkPacketInfo, int chunkSectionIndex) { this.b(packetDataSerializer, chunkPacketInfo, chunkSectionIndex); } // OBFHELPER
|
||||
+ public void b(PacketDataSerializer packetdataserializer, ChunkPacketInfo<T> chunkPacketInfo, int chunkSectionIndex) {
|
||||
+ public synchronized void b(PacketDataSerializer packetdataserializer, ChunkPacketInfo<T> chunkPacketInfo, int chunkSectionIndex) { // Paper - synchronize
|
||||
+ // Paper end
|
||||
this.a();
|
||||
packetdataserializer.writeByte(this.i);
|
||||
@@ -1203,7 +1203,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
this.b();
|
||||
}
|
||||
|
||||
public void a(NBTTagList nbttaglist, long[] along) {
|
||||
public synchronized void a(NBTTagList nbttaglist, long[] along) { // Paper - synchronize
|
||||
this.a();
|
||||
- int i = Math.max(4, MathHelper.d(nbttaglist.size()));
|
||||
+ // Paper - Anti-Xray - TODO: Should this.predefinedObjects.length just be added here (faster) or should the contents be compared to calculate the size (less RAM)?
|
||||
|
||||
Reference in New Issue
Block a user