9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-27 10:59:16 +00:00

Paper PR: Fix async command building throwing CME in some cases

This commit is contained in:
Dreeam
2025-11-02 13:13:22 -05:00
parent 1cc858e644
commit e11accb01b
33 changed files with 96 additions and 4 deletions

View File

@@ -0,0 +1,31 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: hayanesuru <hayanesuru@outlook.jp>
Date: Sat, 9 Aug 2025 14:55:37 +0900
Subject: [PATCH] optimize get chunk
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
index e900060907ce7612b251bdf6d526ef83ea968a7a..f32c1b7e77703265c675683ff7f774dd3d725957 100644
--- a/net/minecraft/world/level/Level.java
+++ b/net/minecraft/world/level/Level.java
@@ -1410,12 +1410,17 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
}
}
// CraftBukkit end
- if (this.isOutsideBuildHeight(pos)) {
+ // Leaf start - optimize get chunk
+ int x = pos.getX();
+ int y = pos.getY();
+ int z = pos.getZ();
+ if (this.isOutsideBuildHeight(y)) {
return Blocks.VOID_AIR.defaultBlockState();
} else {
- ChunkAccess chunk = this.getChunk(pos.getX() >> 4, pos.getZ() >> 4, ChunkStatus.FULL, true); // Paper - manually inline to reduce hops and avoid unnecessary null check to reduce total byte code size, this should never return null and if it does we will see it the next line but the real stack trace will matter in the chunk engine
- return chunk.getBlockState(pos);
+ ChunkAccess chunk = this.getChunk(x >> 4, z >> 4, ChunkStatus.FULL, true); // Paper - manually inline to reduce hops and avoid unnecessary null check to reduce total byte code size, this should never return null and if it does we will see it the next line but the real stack trace will matter in the chunk engine
+ return chunk.getBlockState(x, y, z);
}
+ // Leaf end - optimize get chunk
}
@Override