diff --git a/Spigot-API-Patches/Cache-the-result-of-Material-isBlock.patch b/Spigot-API-Patches/Cache-the-result-of-Material-isBlock.patch new file mode 100644 index 0000000000..d506462869 --- /dev/null +++ b/Spigot-API-Patches/Cache-the-result-of-Material-isBlock.patch @@ -0,0 +1,38 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jason Penilla <11360596+jpenilla@users.noreply.github.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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/Material.java ++++ b/src/main/java/org/bukkit/Material.java +@@ -0,0 +0,0 @@ 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); +@@ -0,0 +0,0 @@ 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: +@@ -0,0 +0,0 @@ public enum Material implements Keyed { + static { + for (Material material : values()) { + BY_NAME.put(material.name(), material); ++ material.isBlock = material.isBlock0(); // Paper + } + } + diff --git a/Spigot-Server-Patches/Add-a-way-to-get-translation-keys-for-blocks-entitie.patch b/Spigot-Server-Patches/Add-a-way-to-get-translation-keys-for-blocks-entitie.patch index 88991f589f..2e083bee2b 100644 --- a/Spigot-Server-Patches/Add-a-way-to-get-translation-keys-for-blocks-entitie.patch +++ b/Spigot-Server-Patches/Add-a-way-to-get-translation-keys-for-blocks-entitie.patch @@ -92,6 +92,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @Override + public String getTranslationKey(Material mat) { ++ if (mat.isBlock()) { ++ return getBlock(mat).getDescriptionId(); ++ } + return getItem(mat).getOrCreateDescriptionId(); + } +