1
0
mirror of https://github.com/LZStealth/armor-statues.git synced 2025-06-07 17:16:44 +01:00

Fix for undo/redo issue.

This commit is contained in:
MukiTanuki 2023-09-24 17:33:55 -07:00
parent 8fd8ab69be
commit b0fb665755
3 changed files with 106 additions and 12 deletions

View File

@ -5,10 +5,22 @@
# #
# Checks if UUID of armor stand matches that of the book # 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 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 data remove storage customizable_armor_stands:uuid_check UUID
execute if score #as_success as_angle matches 1 run data remove storage customizable_armor_stands:book_storage SavedItem.tag.UndoStates data modify storage customizable_armor_stands:uuid_check UUID set from storage customizable_armor_stands:book_storage SavedItem.tag.StatesUUID
data remove storage customizable_armor_stands:book_storage SavedItem.tag.RedoStates 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 # Counts undo states and makes sure they're less than the maximum undo states
# #

View File

@ -7,19 +7,92 @@ execute as @s run function armor_statues:storage_in
# #
# Checks if UUID of armor stand matches that of the book # 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 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 data remove storage customizable_armor_stands:uuid_check 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"}] data modify storage customizable_armor_stands:uuid_check UUID set from storage customizable_armor_stands:book_storage SavedItem.tag.StatesUUID
execute if score #as_success as_angle matches 1 run tellraw @a[tag=as_selected,tag=as_chat] [{"text":"<Stick_God> ","color":"dark_green"}, {"text":"Can't undo/redo state on current Armor Stand","color":"dark_green"}] 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":"<Stick_God> ",\
"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 # 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}] \
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":"<Stick_God> ","color":"dark_green"}, {"text":"No states to undo","color":"dark_green"}] unless data storage customizable_armor_stands:book_storage SavedItem.tag.UndoStates[] run \
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 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":"<Stick_God> ",\
"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 # 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}] \
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":"<Stick_God> ","color":"dark_green"}, {"text":"No states to redo","color":"dark_green"}] unless data storage customizable_armor_stands:book_storage SavedItem.tag.RedoStates[] run \
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 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":"<Stick_God> ",\
"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

View File

@ -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