[SPIGOT-2927] Remove Item for Offhand Item Created: 17/Dec/16  Updated: 17/Dec/16  Resolved: 17/Dec/16

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Thomas C-vS Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: 1.11


 Description   

While looping through the a players inventory contents by using inv.getContents(). When running inv.removeItem(item) on the offhand item. It will not remove any item from the inventory.

The work around for this is to use inv.setItemInOffhand(null). But this is undesirable as it required tracking the index of the current item.



 Comments   
Comment by md_5 [ 17/Dec/16 ]
     * Return the contents from the section of the inventory where items can
     * reasonably be expected to be stored. In most cases this will represent
     * the entire inventory, but in some cases it may exclude armor or result
     * slots.
     * <br>
     * It is these contents which will be used for add / contains / remove
     * methods which look for a specific stack.
Comment by Thomas C-vS [ 17/Dec/16 ]

Thanks for mentioning that. So I guess this should be changed to an improvement of the documentation.

Comment by Black Hole [ 17/Dec/16 ]

I would say "works as documented". Have a look at Inventory.getStorageContents().
But the documentation for the the add / contains / remove methods could be improved.

Comment by Thomas C-vS [ 17/Dec/16 ]

Woops, title of issue should say "Remove Item From Offhand Slot"

Generated at Tue Apr 15 09:41:43 UTC 2025 using Jira 10.3.3#10030003-sha1:d220e3fefc8dfc6d47f522d3b9a20c1455e12b7b.