9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-26 18:39:23 +00:00
Files
Leaf/leaf-server/minecraft-patches/features/0281-optimize-LevelChunk-getBlockStateFinal.patch
Dreeam d36ed6c316 Remove OP lock (#486)
Current implementation of OP lock is not an appropriate solution to prevent plugins that contain backdoor or malicious code. There are many ways to bypass this check to manipulate the OP list or permissions. The best way to prevent this kind of grief is to get plugins from valid and trustworthy places.
2025-08-31 23:53:19 -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