9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-27 02:49:19 +00:00
Files
Leaf/leaf-server/minecraft-patches/features/0287-optimize-LevelChunk-getBlockStateFinal.patch
Dreeam f5b95a6716 Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
PaperMC/Paper@b0da38c2 Repository details in RuntimeException for MavenLibraryResolver#addRepository (#12939)
PaperMC/Paper@1922be90 Update custom tags (#12183)
PaperMC/Paper@79cf1353 Ignore HopperInventorySearchEvent when it has no listeners (#13009)
PaperMC/Paper@ea014f7a feat: add stuckEntityPoiRetryDelay config (#12949)
PaperMC/Paper@a9e76749 Support for showNotification in PlayerRecipeDiscoverEvent (#12992)
PaperMC/Paper@5622c9dd Expose attribute sentiment (#12974)
PaperMC/Paper@42b653b1 Expose more argument types (#12665)
PaperMC/Paper@52d9a221 [ci/skip] Fix typo in Display javadoc (#13010)
PaperMC/Paper@614e9acf Improve APIs around riptide tridents (#12996)
PaperMC/Paper@51706e5a Fixed DyeItem sheep dye hunk
2025-08-25 15:52:00 -04:00

35 lines
1.7 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: hayanesuru <hayanesuru@outlook.jp>
Date: Sat, 9 Aug 2025 15:00:20 +0900
Subject: [PATCH] optimize LevelChunk#getBlockStateFinal
diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java
index e429932a044647f931443c6761d1b39e4eb7665c..6a70665e9b8bc767ba316ada542178634e090afa 100644
--- a/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/net/minecraft/world/level/chunk/LevelChunk.java
@@ -316,12 +316,18 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
public BlockState getBlockStateFinal(final int x, final int y, final int z) {
// Copied and modified from below
- final int sectionIndex = this.getSectionIndex(y);
- if (sectionIndex < 0 || sectionIndex >= this.sections.length
- || this.sections[sectionIndex].nonEmptyBlockCount == 0) {
- return Blocks.AIR.defaultBlockState();
+ // Leaf start - optimize LevelChunk#getBlockStateFinal
+ final int sectionIndex = (y >> 4) - this.minSection;
+ if (sectionIndex < 0 || sectionIndex >= this.sections.length) {
+ return AIR_BLOCKSTATE;
+ } else {
+ LevelChunkSection section = this.sections[sectionIndex];
+ if (section.nonEmptyBlockCount == 0) {
+ return AIR_BLOCKSTATE;
+ }
+ return section.states.get((y & 15) << 8 | (z & 15) << 4 | x & 15);
}
- return this.sections[sectionIndex].states.get((y & 15) << 8 | (z & 15) << 4 | x & 15);
+ // Leaf end - optimize LevelChunk#getBlockStateFinal
}
@Override