mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Determine chunk Y offset on Java packet processing thread
Should stop NullPointerExceptions if the session closes before chunks are processed
This commit is contained in:
parent
975da57617
commit
f9f74a0da8
2 changed files with 5 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue