jhuckaby / magic-sorting-system

A data pack for Minecraft 1.13, 1.14 and 1.15 (Java) for automatically sorting every item in the game.
39 stars 15 forks source link

not so much of an issue, more a request #11

Open pesegolsson opened 5 years ago

pesegolsson commented 5 years ago

could you add code to the sorter so that it sorts out shulker boxes with item in them into its own category?

that would make things so much easier as they gets stoes in seperate chests.

jhuckaby commented 4 years ago

I'll look into this, but I'm afraid this is too complex a task for me. I have no idea how to look inside shulkers using datapack commands. We need to get Seth Bling to code this up for us 😉

isaaclepes commented 3 years ago

Would this help?

if Trapped Chest has Shulker Box that has items /execute if block -126 62 -168 minecraft:trapped_chest{Items:[{id:"minecraft:shulker_box",tag:{BlockEntityTag:{Items:[{}]}}}]}

if trapped chest has Shulker Box that is empty /execute if block -126 62 -168 minecraft:trapped_chest{Items:[{id:"minecraft:shulker_box",tag:{BlockEntityTag:{Items:[]}}}]}

if chest has Any item that contains an item /execute if block -126 62 -168 minecraft:trapped_chest{Items:[{tag:{BlockEntityTag:{Items:[{}]}}}]}

You can get specific by adding in the Slot: , id;, etc into the last Items:[{}] part

isaaclepes commented 3 years ago

I had time to play with it in-game

This command will teleport only items on the ground that contain a shulkerbox that has some item in it /tp @e[type=item,nbt={Item:{id:"minecraft:shulker_box",tag:{BlockEntityTag:{Items:[{}]}}}}] @s

Teleport item if it contains a box containing a chorus_fruit anywhere in it /tp @e[type=item,nbt={Item:{id:"minecraft:shulker_box",tag:{BlockEntityTag:{Items:[{id:"minecraft:chorus_fruit"}]}}}}] @s

It doesn't seem to work the same for detecting empty shulker boxes inside an item entity as it does with chests. Might just need to play with the syntax Not working: /tp @e[type=item,nbt={Item:{id:"minecraft:shulker_box",tag:{BlockEntityTag:{Items:[]}}}}] @s

Otherwise just run the check for non-empty boxes first, then check for any remaining ones after that.

I remember seeing a bug on Mojang for problems with nested NBT data, but I can't find it now. It does appear resolved, at least partially, since I am able to work with nested NBT on 1.16.3 as shown above.