setIngredient + ItemStack || ItemStack => Material

Discussion in 'Spigot Plugin Development' started by to175, Jul 21, 2015.

  1. Hello, help me please, What is the material of BoneMeal ?
    Code (Text):
    ItemStack bonemeal = new ItemStack(Material.INK_SACK, 1, (short) 15);
    //...
    Rxp.shape("GSB", "SGS", "ADA");
    Rxp.setIngredient('B', bonemeal);
    //...
    The method setIngredient(char, MaterialData) in the type ShapedRecipe is not applicable for the arguments (char, ItemStack)
     
  2. Use this method (or use the MaterialData variant)
     
  3. What ?? This method is for a higher number than 1 (of elements) this is an integer not itemstack... I need bone meal !
     
  4. Read the docs again.
     
  5. thanks, hum I will take a look, however I thought it is deprecated :(

    Then how to do "3 sticks in same box" ?
    "XXX","XXX","XSX" with S=3 sticks
     
  6. Dude, you need a (byte). Example:
    Code (Text):
    ItemStack colorshop = new ItemStack(Material.INK_SACK, 1, (byte)4); //gives lapis
     
  7. That still won't fix anything... Set ingredient needs a material not an ItemStack so fixing up the ItemStack won't fix his problem
     
    • Like Like x 1
  8. You can't do the three sticks without events checking for when they are crafting the item then checking if there are 3 sticks in the crafting matrix, if not cancelling the craft :) and I assume you looked at the docs again because he did give the correct answer :)
     
  9. O, read that wrong. :p
     
  10. In order to get bonemeal in the recipe, use the setIngredient method and make the third argument the data value (15, I think?). As for the three sticks, that's not quite possible using the built-in crafting methods, however you may be able to use the InventoryClickEvent to manually check for the three sticks, and cancel the craft if they're not there.