mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-19 15:09:25 +00:00
32 lines
1.7 KiB
Diff
32 lines
1.7 KiB
Diff
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
|