I have been developing a giant sorting machine that can sort every survival-mode item in the game. Instead of a traditional redstone contraption, I have opted to build this using command blocks to reduce the size and light updates. The items are sorted into shulker boxes, and once full, the shulker is broken and falls into a hopper/chest below.
All of this works fine, but the commands cause considerable TPS lag. After reading into this, I believe I can achieve better performance using datapacks, but I have no idea how to make this work. The worst of the lag is from the shulker system which uses several command blocks to check the NBT data of the boxes.
Replace shulker boxes after piston pushes them
execute if block ~ ~5 ~-2 air run setblock ~ ~5 ~-2 minecraft:brown_shulker_box[facing=down]{CustomName:"\"Warehouse Crate\""}
These both can light a lamp using a comparator, if the lamp is lit the piston fires.
execute if block ~ ~5 ~-1 #minecraft:shulker_boxes{Items:[{Slot:26b,Count:1b}]} unless block ~ ~5 ~-1 #minecraft:shulker_boxes{Items:[{Slot:25b,Count:64b}]}
execute if block ~ ~5 ~3 #minecraft:shulker_boxes{Items:[{Slot:26b,Count:64b}]} if block ~ ~5 ~3 #minecraft:shulker_boxes{Items:[{Slot:25b,Count:64b}]}
What I need is to create a function that runs every 5 seconds to check if the box is full and trigger the piston when it is. The issue is that I can't think of how to make this function able to work with 800+ block inventory checks.
If anyone has any suggestions, even a complete re-work, please let me know. I would very much like to avoid using redstone components as much as possible to reduce the size of the sorting system. It is already quite massive.
Lastly, I would love to have some method to reduce the executions per second of the sorter command blocks. 20/sec is probably overkill, but I need them to be in-sync with the hoppers so as not to check them too often but not miss any items.
Here is a video of the item sorter. I don't have a microphone or anything so I just looked around slowly.
I found a method to break the boxes, but the direction is unpredictable.. I need to find a way to engage a piston instead so I can control the direction the box breaks
In-world A=Air, S= Shulker box, C=Comparator, B=solid block, F=Item Frame with tag sss_shulker_target
[S] [C]
[A] [B] [F]
sss:fullchecker.mcfunction
execute as @e[type=item_frame,tag=sss_shulker_target] at @s if block ~1 ~1 ~ minecraft:comparator{OutputSignal:15} run function sss:boxbreaker
execute as @e[type=item_frame,tag=sss_shulker_target] at @s if block ~-1 ~1 ~ minecraft:comparator{OutputSignal:15} run function sss:boxbreaker
execute as @e[type=item_frame,tag=sss_shulker_target] at @s if block ~ ~1 ~1 minecraft:comparator{OutputSignal:15} run function sss:boxbreaker
execute as @e[type=item_frame,tag=sss_shulker_target] at @s if block ~ ~1 ~-1 minecraft:comparator{OutputSignal:15} run function sss:boxbreaker
sss:boxbreaker.mcfunction
execute as @s if block ~2 ~1 ~ #minecraft:shulker_boxes run setblock ~2 ~1 ~ air destroy
execute as @s if block ~-2 ~1 ~ #minecraft:shulker_boxes run setblock ~-2 ~1 ~ air destroy
execute as @s if block ~ ~1 ~2 #minecraft:shulker_boxes run setblock ~ ~1 ~2 air destroy
execute as @s if block ~ ~1 ~-2 #minecraft:shulker_boxes run setblock ~ ~1 ~-2 air destroy
At this point, I am finding my own advice. Hopefully this is useful to someone else.
I will try to get a video up showing how to setup the system.
Once completed, I will also make a schematic of my own design and post it.
Rather than using setblock x y z air destroy, I placed pistons and repeaters. The datapack will place a redstone block next to the repeater if the shulker is full and remove it a couple seconds later. If the spot where a shulkerbox should be contains air, a setblock command fires to replace the box.
This does have the added effect of infinite shulker boxes. I might find a method where the datapack automatically removes any "Warehouse Crate" shulker boxes the moment they are empty, but I need to figure out the logic for that.
Hello,
I have been developing a giant sorting machine that can sort every survival-mode item in the game. Instead of a traditional redstone contraption, I have opted to build this using command blocks to reduce the size and light updates. The items are sorted into shulker boxes, and once full, the shulker is broken and falls into a hopper/chest below.
All of this works fine, but the commands cause considerable TPS lag. After reading into this, I believe I can achieve better performance using datapacks, but I have no idea how to make this work. The worst of the lag is from the shulker system which uses several command blocks to check the NBT data of the boxes.
Replace shulker boxes after piston pushes them
execute if block ~ ~5 ~-2 air run setblock ~ ~5 ~-2 minecraft:brown_shulker_box[facing=down]{CustomName:"\"Warehouse Crate\""}
These both can light a lamp using a comparator, if the lamp is lit the piston fires.
execute if block ~ ~5 ~-1 #minecraft:shulker_boxes{Items:[{Slot:26b,Count:1b}]} unless block ~ ~5 ~-1 #minecraft:shulker_boxes{Items:[{Slot:25b,Count:64b}]}
execute if block ~ ~5 ~3 #minecraft:shulker_boxes{Items:[{Slot:26b,Count:64b}]} if block ~ ~5 ~3 #minecraft:shulker_boxes{Items:[{Slot:25b,Count:64b}]}
What I need is to create a function that runs every 5 seconds to check if the box is full and trigger the piston when it is. The issue is that I can't think of how to make this function able to work with 800+ block inventory checks.
If anyone has any suggestions, even a complete re-work, please let me know. I would very much like to avoid using redstone components as much as possible to reduce the size of the sorting system. It is already quite massive.
Lastly, I would love to have some method to reduce the executions per second of the sorter command blocks. 20/sec is probably overkill, but I need them to be in-sync with the hoppers so as not to check them too often but not miss any items.
Here is a video of the item sorter. I don't have a microphone or anything so I just looked around slowly.
(Upload has 15 min remaining)
Using 1.16.3
I found this Magic Item Sorter data pack. It is not exactly what I want, but I already see how to setup good timers by looking at their tick function.
https://github.com/jhuckaby/magic-sorting-system/blob/master/data/main/functions/tick.mcfunction
I want 1:1 item sorting, not categorical, but it sure is a good source of inspiration.
I found a method to break the boxes, but the direction is unpredictable.. I need to find a way to engage a piston instead so I can control the direction the box breaks
In-world A=Air, S= Shulker box, C=Comparator, B=solid block, F=Item Frame with tag sss_shulker_target
[S] [C]
[A] [B] [F]
sss:fullchecker.mcfunction
execute as @e[type=item_frame,tag=sss_shulker_target] at @s if block ~1 ~1 ~ minecraft:comparator{OutputSignal:15} run function sss:boxbreaker
execute as @e[type=item_frame,tag=sss_shulker_target] at @s if block ~-1 ~1 ~ minecraft:comparator{OutputSignal:15} run function sss:boxbreaker
execute as @e[type=item_frame,tag=sss_shulker_target] at @s if block ~ ~1 ~1 minecraft:comparator{OutputSignal:15} run function sss:boxbreaker
execute as @e[type=item_frame,tag=sss_shulker_target] at @s if block ~ ~1 ~-1 minecraft:comparator{OutputSignal:15} run function sss:boxbreaker
sss:boxbreaker.mcfunction
execute as @s if block ~2 ~1 ~ #minecraft:shulker_boxes run setblock ~2 ~1 ~ air destroy
execute as @s if block ~-2 ~1 ~ #minecraft:shulker_boxes run setblock ~-2 ~1 ~ air destroy
execute as @s if block ~ ~1 ~2 #minecraft:shulker_boxes run setblock ~ ~1 ~2 air destroy
execute as @s if block ~ ~1 ~-2 #minecraft:shulker_boxes run setblock ~ ~1 ~-2 air destroy
At this point, I am finding my own advice. Hopefully this is useful to someone else.
I have published my fork of Magic Sorting System on Github
https://github.com/isaaclepes/Scientific-Sorting-System
I will try to get a video up showing how to setup the system.
Once completed, I will also make a schematic of my own design and post it.
Rather than using setblock x y z air destroy, I placed pistons and repeaters. The datapack will place a redstone block next to the repeater if the shulker is full and remove it a couple seconds later. If the spot where a shulkerbox should be contains air, a setblock command fires to replace the box.
This does have the added effect of infinite shulker boxes. I might find a method where the datapack automatically removes any "Warehouse Crate" shulker boxes the moment they are empty, but I need to figure out the logic for that.
Video demonstration