execute if [something to check] run function mypack:myfunction
I only recently learned how to write a data pack, but essentially it uses only in-game commands (console / command block usable), but runs them like a script instead of a true function as programming languages would have. You can do more complex tasks and run large numbers of commands quickly. The data pack code is parsed and cached so it can be executed more efficiently, too.
Variables are tricky. You either can set a tag on an entity or use scoreboards. I re-worked Magic Sorting System data pack (https://github.com/isaaclepes/Scientific-Sorting-System), look at the load, init, and tick functions. The tick function adds 1 to a scoreboard value every 1/20th of a second. When that scoreboard value matches N it will execute a function. After it reaches 100, the score is reset to 1 and continues counting up. This allows you to time the execution of your main loops.
I apologize, I didn't realize this was 2019... ignore my necropost
WorldEdit schematic now available in GitHub as well. This schematic fits into a chunk and can be tiled. Each tile contains 16 storage units, 8 per side.
Please test it out and report any issues. Also, if you notice that a survival obtainable item is missing, let me know.
A data pack that executes this every couple of seconds would do it.
execute as @e[type=item,nbt={Item:{id:"minecraft:acacia_sapling"}}] at @s run setblock ~ ~ ~ minecraft:acacia_sapling
execute as @e[type=item,nbt={Item:{id:"minecraft:birch_sapling"}}] at @s run setblock ~ ~ ~ minecraft:birch_sapling
execute as @e[type=item,nbt={Item:{id:"minecraft:dark_oak_sapling"}}] at @s run setblock ~ ~ ~ minecraft:dark_oak_sapling
execute as @e[type=item,nbt={Item:{id:"minecraft:jungle_sapling"}}] at @s run setblock ~ ~ ~ minecraft:jungle_sapling
execute as @e[type=item,nbt={Item:{id:"minecraft:oak_sapling"}}] at @s run setblock ~ ~ ~ minecraft:oak_sapling
execute as @e[type=item,nbt={Item:{id:"minecraft:spruce_sapling"}}] at @s run setblock ~ ~ ~ minecraft:spruce_sapling
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.
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 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.
0
I have a small server that I created for friends and family, but we decided to expand and open it up to more players. Feedback is appreciated!
Address: amethystea.lucidious.net
Server: Paper MC 1.16
Required Client Mods: None
Offline Mode: No
Server Plugins:
Autorank
BanFromClaim
CratesPlus
DynamicShop
Dynmap (w/GriefPrevention addon)
EssentialsX / Chat / GeoIP
Grief Prevention (GPFlags, GPUtilities)
HolographicDisplays
LuckPerms
mcMMO
RealEstate
ServerTutorialPlus
ShopChest
Statz
Stress
Vault
WanderingTrades
WorldEdit / AWE
0
calling a function
execute run function mypack:myfucntion
execute if [something to check] run function mypack:myfunction
I only recently learned how to write a data pack, but essentially it uses only in-game commands (console / command block usable), but runs them like a script instead of a true function as programming languages would have. You can do more complex tasks and run large numbers of commands quickly. The data pack code is parsed and cached so it can be executed more efficiently, too.
Variables are tricky. You either can set a tag on an entity or use scoreboards. I re-worked Magic Sorting System data pack (https://github.com/isaaclepes/Scientific-Sorting-System), look at the load, init, and tick functions. The tick function adds 1 to a scoreboard value every 1/20th of a second. When that scoreboard value matches N it will execute a function. After it reaches 100, the score is reset to 1 and continues counting up. This allows you to time the execution of your main loops.
I apologize, I didn't realize this was 2019... ignore my necropost
0
Found this:
The GUI for jigsaw blocks contains the following input fields:
On: https://minecraft.gamepedia.com/Jigsaw_Block
Looks like you need to create structures and load them up with a datapack
Google "minecraft custom structures data pack"
0
Where does beef_delay 2 become beef_delay 1? It looks like you set the tag to 2 but then look for it set to 1.
0
I created a fork of Magic Sorting System to add additional functionality and make it sort 1 to 1 instead of using groups.
https://github.com/isaaclepes/Scientific-Sorting-System
WorldEdit schematic now available in GitHub as well. This schematic fits into a chunk and can be tiled. Each tile contains 16 storage units, 8 per side.
Please test it out and report any issues. Also, if you notice that a survival obtainable item is missing, let me know.
Demonstration:
Code Comparison to Magic Sorting System:
https://github.com/jhuckaby/magic-sorting-system/compare/master...isaaclepes:main
Edit Reason: Add information about schematic file.
0
This would, as @p, teleport them from where they are +0.5 x y & z
/execute as @p at @s run tp ~0.5 ~0.5 ~0.5
Execute as players
at position of self
run teleport
You can also check a location using the y,y,z,dx,dy,dz functions but I don't know if you can do so generically
See these for examples:
https://www.minecraftforum.net/forums/minecraft-java-edition/redstone-discussion-and/commands-command-blocks-and/2929196-using-dx-dy-dz-in-player-detection
https://www.reddit.com/r/Minecraft/comments/43cmfx/help_testfor_players_in_a_rectangular_area/
0
A data pack that executes this every couple of seconds would do it.
execute as @e[type=item,nbt={Item:{id:"minecraft:acacia_sapling"}}] at @s run setblock ~ ~ ~ minecraft:acacia_sapling
execute as @e[type=item,nbt={Item:{id:"minecraft:birch_sapling"}}] at @s run setblock ~ ~ ~ minecraft:birch_sapling
execute as @e[type=item,nbt={Item:{id:"minecraft:dark_oak_sapling"}}] at @s run setblock ~ ~ ~ minecraft:dark_oak_sapling
execute as @e[type=item,nbt={Item:{id:"minecraft:jungle_sapling"}}] at @s run setblock ~ ~ ~ minecraft:jungle_sapling
execute as @e[type=item,nbt={Item:{id:"minecraft:oak_sapling"}}] at @s run setblock ~ ~ ~ minecraft:oak_sapling
execute as @e[type=item,nbt={Item:{id:"minecraft:spruce_sapling"}}] at @s run setblock ~ ~ ~ minecraft:spruce_sapling
0
Video demonstration
0
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.
0
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.
0
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.
0
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