diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/level/JavaLevelChunkWithLightTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/level/JavaLevelChunkWithLightTranslator.java index 8f4567e3e..694bff153 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/level/JavaLevelChunkWithLightTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/level/JavaLevelChunkWithLightTranslator.java @@ -81,6 +81,7 @@ import static org.geysermc.geyser.util.ChunkUtils.indexYZXtoXZY; @Translator(packet = ClientboundLevelChunkWithLightPacket.class) public class JavaLevelChunkWithLightTranslator extends PacketTranslator { + private static final ThreadLocal EXTENDED_COLLISIONS_STORAGE = ThreadLocal.withInitial(ExtendedCollisionsStorage::new); @Override public void translate(GeyserSession session, ClientboundLevelChunkWithLightPacket packet) { @@ -113,7 +114,6 @@ public class JavaLevelChunkWithLightTranslator extends PacketTranslator> 8) + ((xzy & 0xF) < 15 ? 1 : -15)) << 8))] = aboveBedrockExtendedCollisionDefinition.getRuntimeId(); + EXTENDED_COLLISIONS_STORAGE.get().set(((yzx & 0x0ff) | (((yzx >> 8) + ((xzy & 0xF) < 15 ? 1 : -15)) << 8)), aboveBedrockExtendedCollisionDefinition.getRuntimeId()); if ((xzy & 0xF) == 15) { thisExtendedCollisionNextSection = true; } @@ -279,15 +279,15 @@ public class JavaLevelChunkWithLightTranslator extends PacketTranslator> 8) + ((xzy & 0xF) < 15 ? 1 : -15)) << 8))] = aboveBedrockExtendedCollisionDefinition.getRuntimeId(); + EXTENDED_COLLISIONS_STORAGE.get().set(((yzx & 0x0ff) | (((yzx >> 8) + ((xzy & 0xF) < 15 ? 1 : -15)) << 8)), aboveBedrockExtendedCollisionDefinition.getRuntimeId()); if ((xzy & 0xF) == 15) { thisExtendedCollisionNextSection = true; } @@ -306,15 +306,15 @@ public class JavaLevelChunkWithLightTranslator extends PacketTranslator> 5] |= 1 << (xzy & 0x1F); } - if (paletteId == airPaletteId && runningSectionExtendedCollisions[yzx] != 0) { - bedrockData.set(xzy, layer0.idFor(runningSectionExtendedCollisions[yzx])); - runningSectionExtendedCollisions[yzx] = 0; + if (paletteId == airPaletteId && EXTENDED_COLLISIONS_STORAGE.get().get(yzx) != 0) { + bedrockData.set(xzy, layer0.idFor(EXTENDED_COLLISIONS_STORAGE.get().get(yzx))); + EXTENDED_COLLISIONS_STORAGE.get().set(yzx, 0); continue; } BlockDefinition aboveBedrockExtendedCollisionDefinition = session.getBlockMappings().getExtendedCollisionBoxes() .get(javaPalette.idToState(paletteId)); if (aboveBedrockExtendedCollisionDefinition != null) { - runningSectionExtendedCollisions[((yzx & 0x0ff) | (((yzx >> 8) + ((xzy & 0xF) < 15 ? 1 : -15)) << 8))] = aboveBedrockExtendedCollisionDefinition.getRuntimeId(); + EXTENDED_COLLISIONS_STORAGE.get().set(((yzx & 0x0ff) | (((yzx >> 8) + ((xzy & 0xF) < 15 ? 1 : -15)) << 8)), aboveBedrockExtendedCollisionDefinition.getRuntimeId()); if ((xzy & 0xF) == 15) { thisExtendedCollisionNextSection = true; } @@ -482,3 +482,23 @@ public class JavaLevelChunkWithLightTranslator extends PacketTranslator