1- dir global {
2-
3- function on_load minecraft:load {
4- # Initialize Scoreboards
5- scoreboard objectives add <%OBJECTIVES.I()%> dummy
6- scoreboard objectives add <%OBJECTIVES.ID()%> dummy
7- scoreboard objectives add <%OBJECTIVES.IS_RIG_LOADED()%> dummy
8- scoreboard objectives add <%OBJECTIVES.TWEEN_DURATION()%> dummy
9-
10- scoreboard players add aj.last_id <%OBJECTIVES.ID()%> 0
11-
12- # Initialize Storage
13- data modify storage aj:temp args set value {}
14- IF (show_outdated_warning) {
15- # Initialize Rigs
16- scoreboard players reset * <%OBJECTIVES.IS_RIG_LOADED()%>
17- }
18- function #*global/on_load
19- }
20-
21- function on_tick minecraft:tick {
22- execute as @e[type=item_display,tag=<%TAGS.GLOBAL_ROOT()%>] at @s run function #*global/root/on_tick
23- }
24-
25- tag functions on_load {
26- *<%export_namespace%>/on_load
27- }
28-
29- dir root {
30- # TODO Maybe instead of merging tags, I should just generate it from the .ajmeta data every time a rig is exported?
31- # That way I can also check if the rig's files still exist, and remove tag entries if they don't.
32- # An entry will be added for each exported rig.
33- tag functions on_tick {
34- *<%export_namespace%>/root/on_tick
35- }
36- # An entry will be added for each exported rig.
37- IF (show_outdated_warning) {
38- tag functions on_load {
39- *<%export_namespace%>/root/on_load
40- }
41- }
42- }
43-
44- IF (show_function_errors) {
45- dir errors {
46- function function_not_executed_as_root_entity {
47- #ARGS: {export_namespace: string, function_path: string}
48- $tellraw @a <%TELLRAW.FUNCTION_NOT_EXECUTED_AS_ROOT_ERROR('$(function_path)')%>
49- }
50- }
51- }
52-
53- dir remove {
54- # Removes all instances of all rigs from the world.
55- function everything {
56- kill @e[tag=<%TAGS.GLOBAL_RIG()%>]
57- }
58- }
59-
60- dir internal {
61- # Thanks Gibbsly for this code! https://github.com/gibbsly/gu
62- dir gu {
63- function load minecraft:load {
64- scoreboard players set 256 <%OBJECTIVES.I()%> 256
65- data modify storage aj:uuid main.hex_chars set value \
66- <%JSON.stringify([...Array(0x100).keys()].map(v => {const x = v.toString(16); return x.length > 1 ? x : '0' + x}))%>
67- }
68-
69- function convert_uuid_array_to_string {
70- #ARGS: {UUID: [int, int, int, int]}
71-
72- data modify storage aj:uuid temp set value {0:0,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,a:0,b:0,c:0,d:0,e:0,f:0}
73- $data modify storage aj:uuid main.in set value $(UUID)
74-
75- execute store result score 0= <%OBJECTIVES.I()%> store result score 1= <%OBJECTIVES.I()%> run data get storage aj:uuid main.in[0]
76- execute store result storage aj:uuid temp.0 int 1 run scoreboard players operation 0= <%OBJECTIVES.I()%> %= 256 <%OBJECTIVES.I()%>
77- execute store result score 2= <%OBJECTIVES.I()%> run scoreboard players operation 1= <%OBJECTIVES.I()%> /= 256 <%OBJECTIVES.I()%>
78- execute store result storage aj:uuid temp.1 int 1 run scoreboard players operation 1= <%OBJECTIVES.I()%> %= 256 <%OBJECTIVES.I()%>
79- execute store result score 3= <%OBJECTIVES.I()%> run scoreboard players operation 2= <%OBJECTIVES.I()%> /= 256 <%OBJECTIVES.I()%>
80- execute store result storage aj:uuid temp.2 int 1 run scoreboard players operation 2= <%OBJECTIVES.I()%> %= 256 <%OBJECTIVES.I()%>
81- execute store result storage aj:uuid temp.3 int 1 run scoreboard players operation 3= <%OBJECTIVES.I()%> /= 256 <%OBJECTIVES.I()%>
82-
83- execute store result score 0= <%OBJECTIVES.I()%> store result score 1= <%OBJECTIVES.I()%> run data get storage aj:uuid main.in[1]
84- execute store result storage aj:uuid temp.4 int 1 run scoreboard players operation 0= <%OBJECTIVES.I()%> %= 256 <%OBJECTIVES.I()%>
85- execute store result score 2= <%OBJECTIVES.I()%> run scoreboard players operation 1= <%OBJECTIVES.I()%> /= 256 <%OBJECTIVES.I()%>
86- execute store result storage aj:uuid temp.5 int 1 run scoreboard players operation 1= <%OBJECTIVES.I()%> %= 256 <%OBJECTIVES.I()%>
87- execute store result score 3= <%OBJECTIVES.I()%> run scoreboard players operation 2= <%OBJECTIVES.I()%> /= 256 <%OBJECTIVES.I()%>
88- execute store result storage aj:uuid temp.6 int 1 run scoreboard players operation 2= <%OBJECTIVES.I()%> %= 256 <%OBJECTIVES.I()%>
89- execute store result storage aj:uuid temp.7 int 1 run scoreboard players operation 3= <%OBJECTIVES.I()%> /= 256 <%OBJECTIVES.I()%>
90-
91- execute store result score 0= <%OBJECTIVES.I()%> store result score 1= <%OBJECTIVES.I()%> run data get storage aj:uuid main.in[2]
92- execute store result storage aj:uuid temp.8 int 1 run scoreboard players operation 0= <%OBJECTIVES.I()%> %= 256 <%OBJECTIVES.I()%>
93- execute store result score 2= <%OBJECTIVES.I()%> run scoreboard players operation 1= <%OBJECTIVES.I()%> /= 256 <%OBJECTIVES.I()%>
94- execute store result storage aj:uuid temp.9 int 1 run scoreboard players operation 1= <%OBJECTIVES.I()%> %= 256 <%OBJECTIVES.I()%>
95- execute store result score 3= <%OBJECTIVES.I()%> run scoreboard players operation 2= <%OBJECTIVES.I()%> /= 256 <%OBJECTIVES.I()%>
96- execute store result storage aj:uuid temp.a int 1 run scoreboard players operation 2= <%OBJECTIVES.I()%> %= 256 <%OBJECTIVES.I()%>
97- execute store result storage aj:uuid temp.b int 1 run scoreboard players operation 3= <%OBJECTIVES.I()%> /= 256 <%OBJECTIVES.I()%>
98-
99- execute store result score 0= <%OBJECTIVES.I()%> store result score 1= <%OBJECTIVES.I()%> run data get storage aj:uuid main.in[3]
100- execute store result storage aj:uuid temp.c int 1 run scoreboard players operation 0= <%OBJECTIVES.I()%> %= 256 <%OBJECTIVES.I()%>
101- execute store result score 2= <%OBJECTIVES.I()%> run scoreboard players operation 1= <%OBJECTIVES.I()%> /= 256 <%OBJECTIVES.I()%>
102- execute store result storage aj:uuid temp.d int 1 run scoreboard players operation 1= <%OBJECTIVES.I()%> %= 256 <%OBJECTIVES.I()%>
103- execute store result score 3= <%OBJECTIVES.I()%> run scoreboard players operation 2= <%OBJECTIVES.I()%> /= 256 <%OBJECTIVES.I()%>
104- execute store result storage aj:uuid temp.e int 1 run scoreboard players operation 2= <%OBJECTIVES.I()%> %= 256 <%OBJECTIVES.I()%>
105- execute store result storage aj:uuid temp.f int 1 run scoreboard players operation 3= <%OBJECTIVES.I()%> /= 256 <%OBJECTIVES.I()%>
106-
107- block { with storage aj:uuid temp
108- REPEAT (0, 15) as i {
109- $data modify storage aj:uuid temp.<%i.toString(16)%> set from storage aj:uuid main.hex_chars[$(<%i.toString(16)%>)]
110- }
111- }
112-
113- block { with storage aj:uuid temp
114- $data modify storage aj:uuid main.out set value "$(3)$(2)$(1)$(0)-$(7)$(6)-$(5)$(4)-$(b)$(a)-$(9)$(8)$(f)$(e)$(d)$(c)"
115- }
116- }
117- }
118- }
119- }
1201
1212dir <%export_namespace%> {
1223 function on_load {
1234 IF (use_storage_for_animation) {
1245 REPEAT (animations) as animation {
125- data remove storage aj.<%export_namespace%>:animations <%animation.storageSafeName %>
6+ data remove storage aj.<%export_namespace%>:animations <%animation.safe_name %>
1267 }
1278 <%animationStorage.join('\n')%>
1289 }
@@ -133,6 +14,10 @@ dir <%export_namespace%> {
13314 %%>
13415 }
13516
17+ function invalid_version_warning {
18+ # This function will contain a tellraw if the datapack is loaded in the wrong version.
19+ }
20+
13621 dir root {
13722 IF (show_outdated_warning) {
13823 function on_load {
@@ -365,6 +250,11 @@ dir <%export_namespace%> {
365250 storage aj.<%export_namespace%>:animations <%animation.safe_name%>.$(frame).<%node.type + '_' + node.safe_name%>
366251 }
367252 }
253+ IF (animation.frames.some(v => v.variant)) {
254+ $execute if data storage aj.<%export_namespace%>:animations <%animation.safe_name%>.$(frame).variant unless entity @s[tag=<%TAGS.TRANSFORMS_ONLY()%>] run data modify storage aj:temp variant set from storage aj.<%export_namespace%>:animations <%animation.safe_name%>.$(frame).variant
255+ $execute if data storage aj.<%export_namespace%>:animations <%animation.safe_name%>.$(frame).variant unless entity @s[tag=<%TAGS.TRANSFORMS_ONLY()%>] run function *<%export_namespace%>/animations/<%animation.safe_name%>/zzz/apply_variant with storage aj:temp variant
256+ $execute if data storage aj.<%export_namespace%>:animations <%animation.safe_name%>.$(frame).variant unless entity @s[tag=<%TAGS.TRANSFORMS_ONLY()%>] run data remove storage aj:temp variant
257+ }
368258 execute on passengers run data modify entity @s[type=!marker] start_interpolation set value -1
369259 }
370260 function apply_frame {
@@ -378,6 +268,17 @@ dir <%export_namespace%> {
378268 storage aj.<%export_namespace%>:animations <%animation.safe_name%>.$(frame).<%node.type + '_' + node.safe_name%>
379269 }
380270 }
271+ IF (animation.frames.some(v => v.variant)) {
272+ $execute if data storage aj.<%export_namespace%>:animations <%animation.safe_name%>.$(frame).variant unless entity @s[tag=<%TAGS.TRANSFORMS_ONLY()%>] run data modify storage aj:temp variant set from storage aj.<%export_namespace%>:animations <%animation.safe_name%>.$(frame).variant
273+ $execute if data storage aj.<%export_namespace%>:animations <%animation.safe_name%>.$(frame).variant unless entity @s[tag=<%TAGS.TRANSFORMS_ONLY()%>] run function *<%export_namespace%>/animations/<%animation.safe_name%>/zzz/apply_variant with storage aj:temp variant
274+ $execute if data storage aj.<%export_namespace%>:animations <%animation.safe_name%>.$(frame).variant unless entity @s[tag=<%TAGS.TRANSFORMS_ONLY()%>] run data remove storage aj:temp variant
275+ }
276+ }
277+ IF (animation.frames.some(v => v.variant)) {
278+ function apply_variant {
279+ #ARGS: {name: string, condition: string}
280+ $execute $(condition)run function *<%export_namespace%>/variants/$(name)/apply
281+ }
381282 }
382283 } ELSE {
383284 function set_frame {
0 commit comments