mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 23:38:25 +01:00
Optimize getBlockData
This commit is contained in:
parent
720abf5ab8
commit
026367d300
1 changed files with 31 additions and 0 deletions
31
Spigot-Server-Patches/Optimize-getBlockData.patch
Normal file
31
Spigot-Server-Patches/Optimize-getBlockData.patch
Normal file
|
@ -0,0 +1,31 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sat, 13 Feb 2016 19:28:50 -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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/Chunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
||||
@@ -0,0 +0,0 @@ public class Chunk {
|
||||
}
|
||||
}
|
||||
|
||||
+ // PaperSpigot start - Optimize getBlockData
|
||||
public IBlockData getBlockData(final BlockPosition blockposition) {
|
||||
+ 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 getBlockDataSlow(final BlockPosition blockposition) {
|
||||
+ // PaperSpigot end
|
||||
if (this.world.G() == WorldType.DEBUG_ALL_BLOCK_STATES) {
|
||||
IBlockData iblockdata = null;
|
||||
|
||||
--
|
Loading…
Reference in a new issue