Solved Item in hand not changing

Discussion in 'Plugin Development' started by MinecraftMart, Jan 1, 2015.

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

    MinecraftMart

    So what im asking would probly be the easiest thing ever, altough i still cant fix it..
    So im changing the itemstack thats in the hand. But it doesnt work, i do get the 2 messages but it aint changing the item.

    Code:
    if(p.isSneaking()){
                            p.sendMessage("is sneaking");
                            if(p.getInventory().getItemInHand().getItemMeta().getDisplayName().contains(ChatColor.RED + "Fireball Spell")){
                                p.sendMessage("Fire Check");
                                p.getInventory().setItemInHand(null);
                                p.getInventory().setItemInHand(wands.lightning);
                            }
     
  2. remove p.getInventory().setItemInHand(null);
    Are there any errors in the console?
    What is wands.lightning?
     
  3. Offline

    mine-care

    P.updateInventory();
    Even if deprecated it still works
     
  4. Offline

    MinecraftMart

    @mine-care
    You sir, are a genius. How could i have forgotten this.....

    Eeh, its still not working


    @FisheyLP
    I did and no errors,
    and its an ItemStack in another class

    EDIT: it seems to be going either too fast or nothing happens. Because when i rightclick 2 times very fast it goes to the other item but then changes back.

    Full code:
    Code:
    if(p.isSneaking()){
                            if(p.getInventory().getItemInHand().getItemMeta().getDisplayName().contains(ChatColor.RED + "Fireball Spell")){
                                p.getInventory().setItemInHand(wands.lightning);
                                p.setItemInHand(wands.lightning);
                                p.updateInventory();
                                return;
                            }
                            if(p.getInventory().getItemInHand().getItemMeta().getDisplayName().contains(ChatColor.RED + "Lumos")){
                                p.getInventory().setItemInHand(wands.wither);
                                p.updateInventory();
                            }
                            if(p.getInventory().getItemInHand().getItemMeta().getDisplayName().contains(ChatColor.RED + "Wither Spell")){
                                p.getInventory().setItemInHand(wands.freeze);
                                p.updateInventory();
                            }
                            if(p.getInventory().getItemInHand().getItemMeta().getDisplayName().contains(ChatColor.RED + "Freeze Spell")){
                                p.getInventory().setItemInHand(wands.fireBall);
                                p.updateInventory();
                            }
    }
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Oct 31, 2016
  5. Offline

    mine-care

    ThankS =]
    Check for event double fire ;3
     
Thread Status:
Not open for further replies.

Share This Page