From 7504d25db28af3a7c2fed4774d5105c592570da7 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Thu, 28 May 2020 19:31:24 +1000 Subject: [PATCH] #497: Add Material#getCraftingRemainingItem() to get item left behind after crafting By: ben --- .../src/main/java/org/bukkit/Material.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/paper-api/src/main/java/org/bukkit/Material.java b/paper-api/src/main/java/org/bukkit/Material.java index f28da6efd0..57b0d98121 100644 --- a/paper-api/src/main/java/org/bukkit/Material.java +++ b/paper-api/src/main/java/org/bukkit/Material.java @@ -7978,4 +7978,30 @@ public enum Material implements Keyed { // } } + + /** + * Determines the remaining item in a crafting grid after crafting with this + * ingredient. + *
+ * Only available when {@link #isItem()} is true. + * + * @return the item left behind when crafting, or null if nothing is. + */ + @Nullable + public Material getCraftingRemainingItem() { + Validate.isTrue(isItem(), "The Material is not an item!"); + switch (this) { + // + case WATER_BUCKET: + case LAVA_BUCKET: + case MILK_BUCKET: + return BUCKET; + case DRAGON_BREATH: + case HONEY_BOTTLE: + return GLASS_BOTTLE; + default: + return null; + // + } + } }