3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 04:20:04 +01:00
Paper/Spigot-Server-Patches/0064-Optimize-getBlockData.patch
Zach Brown 30f02fe6e5 Fix the end credits toggle
I think its pretty clear that no one uses this given that it didn't work at all before
2016-03-16 02:41:38 -05:00

32 Zeilen
1.2 KiB
Diff

From 1605c01b00947016970a88f124e76ee1a93fa1ae Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Thu, 3 Mar 2016 02:07:55 -0600
Subject: [PATCH] Optimize getBlockData
Hot method, so reduce # of instructions for the method.
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index 5df38be..19788ed 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -392,8 +392,15 @@ public class Chunk {
return this.a(i, j, k).c();
}
+ // Paper - Optimize getBlockData
public IBlockData getBlockData(BlockPosition blockposition) {
- return this.a(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ if (blockposition.getY() >= 0 && blockposition.getY() >> 4 < this.sections.length) {
+ ChunkSection chunksection = this.sections[blockposition.getY() >> 4];
+ if (chunksection != null) {
+ return chunksection.getType(blockposition.getX() & 15, blockposition.getY() & 15, blockposition.getZ() & 15);
+ }
+ }
+ return Blocks.AIR.getBlockData();
}
public IBlockData a(final int i, final int j, final int k) {
--
2.7.2