-
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.
Card Frames: Document and minor improvements
This documents the card_frames sub folder. Furthermore, temporary storages are renamed to follow the new scheme (Work towards #5) and the tag bingo.unmark has the inverse functionality and is now called bingo.toggle_on.
- Loading branch information
1 parent
2d6d90a
commit 5976d66
Showing
3 changed files
with
81 additions
and
18 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -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 | ||
#> | ||
# 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 |
30 changes: 21 additions & 9 deletions
30
data/bingo/functions/card_frames/on_item_removed.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 |
---|---|---|
@@ -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 | ||
tag @s remove bingo.toggle_on |
22 changes: 17 additions & 5 deletions
22
data/bingo/functions/card_frames/on_rotation_changed.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 |
---|---|---|
@@ -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 | ||
tag @s remove bingo.toggle_on |