Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-08 17:20:20 +01: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:
Ursprung
975da57617
Commit
f9f74a0da8
@ -55,9 +55,12 @@ public class JavaChunkDataTranslator extends PacketTranslator<ServerChunkDataPac
|
|||||||
session.getChunkCache().addToCache(packet.getColumn());
|
session.getChunkCache().addToCache(packet.getColumn());
|
||||||
Column column = 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(() -> {
|
GeyserConnector.getInstance().getGeneralThreadPool().execute(() -> {
|
||||||
try {
|
try {
|
||||||
ChunkUtils.ChunkData chunkData = ChunkUtils.translateToBedrock(session, column);
|
ChunkUtils.ChunkData chunkData = ChunkUtils.translateToBedrock(session, column, yOffset);
|
||||||
ChunkSection[] sections = chunkData.getSections();
|
ChunkSection[] sections = chunkData.getSections();
|
||||||
|
|
||||||
// Find highest section
|
// Find highest section
|
||||||
|
@ -81,10 +81,8 @@ public class ChunkUtils {
|
|||||||
return (yzx >> 8) | (yzx & 0x0F0) | ((yzx & 0x00F) << 8);
|
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();
|
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];
|
ChunkSection[] sections = new ChunkSection[javaSections.length - yOffset];
|
||||||
|
|
||||||
// Temporarily stores compound tags of Bedrock-only block entities
|
// Temporarily stores compound tags of Bedrock-only block entities
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren