Solved Fire Help!

Discussion in 'Plugin Development' started by SuperboyDev, Aug 29, 2015.

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

    SuperboyDev

    Hi, I'm creating a plugin where when a player right clicks a water bottle, it check whether the player is on fire. If he is, he is no longer on fire. This is my code:
    Code:
    @EventHandler
        public void onFireExt(PlayerInteractEvent event) {
            ItemStack bottle = new ItemStack(Material.POTION, 1, (byte) 0);
            if (event.getPlayer().getFireTicks() != 0) {
                if ((event.getAction() == Action.RIGHT_CLICK_AIR || event
                        .getAction() == Action.RIGHT_CLICK_BLOCK)
                        && event.getPlayer().getItemInHand() == bottle) {
                    event.getPlayer().setFireTicks(0);
                }
            }
        }
    For some reason, it doesn't remove the fire. Please help!
     
  2. Offline

    Hawktasard

    @SuperboyDev
    The item the player has in their hand and the itemstack you create before you do the check will never be the same. Try event.getPlayer().getItemInHand().isSimilar(bottle).
     
  3. Offline

    SuperboyDev

    @Hawktasard thanks! It worked great! Thanks for the help. :D But I also have one problem. I'm trying to remove the bottle from his hand. Not change it to an empty bottle :p

    EDIT: Oh wait, never mind. I figured it out. Thanks!
     
    Last edited: Aug 29, 2015
Thread Status:
Not open for further replies.

Share This Page