Removing everything in inventory (bug?)

Discussion in 'Plugin Development' started by Ronbo, Jun 3, 2013.

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

    Ronbo

    So right now my code looks like this:
    Code:
                                p.getInventory().clear();
                                p.getEquipment().clear();
                                p.getInventory().addItem(new ItemStack(Material.IRON_SWORD));
                                p.getInventory().addItem(new ItemStack(Material.LEATHER_HELMET));
                                p.getInventory().addItem(new ItemStack(Material.LEATHER_CHESTPLATE));
                                p.getInventory().addItem(new ItemStack(Material.LEATHER_LEGGINGS));
                                p.getInventory().addItem(new ItemStack(Material.LEATHER_BOOTS));
                                p.getInventory().addItem(new ItemStack(Material.COOKED_BEEF, 64));
    and this works fine when I left-click the sign that I'm using. However, when I right-click it (i.e. holding an item in my hand), the sign fails to switch out that item, and the slot remains occupied. For example, if I'm holding a diamond sword in my first slot and have it active, and I right click (normally the blocking action on a sword) on a sign that has the above code's function, I'll get all the leather things and the cooked beef, but I won't get the Iron Sword and will instead still have the Diamond Sword that I was holding.
    Help would be greatly appreciated!
     
  2. Offline

    chasechocolate

    Maybe update the player's inventory? player.updateInventory().
     
    Ronbo likes this.
  3. Offline

    Ronbo

    Thanks, that fixed it. I was trying to avoid it since it's deprecated but I guess it'll do.
     
  4. It's not depricated since there is a better version, it's deprecated because it's kind of a workaround to update the inventory.
     
    Ronbo likes this.
Thread Status:
Not open for further replies.

Share This Page