-
Bug
-
Resolution: Fixed
-
Minor
-
None
-
None
-
CraftBukkit version 4354-Spigot-5eb8a94-c7aab7f (MC: 1.21.3) (Implementing API version 1.21.3-R0.1-SNAPSHOT)
-
Yes
The RecipeChoice.ExactChoice appears to not work as it should. I created a custom recipe using the ExcactChoice. Ingame the recipe is recognized as soon as I put in the required Materials (not checking for other Data like enchantments). My recipe is as follows:
X S X S S X X X
Where S is a Diamond Sword (With ExcactChoice required to have the enchantment Sharpness 1) and X is a plain Iron Ingot.
In the Version 1.21.3 the crafting works with every type of Diamond Sword, no matter if enchanted or not. In the Version 1.21 and 1.21.1 I couldn't reproduce the bug and the crafting works only with a Sharpness 1 Diamond Sword in these versions.
The following code is used to reproduce the bug (only the Plugin Main Class is needed):
package net.quarxy.test; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.NamespacedKey; import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.RecipeChoice; import org.bukkit.inventory.ShapedRecipe; import org.bukkit.plugin.java.JavaPlugin; public final class Test extends JavaPlugin { @Override public void onEnable() { // Plugin startup logic ItemStack RESULT_STACK = new ItemStack(Material.STONE); RESULT_STACK.addUnsafeEnchantment(Enchantment.SILK_TOUCH, 1); ItemStack POSSIBLE = new ItemStack(Material.DIAMOND_SWORD); POSSIBLE.addUnsafeEnchantment(Enchantment.SHARPNESS, 1); ShapedRecipe TEST_RECIPE = new ShapedRecipe(new NamespacedKey(this, "test_recipe"), RESULT_STACK); TEST_RECIPE.shape("XSX", "S S", "XXX"); TEST_RECIPE.setIngredient('X', Material.IRON_INGOT); TEST_RECIPE.setIngredient('S', new RecipeChoice.ExactChoice(POSSIBLE)); Bukkit.addRecipe(TEST_RECIPE); } }
This bug also shows that if you make different recipes with ExcactChoice, where only one item is different (and this difference is purely component/NBT data of the ItemStack (without changing the own item, e.g. always DIAMOND_SWORD) only the last registered recipe is accepted, because the recipe provider does not distinguish between NBT data.