oddlama / vane

Immersive and lore friendly enhancements for vanilla Minecraft
MIT License
250 stars 31 forks source link

Bug: Shulker boxes get stuck inside pouches and backpacks #240

Open ryantheleach opened 4 months ago

ryantheleach commented 4 months ago

If you manage to get a backpack, pouch, or shulkerbox inside a pouch or backpack, it's impossible to get it out.

Rather than prevent you from taking illegal items out, you should only prevent illegal items entering the pouch / backpack.

Also, it's possible to put a shulkerbox or chest inside a pouch or backpack, using the 'right click on inventory stack' method of putting items into pouches and backpacks, but NOT pouches or backpacks.

The logic in the Storage Group is a little all over the place too, the checks should probably call a method that centralizes the logic to prevent stuff like this happening in the future.

public void on_place_item_in_storage_inventory(InventoryClickEvent event) {
<snip>

// Allow putting in any items that are not a storage item, or storage items that have nothing in them.
            if (!(is_storage_item(event.getCursor()) && event.getCursor().hasItemMeta())) {

So the fact that custom items have item meta is what's filtering it out, which isn't really what we want to be checking for.

public void on_inventory_click(InventoryClickEvent event) {
<snip>
if (is_storage_item(event.getCurrentItem()) || (is_storage_item(event.getCursor()) && event.getCursor().hasItemMeta())) {

This is incorrectly filtering ALL storage items somehow, maybe it's because of getCurrentItem vs getCursor? not sure what the original intention was supposed to be here.

public void on_inventory_drag(InventoryDragEvent event) {
<snip>
for (final var item_stack : event.getNewItems().values()) {
            if (is_storage_item(item_stack)) {

drag is only checking if anything is a storage item, then cancelling.