mirror of
https://github.com/LZStealth/armor-statues.git
synced 2025-08-12 21:15:52 +01:00
Initial commit for armor statues
This commit is contained in:
21
data/armor_statues/functions/repeat/redo.mcfunction
Normal file
21
data/armor_statues/functions/repeat/redo.mcfunction
Normal file
@@ -0,0 +1,21 @@
|
||||
#
|
||||
# Description: Undo last armor stand action
|
||||
# Called by: as_statue:repeat/undo_redo
|
||||
# Entity @s: player
|
||||
#
|
||||
# Copies current state to undo states
|
||||
#
|
||||
function armor_statues:repeat/save_undo_state
|
||||
#
|
||||
# Copies last redo state to armor stand
|
||||
#
|
||||
data modify entity @e[type=minecraft:armor_stand,sort=nearest,limit=1] {} merge from storage customizable_armor_stands:book_storage SavedItem.tag.RedoStates[0]
|
||||
data modify entity @e[type=minecraft:armor_stand,sort=nearest,limit=1] Pose set from storage customizable_armor_stands:book_storage SavedItem.tag.RedoStates[0].Pose
|
||||
#
|
||||
# Deletes redo state
|
||||
#
|
||||
data remove storage customizable_armor_stands:book_storage SavedItem.tag.RedoStates[0]
|
||||
#
|
||||
# Modifies book data
|
||||
#
|
||||
execute as @s run function armor_statues:storage_out
|
14
data/armor_statues/functions/repeat/save.mcfunction
Normal file
14
data/armor_statues/functions/repeat/save.mcfunction
Normal file
@@ -0,0 +1,14 @@
|
||||
#
|
||||
# Description: Copies last function to book
|
||||
# Called by: as_statue:trigger
|
||||
# Entity @s: player
|
||||
#
|
||||
execute as @s run function armor_statues:storage_in
|
||||
#
|
||||
execute store result storage customizable_armor_stands:book_storage SavedItem.tag.Repeat int 1 run scoreboard players get @p[tag=as_selected] as_trigger
|
||||
#
|
||||
# Undo states
|
||||
#
|
||||
execute unless score @s as_trigger matches 1000..1004 unless score @s as_trigger matches 161..162 unless score @s as_trigger matches 120..123 unless score @s as_trigger matches 155 if entity @e[type=armor_stand,tag=as_selected] if score #undo_states as_angle matches 1.. run function armor_statues:repeat/save_state
|
||||
#
|
||||
execute as @s run function armor_statues:storage_out
|
@@ -0,0 +1,18 @@
|
||||
#
|
||||
# Description: Copies last state for redoing
|
||||
# Called by: as_statue:repeat/undo
|
||||
# Entity @s: player
|
||||
#
|
||||
# Copies data to redo
|
||||
#
|
||||
data modify storage customizable_armor_stands:book_storage SavedItem.tag.RedoStates prepend value {}
|
||||
#
|
||||
data modify storage customizable_armor_stands:book_storage SavedItem.tag.RedoStates[0].Pose set from entity @e[type=armor_stand,sort=nearest,limit=1,tag=as_selected] Pose
|
||||
data modify storage customizable_armor_stands:book_storage SavedItem.tag.RedoStates[0].NoBasePlate set from entity @e[type=armor_stand,sort=nearest,limit=1,tag=as_selected] NoBasePlate
|
||||
data modify storage customizable_armor_stands:book_storage SavedItem.tag.RedoStates[0].ShowArms set from entity @e[type=armor_stand,sort=nearest,limit=1,tag=as_selected] ShowArms
|
||||
data modify storage customizable_armor_stands:book_storage SavedItem.tag.RedoStates[0].Small set from entity @e[type=armor_stand,sort=nearest,limit=1,tag=as_selected] Small
|
||||
data modify storage customizable_armor_stands:book_storage SavedItem.tag.RedoStates[0].Invisible set from entity @e[type=armor_stand,sort=nearest,limit=1,tag=as_selected] Invisible
|
||||
data modify storage customizable_armor_stands:book_storage SavedItem.tag.RedoStates[0].CustomNameVisible set from entity @e[type=armor_stand,sort=nearest,limit=1,tag=as_selected] CustomNameVisible
|
||||
data modify storage customizable_armor_stands:book_storage SavedItem.tag.RedoStates[0].NoGravity set from entity @e[type=armor_stand,sort=nearest,limit=1,tag=as_selected] NoGravity
|
||||
data modify storage customizable_armor_stands:book_storage SavedItem.tag.RedoStates[0].Pos set from entity @e[type=armor_stand,sort=nearest,limit=1,tag=as_selected] Pos
|
||||
data modify storage customizable_armor_stands:book_storage SavedItem.tag.RedoStates[0].Rotation set from entity @e[type=armor_stand,sort=nearest,limit=1,tag=as_selected] Rotation
|
18
data/armor_statues/functions/repeat/save_state.mcfunction
Normal file
18
data/armor_statues/functions/repeat/save_state.mcfunction
Normal file
@@ -0,0 +1,18 @@
|
||||
#
|
||||
# Description: Copies last state for undoing
|
||||
# Called by: as_statue:repeat/save
|
||||
# Entity @s: player
|
||||
#
|
||||
# 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
|
||||
#
|
||||
# Counts undo states and makes sure they're less than the maximum undo states
|
||||
#
|
||||
execute store result score #as_temp as_angle run data get storage customizable_armor_stands:book_storage SavedItem.tag.UndoStates
|
||||
execute if score #as_temp as_angle >= #undo_states as_angle run data remove storage customizable_armor_stands:book_storage SavedItem.tag.UndoStates[-1]
|
||||
#
|
||||
function armor_statues:repeat/save_undo_state
|
@@ -0,0 +1,18 @@
|
||||
#
|
||||
# Description: Copies last state for undoing
|
||||
# Called by: as_statue:repeat/save
|
||||
# Entity @s: player
|
||||
#
|
||||
# Saves state for undoing
|
||||
#
|
||||
data modify storage customizable_armor_stands:book_storage SavedItem.tag.UndoStates prepend value {}
|
||||
#
|
||||
data modify storage customizable_armor_stands:book_storage SavedItem.tag.UndoStates[0].Pose set from entity @e[type=armor_stand,sort=nearest,limit=1,tag=as_selected] Pose
|
||||
data modify storage customizable_armor_stands:book_storage SavedItem.tag.UndoStates[0].NoBasePlate set from entity @e[type=armor_stand,sort=nearest,limit=1,tag=as_selected] NoBasePlate
|
||||
data modify storage customizable_armor_stands:book_storage SavedItem.tag.UndoStates[0].ShowArms set from entity @e[type=armor_stand,sort=nearest,limit=1,tag=as_selected] ShowArms
|
||||
data modify storage customizable_armor_stands:book_storage SavedItem.tag.UndoStates[0].Small set from entity @e[type=armor_stand,sort=nearest,limit=1,tag=as_selected] Small
|
||||
data modify storage customizable_armor_stands:book_storage SavedItem.tag.UndoStates[0].Invisible set from entity @e[type=armor_stand,sort=nearest,limit=1,tag=as_selected] Invisible
|
||||
data modify storage customizable_armor_stands:book_storage SavedItem.tag.UndoStates[0].CustomNameVisible set from entity @e[type=armor_stand,sort=nearest,limit=1,tag=as_selected] CustomNameVisible
|
||||
data modify storage customizable_armor_stands:book_storage SavedItem.tag.UndoStates[0].NoGravity set from entity @e[type=armor_stand,sort=nearest,limit=1,tag=as_selected] NoGravity
|
||||
data modify storage customizable_armor_stands:book_storage SavedItem.tag.UndoStates[0].Pos set from entity @e[type=armor_stand,sort=nearest,limit=1,tag=as_selected] Pos
|
||||
data modify storage customizable_armor_stands:book_storage SavedItem.tag.UndoStates[0].Rotation set from entity @e[type=armor_stand,sort=nearest,limit=1,tag=as_selected] Rotation
|
21
data/armor_statues/functions/repeat/undo.mcfunction
Normal file
21
data/armor_statues/functions/repeat/undo.mcfunction
Normal file
@@ -0,0 +1,21 @@
|
||||
#
|
||||
# Description: Undo last armor stand action
|
||||
# Called by: as_statue:repeat/undo_redo
|
||||
# Entity @s: player
|
||||
#
|
||||
# Copies current state to redo states
|
||||
#
|
||||
function armor_statues:repeat/save_redo_state
|
||||
#
|
||||
# Copies last undo state to armor stand
|
||||
#
|
||||
data modify entity @e[type=minecraft:armor_stand,sort=nearest,limit=1] {} merge from storage customizable_armor_stands:book_storage SavedItem.tag.UndoStates[0]
|
||||
data modify entity @e[type=minecraft:armor_stand,sort=nearest,limit=1] Pose set from storage customizable_armor_stands:book_storage SavedItem.tag.UndoStates[0].Pose
|
||||
#
|
||||
# Deletes undo state state
|
||||
#
|
||||
data remove storage customizable_armor_stands:book_storage SavedItem.tag.UndoStates[0]
|
||||
#
|
||||
# Modifies book data
|
||||
#
|
||||
execute as @s run function armor_statues:storage_out
|
25
data/armor_statues/functions/repeat/undo_redo.mcfunction
Normal file
25
data/armor_statues/functions/repeat/undo_redo.mcfunction
Normal file
@@ -0,0 +1,25 @@
|
||||
#
|
||||
# Description: Checks if armor stand is undoable/redoable
|
||||
# Called by: as_statue:trigger
|
||||
# Entity @s: player
|
||||
#
|
||||
execute as @s run function armor_statues:storage_in
|
||||
#
|
||||
# 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 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":"<Stick_God> ","color":"dark_green"}, {"text":"Can't undo/redo state on current Armor Stand","color":"dark_green"}]
|
||||
#
|
||||
# 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":"<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[] if score #as_success as_angle matches 0 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":"<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[] if score #as_success as_angle matches 0 run function armor_statues:repeat/redo
|
Reference in New Issue
Block a user