Item in hand

Discussion in 'Plugin Development' started by Laekh, Jun 13, 2013.

Thread Status:
Not open for further replies.
  1. Hello,

    I've ran into a problem.

    I'm trying to show a different item in the player's hand without it actually replacing the item they were holding, for instance, when they block with a wooden shield, a melon would show up, but they would still be blocking with the sword.

    I've looked into a lot of packets, but can't seem to be able to find anything helpful.

    Does anyone have any idea what would allow me to do this?
    ProtocolLib usage is allowed for this.

    Thank you.

    After a (VERY) long search, my end result didn't even work.
    Does anyone know why?

    Most really good devs told me that it wasn't even possible to do what I wanted, but it might.

    Code:
       for(Player players : Bukkit.getServer().getOnlinePlayers()) {
       ItemStack goldIngot = new ItemStack(Material.GOLD_INGOT);
       net.minecraft.server.v1_5_R3.ItemStack newgoldIngot = CraftItemStack.asNMSCopy(goldIngot);
          ((CraftPlayer) players).getHandle().playerConnection.sendPacket(new Packet5EntityEquipment(((CraftPlayer) players).getEntityId(), 0, newgoldIngot));
      }
    
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 1, 2016
  2. Offline

    Garris0n

    I'm assuming telling the client "hey you just equipped a gold ingot" even though the client KNOWS it's not holding a gold ingot causes some issues. This would work to show all OTHER players he's holding a gold ingot and disguise his true item, but it will probably just mess up the client and cause problems if you send it to that player. If you're trying to change the item rendered but continue "blocking with a sword" that's not gonna work. The client renders that sword block based on the item in its hand, so you can't just change it around without changing the item as far as I know.
     

  3. Makes sense, too bad that it doesn't work then.
    Thank you for your help.
     
Thread Status:
Not open for further replies.

Share This Page