Custom items in custom recipe. SPIGOT 1.17

Discussion in 'Spigot Help' started by KingCheese, Aug 11, 2021.

  1. I am working on creating a plugin that adds custom items from custom recipes. I am having trouble using one of my custom items as an ingredient for the custom recipe. How do I do it?
    It says that I can't use an item stack so what do I use?

    Code (Java):
    public ShapelessRecipe Sandwich() {
           
            //Create Tomato
            ItemStack tomato = new ItemStack(Material.RED_DYE);
            ItemMeta tometa = tomato.getItemMeta();
            //Add meta
            tometa.setDisplayName("tomato");
            tometa.setCustomModelData(720001);
            //Assign meta
            tomato.setItemMeta(tometa);
            //Create Sandwich
            ItemStack item = new ItemStack(Material.BREAD);
            ItemMeta meta = item.getItemMeta();
            //Add meta
            meta.setCustomModelData(720002);
            meta.setDisplayName("Chicken Sandwich");
            //Assign meta
            item.setItemMeta(meta);
                   
            NamespacedKey key = new NamespacedKey(this, "chicken_sandwich");
           
            //create recipe
            ShapelessRecipe recipe = new ShapelessRecipe(key, item);
            //add ingredients
            recipe.addIngredient(1, Material.BREAD);
            recipe.addIngredient(1, Material.COOKED_CHICKEN);
            recipe.addIngredient(1, tomato); //where the error is

           
           
            return recipe;
       
        }
     
  2. You forgot add Bukkit.addRecipe(yourRecipe);
     
  3. I have that up In the on enable
    my issue is adding a custom item as an ingredient
     
  4. Can you send it?
     
  5. RecipeChoice.ExactChoice is what you're searching.
     
  6. Where do I put It?
     
  7. That's not the issue
     
  8. I figured it out, I had to make an event handler that makes sure it's the custom item.