[SPIGOT-7928] ExactChoice acts as MaterialChoice (1.21.3) Created: 26/Oct/24  Updated: 25/Dec/24  Resolved: 26/Oct/24

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Jojo56627 Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: Crafting, RecipeChoices, Recipes
Environment:

Normal Windows 10 Local server with Java Version:

java version "21.0.4" 2024-07-16 LTS
Java(TM) SE Runtime Environment (build 21.0.4+8-LTS-274)
Java HotSpot(TM) 64-Bit Server VM (build 21.0.4+8-LTS-274, mixed mode, sharing) 

Attachments: PNG File Bild_2024-10-26_132519593.png     PNG File Bild_2024-10-26_132523434.png     PNG File Bild_2024-10-26_133313894.png    
Version: CraftBukkit version 4354-Spigot-5eb8a94-c7aab7f (MC: 1.21.3) (Implementing API version 1.21.3-R0.1-SNAPSHOT)
Guidelines Read: Yes

 Description   

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.



 Comments   
Comment by Jojo56627 [ 26/Oct/24 ]

Because I found a workaround using theĀ 
PrepareItemCraftEvent I degraded the priority.

Generated at Sat Dec 13 13:38:37 UTC 2025 using Jira 10.3.13#10030013-sha1:56dd970ae30ebfeda3a697d25be1f6388b68a422.