-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This refactors command queue to be easier to understand and removes some unnecessary functions. Everything in there is now also documented (Work towards #5) and names are changed to follow #4.
- Loading branch information
1 parent
d8a364e
commit 784d20c
Showing
25 changed files
with
179 additions
and
63 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
...ions/command_queue/claculate_next_position_and_set_command_block/check_z_limit.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#> bingo:command_queue/claculate_next_position_and_set_command_block/check_z_limit | ||
# | ||
# This function checks z limits and moves to the next z or y position, depending | ||
# on the result | ||
# | ||
# @within function bingo:command_queue/claculate_next_position_and_set_command_block/run | ||
|
||
execute if score $command_queue/next_pos.mody bingo.tmp matches 0 if score $command_queue.z bingo.tmp matches 15 run function bingo:command_queue/claculate_next_position_and_set_command_block/next_positive_y | ||
execute if score $command_queue/next_pos.mody bingo.tmp matches 1 if score $command_queue.z bingo.tmp matches 0 run function bingo:command_queue/claculate_next_position_and_set_command_block/next_positive_y | ||
execute if score $command_queue/next_pos.mody bingo.tmp matches 0 unless score $command_queue.z bingo.tmp matches 15 run function bingo:command_queue/claculate_next_position_and_set_command_block/next_positive_z | ||
execute if score $command_queue/next_pos.mody bingo.tmp matches 1 unless score $command_queue.z bingo.tmp matches 0 run function bingo:command_queue/claculate_next_position_and_set_command_block/next_negative_z |
8 changes: 8 additions & 0 deletions
8
...ns/command_queue/claculate_next_position_and_set_command_block/next_negative_x.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#> bingo:command_queue/claculate_next_position_and_set_command_block/next_negative_x | ||
# | ||
# This function sets a command block facing west and moves to the negative x | ||
# | ||
# @within function bingo:command_queue/claculate_next_position_and_set_command_block/run | ||
|
||
setblock ~ ~ ~ minecraft:chain_command_block[facing=west]{auto: true} | ||
scoreboard players remove $command_queue.x bingo.tmp 1 |
8 changes: 8 additions & 0 deletions
8
...ns/command_queue/claculate_next_position_and_set_command_block/next_negative_z.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#> bingo:command_queue/claculate_next_position_and_set_command_block/next_negative_z | ||
# | ||
# This function sets a command block facing west and moves to the negative z | ||
# | ||
# @within function bingo:command_queue/claculate_next_position_and_set_command_block/check_z_limit | ||
|
||
setblock ~ ~ ~ minecraft:chain_command_block[facing=north]{auto: true} | ||
scoreboard players remove $command_queue.z bingo.tmp 1 |
8 changes: 8 additions & 0 deletions
8
...ns/command_queue/claculate_next_position_and_set_command_block/next_positive_x.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#> bingo:command_queue/claculate_next_position_and_set_command_block/next_positive_x | ||
# | ||
# This function sets a command block facing east and moves to the positive x | ||
# | ||
# @within function bingo:command_queue/claculate_next_position_and_set_command_block/run | ||
|
||
setblock ~ ~ ~ minecraft:chain_command_block[facing=east]{auto: true} | ||
scoreboard players add $command_queue.x bingo.tmp 1 |
8 changes: 8 additions & 0 deletions
8
...ns/command_queue/claculate_next_position_and_set_command_block/next_positive_y.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#> bingo:command_queue/claculate_next_position_and_set_command_block/next_positive_y | ||
# | ||
# This function sets a command block facing up and moves to the positive y | ||
# | ||
# @within function bingo:command_queue/claculate_next_position_and_set_command_block/check_z_limit | ||
|
||
setblock ~ ~ ~ minecraft:chain_command_block[facing=up]{auto: true} | ||
scoreboard players add $command_queue.y bingo.tmp 1 |
8 changes: 8 additions & 0 deletions
8
...ns/command_queue/claculate_next_position_and_set_command_block/next_positive_z.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#> bingo:command_queue/claculate_next_position_and_set_command_block/next_positive_z | ||
# | ||
# This function sets a command block facing south and moves to the positive z | ||
# | ||
# @within function bingo:command_queue/claculate_next_position_and_set_command_block/check_z_limit | ||
|
||
setblock ~ ~ ~ minecraft:chain_command_block[facing=south]{auto: true} | ||
scoreboard players add $command_queue.z bingo.tmp 1 |
39 changes: 39 additions & 0 deletions
39
...ingo/functions/command_queue/claculate_next_position_and_set_command_block/run.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#> bingo:command_queue/claculate_next_position_and_set_command_block/run | ||
# | ||
# This function calculates the position for the next command block and stores it | ||
# in $command_queue.x/y/z. | ||
# | ||
# The position of the marker aec is also changed in here. | ||
# | ||
# @within function bingo:command_queue/iter | ||
# @writes | ||
# score_holder $command_queue.x | ||
# score_holder $command_queue.y | ||
# score_holder $command_queue.z | ||
|
||
#> | ||
# Contains the result of z % 2 | ||
# | ||
# @within bingo:command_queue/claculate_next_position_and_set_command_block/** | ||
#declare score_holder $command_queue/next_pos.modz | ||
#> | ||
# Contains the result of y % 2 | ||
# | ||
# @within bingo:command_queue/claculate_next_position_and_set_command_block/** | ||
#declare score_holder $command_queue/next_pos.mody | ||
|
||
scoreboard players operation $command_queue/next_pos.modz bingo.tmp = $command_queue.z bingo.tmp | ||
scoreboard players operation $command_queue/next_pos.modz bingo.tmp %= 2 bingo.const | ||
scoreboard players operation $command_queue/next_pos.mody bingo.tmp = $command_queue.y bingo.tmp | ||
scoreboard players operation $command_queue/next_pos.mody bingo.tmp %= 2 bingo.const | ||
|
||
# Check for hitting the limit on the x axis. If (z % 2) == (y % 2), we move towards positive x, otherwise towards negative x. | ||
execute if score $command_queue/next_pos.modz bingo.tmp = $command_queue/next_pos.mody bingo.tmp if score $command_queue.x bingo.tmp matches 15 run function bingo:command_queue/claculate_next_position_and_set_command_block/check_z_limit | ||
execute unless score $command_queue/next_pos.modz bingo.tmp = $command_queue/next_pos.mody bingo.tmp if score $command_queue.x bingo.tmp matches 0 run function bingo:command_queue/claculate_next_position_and_set_command_block/check_z_limit | ||
|
||
execute if score $command_queue/next_pos.modz bingo.tmp = $command_queue/next_pos.mody bingo.tmp unless score $command_queue.x bingo.tmp matches 15 run function bingo:command_queue/claculate_next_position_and_set_command_block/next_positive_x | ||
execute unless score $command_queue/next_pos.modz bingo.tmp = $command_queue/next_pos.mody bingo.tmp unless score $command_queue.x bingo.tmp matches 0 run function bingo:command_queue/claculate_next_position_and_set_command_block/next_negative_x | ||
|
||
execute store result entity @s Pos[0] double 1 run scoreboard players get $command_queue.x bingo.tmp | ||
execute store result entity @s Pos[1] double 1 run scoreboard players get $command_queue.y bingo.tmp | ||
execute store result entity @s Pos[2] double 1 run scoreboard players get $command_queue.z bingo.tmp |
23 changes: 23 additions & 0 deletions
23
data/bingo/functions/command_queue/init_for_new_tick.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#> bingo:command_queue/init_for_new_tick | ||
# | ||
# This function initializes some values and entities needed for a run. | ||
# It will only be executed once per tick. | ||
# | ||
# The area effect cloud spawned can be used as an indicator whether this | ||
# function was already run in the current tick. | ||
# | ||
# The area effect cloud can be identified by the tag "bingp.command". | ||
# | ||
# @within function bingo:command_queue/run | ||
|
||
#> | ||
# This tag identifies the area effect cloud used to set the command blocks. | ||
# | ||
# @within function bingo:command_queue/** | ||
#declare tag bingo.command | ||
|
||
summon minecraft:area_effect_cloud 1 0 0 {Tags: ["bingo.command"]} | ||
data merge block 0 0 0 {auto: true} | ||
scoreboard players set $command_queue.x bingo.tmp 1 | ||
scoreboard players set $command_queue.y bingo.tmp 0 | ||
scoreboard players set $command_queue.z bingo.tmp 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#> bingo:command_queue/iter | ||
# | ||
# One iteration of the command queue. Places one command and is executed again | ||
# automatically until there are no more commands in the given command queue. | ||
# | ||
# @within | ||
# function bingo:command_queue/iter | ||
# function bingo:command_queue/run | ||
|
||
#> | ||
# Score holder to store the size of the current command queue. | ||
# | ||
# @private | ||
#declare score_holder $command_queue/iter.size | ||
|
||
execute store result score $command_queue/iter.size bingo.tmp run data get storage temp:bingo.input/command_queue queue | ||
execute if score $command_queue/iter.size bingo.tmp matches 2.. run function bingo:command_queue/claculate_next_position_and_set_command_block/run | ||
execute if score $command_queue/iter.size bingo.tmp matches 1 run setblock ~ ~ ~ minecraft:chain_command_block[facing=down]{auto: true} | ||
|
||
data modify block ~ ~ ~ Command set from storage temp:bingo.input/command_queue queue[0] | ||
data remove storage temp:bingo.input/command_queue queue[0] | ||
|
||
execute if score $command_queue/iter.size bingo.tmp matches 2.. at @s run function bingo:command_queue/iter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#> bingo:command_queue/run | ||
# | ||
# This function runs the command queue. | ||
# The command queue can execute a list of provided commands in the next tick. | ||
# | ||
# @internal | ||
# @input storage temp:bingo.input/command_queue queue | ||
|
||
#> | ||
# This storage is used as input by the command queue. | ||
# It may only be read by related functions. | ||
# | ||
# It holds a list of commands to execute in the next tick. The field queue | ||
# is used for that. | ||
# | ||
# @internal | ||
#declare storage temp:bingo.input/command_queue | ||
|
||
#> | ||
# This score holder holds the current x coordinate | ||
# | ||
# @within function bingo:command_queue/** | ||
#declare score_holder $command_queue.x | ||
#> | ||
# This score holder holds the current y coordinate | ||
# | ||
# @within function bingo:command_queue/** | ||
#declare score_holder $command_queue.y | ||
#> | ||
# This score holder holds the current z coordinate | ||
# | ||
# @within function bingo:command_queue/** | ||
#declare score_holder $command_queue.z | ||
|
||
execute at @e[type=minecraft:area_effect_cloud, tag=bingo.command, limit=1] run data modify storage temp:bingo.input/command_queue queue prepend from block ~ ~ ~ Command | ||
execute unless entity @e[type=minecraft:area_effect_cloud, tag=bingo.command, limit=1] in bingo:lobby run function bingo:command_queue/init_for_new_tick | ||
execute as @e[type=minecraft:area_effect_cloud, tag=bingo.command, limit=1] at @s run function bingo:command_queue/iter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 0 additions & 10 deletions
10
data/bingo/functions/run_command_from_string/check_limits.mcfunction
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
data/bingo/functions/run_command_from_string/check_z_limit.mcfunction
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
data/bingo/functions/run_command_from_string/init_new_run.mcfunction
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
data/bingo/functions/run_command_from_string/next_negative_x.mcfunction
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
data/bingo/functions/run_command_from_string/next_negative_z.mcfunction
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
data/bingo/functions/run_command_from_string/next_positive_x.mcfunction
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
data/bingo/functions/run_command_from_string/next_positive_z.mcfunction
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
data/bingo/functions/run_command_from_string/next_x.mcfunction
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
data/bingo/functions/run_command_from_string/next_y.mcfunction
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
data/bingo/functions/run_command_from_string/next_z.mcfunction
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
data/bingo/functions/run_command_from_string/set_command_block.mcfunction
This file was deleted.
Oops, something went wrong.