ShapedRecipe setIngredient

Discussion in 'Plugin Development' started by ZockerBuddie, Apr 27, 2021.

  1. Offline

    ZockerBuddie

    Hey, i want do set an Ingredient by an MaterialData, but ingame it is only Air...

    public RecipeManager() {
    plugin = Main.getPlugin();

    ItemStack backpacksmall = new ItemStack(Material.PHANTOM_MEMBRANE);
    ItemMeta bpsMeta = backpacksmall.getItemMeta();
    bpsMeta.setCustomModelData(1);
    bpsMeta.setDisplayName("Small Backpack");
    backpacksmall.setItemMeta(bpsMeta);
    bpsRecipe = new ShapedRecipe(NamespacedKey.minecraft("backpack_small"), backpacksmall);
    bpsRecipe.shape("LSL", "SCS", "LSL");
    bpsRecipe.setIngredient('L', Material.LEATHER);
    bpsRecipe.setIngredient('S', Material.STRING);
    bpsRecipe.setIngredient('C', Material.CHEST);
    plugin.getServer().addRecipe(bpsRecipe);

    ItemStack backpackbig = new ItemStack(Material.PHANTOM_MEMBRANE);
    ItemMeta bpbMeta = backpackbig.getItemMeta();
    bpbMeta.setCustomModelData(2);
    bpbMeta.setDisplayName("Large Backpack");
    backpackbig.setItemMeta(bpbMeta);
    bpbRecipe = new ShapedRecipe(NamespacedKey.minecraft("backpack_big"), backpackbig);
    bpbRecipe.shape("LSL", "SBS", "LSL");
    bpbRecipe.setIngredient('L', Material.LEATHER);
    bpbRecipe.setIngredient('S', Material.STRING);
    bpbRecipe.setIngredient('B', backpacksmall.getData());
    plugin.getServer().addRecipe(bpbRecipe);
    }
     
  2. Offline

    darthvader1925

    Shouldn't you cast plugin as
    private Main plugin;

    public RecipieManager() {
    plugin = Main.getPlugin(Main.class);
    }
     
  3. Offline

    timtower Administrator Administrator Moderator

Share This Page