diff --git a/data/bingo/functions/card_frames/find_item.mcfunction b/data/bingo/functions/card_frames/find_item.mcfunction index 67be78b3..52e73cd4 100644 --- a/data/bingo/functions/card_frames/find_item.mcfunction +++ b/data/bingo/functions/card_frames/find_item.mcfunction @@ -1,5 +1,44 @@ -execute if score $i bingo.tmp matches 0 run data modify storage bingo:tmp item set from storage bingo:tmp slots[0].item.item +#> bingo:card_frames/find_item +# +# This function finds the item in the given slot and returns it as found item in +# temp:bingo.output/card_item +# +# @internal +# @input +# score $card_frames/find_item.slot_id bingo.tmp The slot index of which the +# item should be returned. +# storage temp:bingo.input/card_item slots The slots of the current card +# @output storage temp:bingo.output/card_item found_item -data remove storage bingo:tmp slots[0] -scoreboard players remove $i bingo.tmp 1 -execute if score $i bingo.tmp matches 0.. run function bingo:card_frames/find_item \ No newline at end of file +#> +# Input score for bingo:card_frames/find_item. +# May only be read by that function. +# +# This is the index of the slot of which the item should be returned +# +# @internal +#declare score_holder $card_frames/find_item.slot_id + +#> +# Input storage for bingo:card_frames/find_item. +# May only be read by that function. +# +# This should hold the slots of the current card in the slots field +# +# @internal +#declare storage temp:bingo.input/card_item + +#> +# Output storage for bingo:card_frames/find_item +# May only be written to by that function +# +# This holds the item that was found in the given slot in found_item +# +# @internal +#declare storage temp:bingo.output/card_item + +execute if score $card_frames/find_item.slot_id bingo.tmp matches 0 run data modify storage temp:bingo.output/card_item found_item set from storage temp:bingo.input/card_item slots[0].item.item + +data remove storage temp:bingo.input/card_item slots[0] +scoreboard players remove $card_frames/find_item.slot_id bingo.tmp 1 +execute if score $card_frames/find_item.slot_id bingo.tmp matches 0.. run function bingo:card_frames/find_item \ No newline at end of file diff --git a/data/bingo/functions/card_frames/on_item_removed.mcfunction b/data/bingo/functions/card_frames/on_item_removed.mcfunction index a0abc204..7e45448a 100644 --- a/data/bingo/functions/card_frames/on_item_removed.mcfunction +++ b/data/bingo/functions/card_frames/on_item_removed.mcfunction @@ -1,17 +1,29 @@ +#> bingo:card_frames/on_item_removed +# +# This function is called by the lobby loop whenever an item was removed from a +# card frame in the lobby. +# +# It toggles the red marker block behind the item frame. +# +# @within function bingo:lobby/tick +# @context entity The item frame that had its item removed #> +# This tag indicates whether the item frame in question should toggle on (set +# red concrete behind) or toggle off (set barrier behind). +# # @private -#declare tag bingo.unmark +#declare tag bingo.toggle_on -data modify storage bingo:tmp slots set from storage bingo:card slots -scoreboard players operation $i bingo.tmp = @s bingo.frame_id +data modify storage temp:bingo.input/card_item slots set from storage bingo:card slots +scoreboard players operation $card_frames/find_item.slot_id bingo.tmp = @s bingo.frame_id function bingo:card_frames/find_item -data modify storage bingo:tmp item.Count set value 1b -data modify entity @s Item set from storage bingo:tmp item +data modify storage temp:bingo.output/card_item found_item.Count set value 1b +data modify entity @s Item set from storage temp:bingo.output/card_item found_item -execute if block ~ ~ ~-1 minecraft:red_concrete run tag @s add bingo.unmark -execute if entity @s[tag=bingo.unmark] run setblock ~ ~ ~-1 minecraft:barrier -execute unless entity @s[tag=bingo.unmark] run setblock ~ ~ ~-1 minecraft:red_concrete +execute unless block ~ ~ ~-1 minecraft:red_concrete run tag @s add bingo.toggle_on +execute unless entity @s[tag=bingo.toggle_on] run setblock ~ ~ ~-1 minecraft:barrier +execute if entity @s[tag=bingo.toggle_on] run setblock ~ ~ ~-1 minecraft:red_concrete -tag @s remove bingo.unmark \ No newline at end of file +tag @s remove bingo.toggle_on \ No newline at end of file diff --git a/data/bingo/functions/card_frames/on_rotation_changed.mcfunction b/data/bingo/functions/card_frames/on_rotation_changed.mcfunction index 14237716..b74dea0c 100644 --- a/data/bingo/functions/card_frames/on_rotation_changed.mcfunction +++ b/data/bingo/functions/card_frames/on_rotation_changed.mcfunction @@ -1,12 +1,24 @@ +#> bingo:card_frames/on_rotation_changed +# +# This function is called by the lobby loop whenever an item was removed from a +# card frame in the lobby. +# +# It toggles the hreen marker block behind the item frame. +# +# @within function bingo:lobby/tick +# @context entity The item frame that had its item removed #> +# This tag indicates whether the item frame in question should toggle on (set +# green concrete behind) or toggle off (set barrier behind). +# # @private -#declare tag bingo.unmark +#declare tag bingo.toggle_on data modify entity @s ItemRotation set value 0b -execute if block ~ ~ ~-1 minecraft:green_concrete run tag @s add bingo.unmark -execute if entity @s[tag=bingo.unmark] run setblock ~ ~ ~-1 minecraft:barrier -execute unless entity @s[tag=bingo.unmark] run setblock ~ ~ ~-1 minecraft:green_concrete +execute unless block ~ ~ ~-1 minecraft:green_concrete run tag @s add bingo.toggle_on +execute unless entity @s[tag=bingo.toggle_on] run setblock ~ ~ ~-1 minecraft:barrier +execute if entity @s[tag=bingo.toggle_on] run setblock ~ ~ ~-1 minecraft:green_concrete -tag @s remove bingo.unmark \ No newline at end of file +tag @s remove bingo.toggle_on \ No newline at end of file