Solved no suitable method found for setIngredient

Discussion in 'Spigot Plugin Help' started by luan2809, Jul 6, 2021.

  1. I'm trying to add recipe to my item but it doesn't work, i really flow the tutorial. Here is my code and sorry for my bad English.

    private static void create_knockback_stick(){
    ItemStack item = new ItemStack(Material.STICK, 1);
    ItemMeta meta = item.getItemMeta();
    meta.setDisplayName("§6Stick");
    List<String> lore = new ArrayList<>();
    lore.add("Stick");
    meta.setLore(lore);
    meta.addEnchant(Enchantment.KNOCKBACK, 100, true);
    meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
    item.setItemMeta(meta);
    knockback_stick = item;

    ItemStack temp = new ItemStack(Material.ENCHANTED_BOOK);
    temp.addEnchantment(Enchantment.KNOCKBACK, 2);
    ShapedRecipe recipe = new ShapedRecipe(NamespacedKey.minecraft("Knockback Stick"), knockback_stick);
    recipe.shape("KKK", "KSK", "KKK");
    recipe.setIngredient("K", temp);
    recipe.setIngredient("S", Material.STICK);
    Bukkit.getServer().addRecipe(recipe);
    }

    And here is the errors:
    upload_2021-7-6_16-4-16.png
     
    #1 luan2809, Jul 6, 2021
    Last edited: Jul 6, 2021
  2. You need to pass a char. So single quotes for the first parameter of setIngredients
     
  3. It's work thanks you but now it have this error upload_2021-7-6_16-35-44.png
     

    Attached Files:

  4. recipe.setIngredient('K', new RecipeChoice.ExactChoice(temp));
     
  5. I did it but why it doesn't work in Minecraft upload_2021-7-6_17-8-0.png
     
  6. Try using "Knockback_Stick" in the NamespacedKey instead of what you have
    Code (Text):
    ShapedRecipe recipe = new ShapedRecipe(NamespacedKey.minecraft("Knockback Stick"), knockback_stick);