2016-03-25 07:38:38 +01:00
|
|
|
From 913ffd56eaf018ef08a5581bdb34cf4e98d9327e Mon Sep 17 00:00:00 2001
|
2016-02-14 02:29:59 +01:00
|
|
|
From: Aikar <aikar@aikar.co>
|
2016-03-01 00:09:49 +01:00
|
|
|
Date: Thu, 3 Mar 2016 02:07:55 -0600
|
2016-02-14 02:29:59 +01:00
|
|
|
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
|
2016-03-25 07:38:38 +01:00
|
|
|
index 9020b1b..f233c13 100644
|
2016-02-14 02:29:59 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/Chunk.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
2016-03-25 07:38:38 +01:00
|
|
|
@@ -403,8 +403,15 @@ public class Chunk {
|
2016-03-01 00:09:49 +01:00
|
|
|
return this.a(i, j, k).c();
|
2016-02-14 02:29:59 +01:00
|
|
|
}
|
|
|
|
|
2016-03-01 00:09:49 +01:00
|
|
|
+ // Paper - Optimize getBlockData
|
|
|
|
public IBlockData getBlockData(BlockPosition blockposition) {
|
|
|
|
- return this.a(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
2016-02-14 02:29:59 +01:00
|
|
|
+ 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();
|
2016-03-01 00:09:49 +01:00
|
|
|
}
|
2016-02-14 02:29:59 +01:00
|
|
|
|
2016-03-01 00:09:49 +01:00
|
|
|
public IBlockData a(final int i, final int j, final int k) {
|
2016-02-14 02:29:59 +01:00
|
|
|
--
|
2016-03-25 07:38:38 +01:00
|
|
|
2.7.1.windows.2
|
2016-02-14 02:29:59 +01:00
|
|
|
|