Solved Offhand slot id??

Discussion in 'Spigot Plugin Development' started by rippin, May 19, 2016.

  1. I was googling this and couldn't figure out, what the the slot id for the offhand?
    Thanks in advance.
  2. Could you possibly use instead? I'm just getting into development so i'm not sure if that's what you're looking for.
    Code (Text):
    Edit: Just tried it. Doesn't seem to work

    Edit2: Just kidding. I was a dummy and tested the wrong thing
    Code (Text):
    Work to get the off hand 'Slot'. Even though it's treated not like a slot
    #2 SirTak, May 19, 2016
    Last edited: May 19, 2016
  3. I don't know what do you mean by slot id

    but may help
  4. A good tip when trying to find something is to just nose around. Especially given the main IDEs IntelliJ and Eclipse they give suggestions on what methods you can use so usually that can give you a trail to fixing/finding a solution. That's how I found that method btw.
  5. well done in spigot there's a method wherein you can edit the thread and change the prefix as solved if the problem is no longer existed.
  6. I'm pretty sure he's trying to find the ID number of the off hand slot, so he can call Inventory#setItem.

    You can find this pretty easily by making an event listener that prints the clicked slot to console when a player clicks in an inventory.
  7. Edit: This should help.

    Code (Text):
      public ItemStack getItemInOffHand()
        return CraftItemStack.asCraftMirror(getInventory().extraSlots[0]);

      public void setItemInOffHand(ItemStack item)
        ItemStack[] extra = getExtraContents();
        extra[0] = item;
    • Like Like x 1
  8. What's the difference between that and just setting the offhand using the command I suggested? Because it seems you can set item for off hand like what I said previously
  9. There isn't a difference, and you didn't suggest that, you suggested using PlayerInventory#getItemInOffHand, when it should be set.

    Also, it's not a command, it's a method (or function).