Adding certain potions to inventory

Discussion in 'Plugin Development' started by CrazedMC, Aug 18, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    CrazedMC

    Can I have some help with adding a potion to the inventory like a strength potion?
    Because whenever I do:
    Code:
    ItemStack potion = new ItemStack (Material.POTION)
    It just comes up with potion.
     
  2. Offline

    DrTURTLE2

    Oh my lord
     
  3. Offline

    CrazedMC

  4. Offline

    DrTURTLE2

    I msged him over skype, this IS solved xD
     
  5. Offline

    Sabersamus

    try this:

    Code:
    Potion strength_potion = new Potion(PotionType.STRENGTH, 1); //Creates a new Strength 1 potion
    ItemStack stack = strength_potion.toItemStack(1);//converts the potion to an item stack
    player.getInventory().addItem(stack);//adds item to players inventory
    
    Sorry if I misspelled anything, I'm tired.

    Other than that, this should work
     
  6. Potions have sub-types, what you can do is:

    Code:java
    1.  
    2. ItemStack potion = new ItemStack(Material.POTION, <amount>, <subtype>
    3. //Example:
    4. //If I wanted, let's say a potion of Regeneration...
    5. ItemStack potion = new ItemStack(Material.POTION, 1, 8289);
    6.  

    Link to potion Subtypes:
    http://www.minecraftwiki.net/wiki/Potions#Data_value_table
     
  7. Offline

    Sabersamus

    Or you could do it how I just said, which is easier to remember (you're way works too, mines just, more friendly :p)
     
  8. Offline

    DrTURTLE2

    Or you could just read what I posted earlier... That works too.
     
  9. Offline

    Sabersamus

    You said its not solved.
     
  10. Offline

    DrTURTLE2

    WHOOPS
    LOL

    IT IS SOLVED XD
     
Thread Status:
Not open for further replies.

Share This Page