Mushroom soup heal help!

Discussion in 'Plugin Development' started by MrZancrow, Dec 29, 2013.

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

    MrZancrow

    (p.getItemInHand().getTypeId()== Material.MUSHROOM_SOUP.getId())

    getTypeId() and getID() are yellow and i dont now how i can fix it ?
     
  2. Offline

    Maulss

    getId() and getTypeId() are deprecated.

    Instead, use their Material enum names:

    if (p.getInventory().getItemInHand() == Material.MUSHROOM_SOUP) {}
     
  3. Offline

    NathanWolf

    I think you need a getType() in the above poster's code, since getItemInHand returns an ItemStack, and you want it's Material.
     
  4. Offline

    AoH_Ruthless

    Maulss
    it's p.getItemInHand().getType(), not p.getInventory().getItemInHand()

    MrZancrow
    All Item Id's and Data values are deprecated (Minecraft is moving away from magic numbers)

    EDIT: Ninja'd by NathanWolf
     
  5. Offline

    PolarCraft

    MrZancrow NathanWolf Maulss This is what i did.
    Code:java
    1. @EventHandler
    2. public void onRightClick(PlayerInteractEvent e)
    3. {
    4. Player p = e.getPlayer();
    5. if (p.getHealth() != 20.0D) //ARGUMENT SO IF HEALTH IS 20 THEN IT WILL NOT EAT THE SOUP
    6. {
    7. int soup = 7;
    8. if ((e.getAction() == Action.RIGHT_CLICK_AIR) || ((e.getAction() == Action.RIGHT_CLICK_BLOCK) && (p.getItemInHand().getType() == Material.MUSHROOM_SOUP))) { //CHECKS TO SEE IF ITEMINHAND IS MUSHROOM_SOUP
    9. p.setHealth(p.getHealth() + soup > p.getMaxHealth() ? p.getMaxHealth() : p.getHealth() + soup); //CHECKS TO SEE IF HEALTH IS GREATER OR LESS THAN 20 AND IF LESS THAN IT SETS IT TO 20
    10. p.getItemInHand().setType(Material.BOWL); // ONCE TAKEN IT MAKES THE MUSHROOM_SOUP INTO A BOWL
    11. }
    12. }
    13. }
    14. }
     
Thread Status:
Not open for further replies.

Share This Page