Simple item troubles

Discussion in 'Plugin Development' started by Shzylo, Oct 24, 2013.

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

    Shzylo

    I am always having struggles with my item handling. What I am currently doing is throwing snowballs, but I cancel the event (I am going to set the velocity to a different one) and I can get the hand to empty of snowballs. Once the slot is empty, it is empty.
    If I switch my hotbar to another item and right click, the snowball reappears. Here is my code:
    Code:java
    1. if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
    2. if (item == Material.SNOW_BALL) {
    3. e.setCancelled(true);
    4. p.sendMessage("You cannot throw snowballs!");
    5. if (hand.getAmount() > 1) {
    6. hand.setAmount(hand.getAmount() - 1);
    7. ze.getLogger().info("ASDF");
    8. } else {
    9. hand.setType(Material.AIR);
    10. ze.getLogger().info("FDSA");
    11. }
    12. }
    13. }

    The messages within there were all debug tests, FDSA is called when there is only one snowball is in a player's hand, which is suppposed to set that item to NULL, but it doesn't really do that well. As I said, if I switch to another item in my hotbar and right click, the item re appears.
     
  2. Offline

    MineDoubleSpace

    try calling an inventory update, I had this issue once too. where inventory doesn't update.
     
  3. Offline

    Shzylo

    That doesn't change a thing.
     
Thread Status:
Not open for further replies.

Share This Page