3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 12:30:06 +01:00
Paper/Spigot-API-Patches/0276-Cache-the-result-of-Material-isBlock.patch
Jason 45bc531dd3
Fix Material#getTranslationKey for Block Materials (#5294)
* Fix Material#getTranslationKey for Block Materials

* Cache the result of Material#isBlock
2021-03-02 16:27:34 -08:00

39 Zeilen
1.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: jmp <jasonpenilla2@me.com>
Date: Tue, 2 Mar 2021 15:24:58 -0800
Subject: [PATCH] Cache the result of Material#isBlock
diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java
index 2a3becabbd10fa8ffd19f35a3f6d8a6bfcb388c3..7b77c7132723a01e8c38ddaa616b363be300b653 100644
--- a/src/main/java/org/bukkit/Material.java
+++ b/src/main/java/org/bukkit/Material.java
@@ -3521,6 +3521,7 @@ public enum Material implements Keyed {
public final Class<?> data;
private final boolean legacy;
private final NamespacedKey key;
+ private boolean isBlock; // Paper
private Material(final int id) {
this(id, 64);
@@ -3718,6 +3719,11 @@ public enum Material implements Keyed {
* @return true if this material is a block
*/
public boolean isBlock() {
+ // Paper start - cache isBlock
+ return this.isBlock;
+ }
+ private boolean isBlock0() {
+ // Paper end
switch (this) {
//<editor-fold defaultstate="collapsed" desc="isBlock">
case ACACIA_BUTTON:
@@ -4663,6 +4669,7 @@ public enum Material implements Keyed {
static {
for (Material material : values()) {
BY_NAME.put(material.name(), material);
+ material.isBlock = material.isBlock0(); // Paper
}
}