diff --git a/data/armor_statues/functions/repeat/save_state.mcfunction b/data/armor_statues/functions/repeat/save_state.mcfunction index eecd35f..e27516b 100644 --- a/data/armor_statues/functions/repeat/save_state.mcfunction +++ b/data/armor_statues/functions/repeat/save_state.mcfunction @@ -5,10 +5,22 @@ # # Checks if UUID of armor stand matches that of the book # +#scoreboard players set #as_success as_angle 0 +#execute store success score #as_success as_angle run data modify storage customizable_armor_stands:book_storage SavedItem.tag.StatesUUID set from entity @e[type=armor_stand,sort=nearest,limit=1,tag=as_selected] UUID +#execute if score #as_success as_angle matches 1 run data remove storage customizable_armor_stands:book_storage SavedItem.tag.UndoStates +#data remove storage customizable_armor_stands:book_storage SavedItem.tag.RedoStates + +# checks if uuid matches armor stand scoreboard players set #as_success as_angle 0 -execute store success score #as_success as_angle run data modify storage customizable_armor_stands:book_storage SavedItem.tag.StatesUUID set from entity @e[type=armor_stand,sort=nearest,limit=1,tag=as_selected] UUID -execute if score #as_success as_angle matches 1 run data remove storage customizable_armor_stands:book_storage SavedItem.tag.UndoStates -data remove storage customizable_armor_stands:book_storage SavedItem.tag.RedoStates +data remove storage customizable_armor_stands:uuid_check UUID +data modify storage customizable_armor_stands:uuid_check UUID set from storage customizable_armor_stands:book_storage SavedItem.tag.StatesUUID +execute store result score #as_success as_angle \ + as @e[type=armor_stand,sort=nearest,limit=1,tag=as_selected] run \ + function armor_statues:uuid_check with storage customizable_armor_stands:uuid_check {} +# +execute if score #as_success as_angle matches 0 run data modify storage customizable_armor_stands:book_storage SavedItem.tag.UndoStates set value [] +execute if score #as_success as_angle matches 0 run data modify storage customizable_armor_stands:book_storage SavedItem.tag.StatesUUID set from entity @e[type=armor_stand,sort=nearest,limit=1,tag=as_selected] UUID +data modify storage customizable_armor_stands:book_storage SavedItem.tag.RedoStates set value [] # # Counts undo states and makes sure they're less than the maximum undo states # diff --git a/data/armor_statues/functions/repeat/undo_redo.mcfunction b/data/armor_statues/functions/repeat/undo_redo.mcfunction index 77040ca..cfa9762 100644 --- a/data/armor_statues/functions/repeat/undo_redo.mcfunction +++ b/data/armor_statues/functions/repeat/undo_redo.mcfunction @@ -7,19 +7,92 @@ execute as @s run function armor_statues:storage_in # # Checks if UUID of armor stand matches that of the book # + + +#execute store success score #as_success as_angle run data modify storage customizable_armor_stands:book_storage SavedItem.tag.StatesUUID set from entity @e[type=armor_stand,sort=nearest,limit=1,tag=as_selected] UUID + +# checks if uuid matches armor stand scoreboard players set #as_success as_angle 0 -execute store success score #as_success as_angle run data modify storage customizable_armor_stands:book_storage SavedItem.tag.StatesUUID set from entity @e[type=armor_stand,sort=nearest,limit=1,tag=as_selected] UUID -execute if score #as_success as_angle matches 1 run title @a[tag=as_selected,tag=!as_chat] actionbar [{"text":"Can't undo/redo state on current Armor Stand","color":"dark_green"}] -execute if score #as_success as_angle matches 1 run tellraw @a[tag=as_selected,tag=as_chat] [{"text":" ","color":"dark_green"}, {"text":"Can't undo/redo state on current Armor Stand","color":"dark_green"}] +data remove storage customizable_armor_stands:uuid_check UUID +data modify storage customizable_armor_stands:uuid_check UUID set from storage customizable_armor_stands:book_storage SavedItem.tag.StatesUUID +execute store result score #as_success as_angle \ + as @e[type=armor_stand,sort=nearest,limit=1,tag=as_selected] run \ + function armor_statues:uuid_check with storage customizable_armor_stands:uuid_check {} +# +execute if score #as_success as_angle matches 0 run \ + title @a[tag=as_selected,tag=!as_chat] actionbar \ + [\ + {\ + "text":"Can't undo/redo state on current Armor Stand",\ + "color":"dark_green"\ + }\ + ] +execute if score #as_success as_angle matches 0 run \ + tellraw @a[tag=as_selected,tag=as_chat] \ + [\ + {\ + "text":" ",\ + "color":"dark_green"\ + }, \ + {\ + "text":"Can't undo/redo state on current Armor Stand",\ + "color":"dark_green"\ + }\ + ] +execute if score #as_success as_angle matches 0 run return 0 # # Undo # -execute as @s[scores={as_trigger=1200}] unless data storage customizable_armor_stands:book_storage SavedItem.tag.UndoStates[] if score #as_success as_angle matches 0 run title @a[tag=as_selected,tag=!as_chat] actionbar [{"text":"No states to undo","color":"dark_green"}] -execute as @s[scores={as_trigger=1200}] unless data storage customizable_armor_stands:book_storage SavedItem.tag.UndoStates[] if score #as_success as_angle matches 0 run tellraw @a[tag=as_selected,tag=as_chat] [{"text":" ","color":"dark_green"}, {"text":"No states to undo","color":"dark_green"}] -execute as @s[scores={as_trigger=1200}] if data storage customizable_armor_stands:book_storage SavedItem.tag.UndoStates[] if score #as_success as_angle matches 0 run function armor_statues:repeat/undo +execute as @s[scores={as_trigger=1200}] \ + unless data storage customizable_armor_stands:book_storage SavedItem.tag.UndoStates[] run \ + title @a[tag=as_selected,tag=!as_chat] actionbar \ + [\ + {\ + "text":"No states to undo",\ + "color":"dark_green"\ + }\ + ] +execute as @s[scores={as_trigger=1200}] \ + unless data storage customizable_armor_stands:book_storage SavedItem.tag.UndoStates[] run \ + tellraw @a[tag=as_selected,tag=as_chat] \ + [\ + {\ + "text":" ",\ + "color":"dark_green"\ + }, \ + {\ + "text":"No states to undo",\ + "color":"dark_green"\ + }\ + ] +execute as @s[scores={as_trigger=1200}] \ + if data storage customizable_armor_stands:book_storage SavedItem.tag.UndoStates[] run \ + function armor_statues:repeat/undo # # Redo # -execute as @s[scores={as_trigger=1201}] unless data storage customizable_armor_stands:book_storage SavedItem.tag.RedoStates[] if score #as_success as_angle matches 0 run title @a[tag=as_selected,tag=!as_chat] actionbar [{"text":"No states to redo","color":"dark_green"}] -execute as @s[scores={as_trigger=1201}] unless data storage customizable_armor_stands:book_storage SavedItem.tag.RedoStates[] if score #as_success as_angle matches 0 run tellraw @a[tag=as_selected,tag=as_chat] [{"text":" ","color":"dark_green"}, {"text":"No states to redo","color":"dark_green"}] -execute as @s[scores={as_trigger=1201}] if data storage customizable_armor_stands:book_storage SavedItem.tag.RedoStates[] if score #as_success as_angle matches 0 run function armor_statues:repeat/redo \ No newline at end of file +execute as @s[scores={as_trigger=1201}] \ + unless data storage customizable_armor_stands:book_storage SavedItem.tag.RedoStates[] run \ + title @a[tag=as_selected,tag=!as_chat] actionbar \ + [\ + {\ + "text":"No states to redo",\ + "color":"dark_green"\ + }\ + ] +execute as @s[scores={as_trigger=1201}] \ + unless data storage customizable_armor_stands:book_storage SavedItem.tag.RedoStates[] run \ + tellraw @a[tag=as_selected,tag=as_chat] \ + [\ + {\ + "text":" ",\ + "color":"dark_green"\ + }, \ + {\ + "text":"No states to redo",\ + "color":"dark_green"\ + }\ + ] +execute as @s[scores={as_trigger=1201}] \ + if data storage customizable_armor_stands:book_storage SavedItem.tag.RedoStates[] run \ + function armor_statues:repeat/redo \ No newline at end of file diff --git a/data/armor_statues/functions/uuid_check.mcfunction b/data/armor_statues/functions/uuid_check.mcfunction new file mode 100644 index 0000000..9f49636 --- /dev/null +++ b/data/armor_statues/functions/uuid_check.mcfunction @@ -0,0 +1,9 @@ +# +# Description: Checks to see if a UUID matches that of a given UUID of an entity. +# Called by: as_statue:repeat/undo_redo +# Entity @s: any +# Parameters: +# UUID (list): a uuid to check against the entity. +# +$execute if data entity @s { UUID: $(UUID) } run return 1 +return 0 \ No newline at end of file