Solved Potions and inventory GUI

Discussion in 'Plugin Development' started by Markyroson, Jun 28, 2015.

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

    Markyroson

    How would I add a potion to my inventory GUI?

    I tried this

    Code:
    Potion potionHealing = new Potion(PotionType.INSTANT_HEAL);
    potionHealing.toItemStack(1);
    inventory.setItem(5, potionHealing);
    but got the error "The method setItem(int, ItemStack) in the type Inventory is not applicable for the arguments (int, Potion)" so how do I add it to the GUI?
     
  2. potion.toItemStack(amount)
     
    Markyroson likes this.
  3. Offline

    Markyroson

    Thank you and I had actually managed to solve it on my own literally 4-5 minutes after posting this ;-)

    Final code for the section is:
    Code:
    Potion potionHealing = new Potion(PotionType.INSTANT_HEAL);
    ItemStack stack = potionHealing.toItemStack(1);
    inventory.setItem(5, stack);
    for anyone possibly reading in future, please be advised that just that code alone will not work and you will have to put it into the context for your individual project/needs, it is merely how to add a potion.
     
Thread Status:
Not open for further replies.

Share This Page