mirror of
https://github.com/PaperMC/Paper.git
synced 2025-03-02 11:22:01 +01:00
Cache BlockState for Blocks
Improve performance for many plugins that call .getState() multiple times for things like signs that have to "build" sign data.
This commit is contained in:
parent
ae95189944
commit
8abad348b6
37
Spigot-Server-Patches/Cache-BlockState-for-Blocks.patch
Normal file
37
Spigot-Server-Patches/Cache-BlockState-for-Blocks.patch
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Aikar <aikar@aikar.co>
|
||||||
|
Date: Thu, 14 Jan 2016 01:16:30 -0500
|
||||||
|
Subject: [PATCH] Cache BlockState for Blocks
|
||||||
|
|
||||||
|
Improve performance for many plugins that call .getState() multiple
|
||||||
|
times for things like signs that have to "build" sign data.
|
||||||
|
|
||||||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
||||||
|
@@ -0,0 +0,0 @@ import org.bukkit.util.BlockVector;
|
||||||
|
|
||||||
|
public class CraftBlock implements Block {
|
||||||
|
private final CraftChunk chunk;
|
||||||
|
+ private BlockState state; // Paper
|
||||||
|
private final int x;
|
||||||
|
private final int y;
|
||||||
|
private final int z;
|
||||||
|
@@ -0,0 +0,0 @@ public class CraftBlock implements Block {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Paper start
|
||||||
|
public BlockState getState() {
|
||||||
|
+ if (this.state == null) {
|
||||||
|
+ this.state = getState0();
|
||||||
|
+ }
|
||||||
|
+ return this.state;
|
||||||
|
+ }
|
||||||
|
+ private BlockState getState0() {
|
||||||
|
+ // Paper end
|
||||||
|
Material material = getType();
|
||||||
|
|
||||||
|
switch (material) {
|
||||||
|
--
|
Loading…
Reference in New Issue
Block a user