3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-09-08 20:43:04 +02:00

Determine chunk Y offset on Java packet processing thread

Should stop NullPointerExceptions if the session closes before chunks are processed
Dieser Commit ist enthalten in:
Camotoy 2021-06-25 13:51:52 -04:00
Ursprung 975da57617
Commit f9f74a0da8
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 7EEFB66FE798081F
2 geänderte Dateien mit 5 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -55,9 +55,12 @@ public class JavaChunkDataTranslator extends PacketTranslator<ServerChunkDataPac
session.getChunkCache().addToCache(packet.getColumn());
Column column = packet.getColumn();
// Ensure that, if the player is using lower world heights, the position is not offset
int yOffset = session.getChunkCache().getChunkMinY();
GeyserConnector.getInstance().getGeneralThreadPool().execute(() -> {
try {
ChunkUtils.ChunkData chunkData = ChunkUtils.translateToBedrock(session, column);
ChunkUtils.ChunkData chunkData = ChunkUtils.translateToBedrock(session, column, yOffset);
ChunkSection[] sections = chunkData.getSections();
// Find highest section

Datei anzeigen

@ -81,10 +81,8 @@ public class ChunkUtils {
return (yzx >> 8) | (yzx & 0x0F0) | ((yzx & 0x00F) << 8);
}
public static ChunkData translateToBedrock(GeyserSession session, Column column) {
public static ChunkData translateToBedrock(GeyserSession session, Column column, int yOffset) {
Chunk[] javaSections = column.getChunks();
// Ensure that, if the player is using lower world heights, the position is not offset
int yOffset = session.getChunkCache().getChunkMinY();
ChunkSection[] sections = new ChunkSection[javaSections.length - yOffset];
// Temporarily stores compound tags of Bedrock-only block entities