[SPIGOT-7389] Can't set ChiseledBookshelf Inventory slot to null Created: 12/Jun/23 Updated: 25/Dec/24 Resolved: 16/Jun/23 |
|
| Status: | Resolved |
| Project: | Spigot |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor |
| Reporter: | Rothes | Assignee: | Doc |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Version: | 1.20 |
| Guidelines Read: | Yes |
| Description |
|
((InventoryHolder) block.getState()).getInventory().setItem(i, null) Doesn't work. The item is not removed. |
| Comments |
| Comment by Doc [ 12/Jun/23 ] |
|
Ok i use this with a PR https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/pull-requests/1210/overview and can set null items in that slots. @EventHandler private void onInteract(PlayerInteractEvent event) { Block block = event.getClickedBlock(); ItemStack itemStackMain = event.getPlayer().getEquipment().getItemInMainHand(); if (event.getAction().equals(Action.RIGHT_CLICK_BLOCK) && itemStackMain.getType() == Material.STICK && block != null && block.getType() == Material.CHISELED_BOOKSHELF) { ItemStack itemStackSecond = event.getPlayer().getEquipment().getItemInOffHand(); Inventory inventory = ((InventoryHolder) block.getState()).getInventory(); Bukkit.broadcastMessage("Original Item " + inventory.getItem(0)); Bukkit.broadcastMessage("Set Item " + itemStackSecond); ((InventoryHolder) block.getState()).getInventory().setItem(0, itemStackSecond); Bukkit.broadcastMessage("Seted Item " + inventory.getItem(0)); } } |
| Comment by Doc [ 12/Jun/23 ] |
|
Okay can you try using removeItem? if that works please can you provide a example plugin for this, i check in NMS and the setItem for that inventory is think only for put things.. for remove not. |
| Comment by Rothes [ 12/Jun/23 ] |
|
Yes I tried. AIR also doesn't remove the item. |
| Comment by Doc [ 12/Jun/23 ] |
|
you try passing a Item with AIR? |