mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-08 11:50:32 +01:00
9ff01b16ab
This will be used by my next commit. But trying to get the build going since CI blew up
32 lines
1.2 KiB
Diff
32 lines
1.2 KiB
Diff
From 5a12cc3597b9adaa7c33ca1a9a31da1b61e3ac4c 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 3b5e8c2..42fedb7 100644
|
|
--- a/src/main/java/net/minecraft/server/Chunk.java
|
|
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
|
@@ -403,8 +403,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.4
|
|
|