From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: jmp 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) { // 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 } }