3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-12-26 16:12:46 +01:00

Reduce Frequency of Crashes Due to Dispensers, Droppers, and Chiseled Bookshelves (#4248)

* Revert to subchunk v8; reduces freq of #4240

* Full resolution
Dieser Commit ist enthalten in:
Kas-tle 2023-10-26 08:16:24 -07:00 committet von GitHub
Ursprung 2e68244fde
Commit 8d2ebcf69b
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
3 geänderte Dateien mit 15 neuen und 17 gelöschten Zeilen

Datei anzeigen

@ -30,19 +30,18 @@ import org.cloudburstmc.protocol.common.util.Preconditions;
public class GeyserChunkSection { public class GeyserChunkSection {
// As of at least 1.19.80 // Temporary reversion to v8 as it reduces the frequnecy of https://github.com/GeyserMC/Geyser/issues/4240
private static final int CHUNK_SECTION_VERSION = 9; // This does not fully resolve the issue so a better solution is still needed
private static final int CHUNK_SECTION_VERSION = 8;
private final BlockStorage[] storage; private final BlockStorage[] storage;
private final int sectionY;
public GeyserChunkSection(int airBlockId, int sectionY) { public GeyserChunkSection(int airBlockId) {
this(new BlockStorage[]{new BlockStorage(airBlockId), new BlockStorage(airBlockId)}, sectionY); this(new BlockStorage[]{new BlockStorage(airBlockId), new BlockStorage(airBlockId)});
} }
public GeyserChunkSection(BlockStorage[] storage, int sectionY) { public GeyserChunkSection(BlockStorage[] storage) {
this.storage = storage; this.storage = storage;
this.sectionY = sectionY;
} }
public int getFullBlock(int x, int y, int z, int layer) { public int getFullBlock(int x, int y, int z, int layer) {
@ -61,7 +60,6 @@ public class GeyserChunkSection {
buffer.writeByte(CHUNK_SECTION_VERSION); buffer.writeByte(CHUNK_SECTION_VERSION);
buffer.writeByte(this.storage.length); buffer.writeByte(this.storage.length);
// Required for chunk version 9+ // Required for chunk version 9+
buffer.writeByte(this.sectionY);
for (BlockStorage blockStorage : this.storage) { for (BlockStorage blockStorage : this.storage) {
blockStorage.writeToNetwork(buffer); blockStorage.writeToNetwork(buffer);
} }
@ -88,12 +86,12 @@ public class GeyserChunkSection {
return true; return true;
} }
public GeyserChunkSection copy(int sectionY) { public GeyserChunkSection copy() {
BlockStorage[] storage = new BlockStorage[this.storage.length]; BlockStorage[] storage = new BlockStorage[this.storage.length];
for (int i = 0; i < storage.length; i++) { for (int i = 0; i < storage.length; i++) {
storage[i] = this.storage[i].copy(); storage[i] = this.storage[i].copy();
} }
return new GeyserChunkSection(storage, sectionY); return new GeyserChunkSection(storage);
} }
public static int blockPosition(int x, int y, int z) { public static int blockPosition(int x, int y, int z) {

Datei anzeigen

@ -154,7 +154,7 @@ public class JavaLevelChunkWithLightTranslator extends PacketTranslator<Clientbo
} }
BlockStorage[] layers = new BlockStorage[]{ layer0 }; BlockStorage[] layers = new BlockStorage[]{ layer0 };
sections[bedrockSectionY] = new GeyserChunkSection(layers, bedrockSectionY); sections[bedrockSectionY] = new GeyserChunkSection(layers);
} }
EXTENDED_COLLISIONS_STORAGE.get().clear(); EXTENDED_COLLISIONS_STORAGE.get().clear();
extendedCollisionNextSection = false; extendedCollisionNextSection = false;
@ -167,7 +167,7 @@ public class JavaLevelChunkWithLightTranslator extends PacketTranslator<Clientbo
if (javaPalette instanceof GlobalPalette) { if (javaPalette instanceof GlobalPalette) {
// As this is the global palette, simply iterate through the whole chunk section once // As this is the global palette, simply iterate through the whole chunk section once
GeyserChunkSection section = new GeyserChunkSection(session.getBlockMappings().getBedrockAir().getRuntimeId(), bedrockSectionY); GeyserChunkSection section = new GeyserChunkSection(session.getBlockMappings().getBedrockAir().getRuntimeId());
for (int yzx = 0; yzx < BlockStorage.SIZE; yzx++) { for (int yzx = 0; yzx < BlockStorage.SIZE; yzx++) {
int javaId = javaData.get(yzx); int javaId = javaData.get(yzx);
int bedrockId = session.getBlockMappings().getBedrockBlockId(javaId); int bedrockId = session.getBlockMappings().getBedrockBlockId(javaId);
@ -217,9 +217,9 @@ public class JavaLevelChunkWithLightTranslator extends PacketTranslator<Clientbo
if (BlockRegistries.WATERLOGGED.get().get(javaId)) { if (BlockRegistries.WATERLOGGED.get().get(javaId)) {
BlockStorage waterlogged = new BlockStorage(SingletonBitArray.INSTANCE, IntLists.singleton(session.getBlockMappings().getBedrockWater().getRuntimeId())); BlockStorage waterlogged = new BlockStorage(SingletonBitArray.INSTANCE, IntLists.singleton(session.getBlockMappings().getBedrockWater().getRuntimeId()));
sections[bedrockSectionY] = new GeyserChunkSection(new BlockStorage[] {blockStorage, waterlogged}, bedrockSectionY); sections[bedrockSectionY] = new GeyserChunkSection(new BlockStorage[] {blockStorage, waterlogged});
} else { } else {
sections[bedrockSectionY] = new GeyserChunkSection(new BlockStorage[] {blockStorage}, bedrockSectionY); sections[bedrockSectionY] = new GeyserChunkSection(new BlockStorage[] {blockStorage});
} }
if (useExtendedCollisions) { if (useExtendedCollisions) {
EXTENDED_COLLISIONS_STORAGE.get().clear(); EXTENDED_COLLISIONS_STORAGE.get().clear();
@ -378,7 +378,7 @@ public class JavaLevelChunkWithLightTranslator extends PacketTranslator<Clientbo
layers = new BlockStorage[]{ layer0, new BlockStorage(BitArrayVersion.V1.createArray(BlockStorage.SIZE, layer1Data), layer1Palette) }; layers = new BlockStorage[]{ layer0, new BlockStorage(BitArrayVersion.V1.createArray(BlockStorage.SIZE, layer1Data), layer1Palette) };
} }
sections[bedrockSectionY] = new GeyserChunkSection(layers, bedrockSectionY); sections[bedrockSectionY] = new GeyserChunkSection(layers);
extendedCollisionNextSection = thisExtendedCollisionNextSection; extendedCollisionNextSection = thisExtendedCollisionNextSection;
} }
@ -432,7 +432,7 @@ public class JavaLevelChunkWithLightTranslator extends PacketTranslator<Clientbo
IntList palette = bedrockSection.getBlockStorageArray()[0].getPalette(); IntList palette = bedrockSection.getBlockStorageArray()[0].getPalette();
if (palette instanceof IntImmutableList || palette instanceof IntLists.Singleton) { if (palette instanceof IntImmutableList || palette instanceof IntLists.Singleton) {
// TODO there has to be a better way to expand the palette .-. // TODO there has to be a better way to expand the palette .-.
bedrockSection = bedrockSection.copy(bedrockSectionY); bedrockSection = bedrockSection.copy();
sections[bedrockSectionY] = bedrockSection; sections[bedrockSectionY] = bedrockSection;
} }
bedrockSection.setFullBlock(x, y & 0xF, z, 0, blockDefinition.getRuntimeId()); bedrockSection.setFullBlock(x, y & 0xF, z, 0, blockDefinition.getRuntimeId());

Datei anzeigen

@ -63,7 +63,7 @@ public class ChunkUtils {
static { static {
ByteBuf byteBuf = Unpooled.buffer(); ByteBuf byteBuf = Unpooled.buffer();
try { try {
new GeyserChunkSection(new BlockStorage[0], 0) new GeyserChunkSection(new BlockStorage[0])
.writeToNetwork(byteBuf); .writeToNetwork(byteBuf);
SERIALIZED_CHUNK_DATA = new byte[byteBuf.readableBytes()]; SERIALIZED_CHUNK_DATA = new byte[byteBuf.readableBytes()];
byteBuf.readBytes(SERIALIZED_CHUNK_DATA); byteBuf.readBytes(SERIALIZED_CHUNK_DATA);