@@ -116,7 +116,7 @@ dir <%export_namespace%> {
116116 function on_load {
117117 <%%
118118 animations.forEach(animation => {
119- emit(`scoreboard objectives add ${OBJECTIVES.FRAME(animation.name )} dummy`)
119+ emit(`scoreboard objectives add ${OBJECTIVES.FRAME(animation.safeName )} dummy`)
120120 })
121121 %%>
122122
@@ -157,8 +157,8 @@ dir <%export_namespace%> {
157157 function #*<%export_namespace%>/as_root/pre_tick
158158 # Animations
159159 REPEAT (animations) as animation {
160- execute if entity @s[tag=<%TAGS.ANIMATION_PLAYING(export_namespace, animation.name )%>] run \
161- function *<%export_namespace%>/animations/<%animation.name %>/zzz/on_tick
160+ execute if entity @s[tag=<%TAGS.ANIMATION_PLAYING(export_namespace, animation.safeName )%>] run \
161+ function *<%export_namespace%>/animations/<%animation.safeName %>/zzz/on_tick
162162 }
163163 execute on passengers if entity @s[tag=<%TAGS.PROJECT_DATA(export_namespace)%>] run {
164164 REPEAT (Object.values(rig.nodeMap).filter(v => v.type === 'locator')) as node {
@@ -218,77 +218,77 @@ dir <%export_namespace%> {
218218
219219 dir animations {
220220 REPEAT (animations) as animation {
221- dir <%animation.name %> {
221+ dir <%animation.safeName %> {
222222 # TODO: Maybe add an exclusive argument to the play function that will pause all other animations before playing this one.
223223 function play {
224224 execute unless entity @s[type=item_display,tag=<%TAGS.PROJECT_ROOT(export_namespace)%>] run return run \
225225 function *global/errors/function_not_executed_as_root_entity \
226- {'export_namespace': '<%export_namespace%>', 'function_path': 'animated_java:<%export_namespace%>/animations/<%animation.name %>/play'}
227- tag @s add <%TAGS.ANIMATION_PLAYING(export_namespace, animation.name )%>
228- scoreboard players set @s <%OBJECTIVES.FRAME(animation.name )%> 0
226+ {'export_namespace': '<%export_namespace%>', 'function_path': 'animated_java:<%export_namespace%>/animations/<%animation.safeName %>/play'}
227+ tag @s add <%TAGS.ANIMATION_PLAYING(export_namespace, animation.safeName )%>
228+ scoreboard players set @s <%OBJECTIVES.FRAME(animation.safeName )%> 0
229229 tag @s add <%TAGS.TRANSFORMS_ONLY()%>
230230 execute at @s run function ./zzz/set_frame {frame: 0}
231231 tag @s remove <%TAGS.TRANSFORMS_ONLY()%>
232232 }
233233 function stop {
234234 execute unless entity @s[type=item_display,tag=<%TAGS.PROJECT_ROOT(export_namespace)%>] run return run \
235235 function *global/errors/function_not_executed_as_root_entity \
236- {'export_namespace': '<%export_namespace%>', 'function_path': 'animated_java:<%export_namespace%>/animations/<%animation.name %>/stop'}
237- tag @s remove <%TAGS.ANIMATION_PLAYING(export_namespace, animation.name )%>
238- scoreboard players set @s <%OBJECTIVES.FRAME(animation.name )%> 0
236+ {'export_namespace': '<%export_namespace%>', 'function_path': 'animated_java:<%export_namespace%>/animations/<%animation.safeName %>/stop'}
237+ tag @s remove <%TAGS.ANIMATION_PLAYING(export_namespace, animation.safeName )%>
238+ scoreboard players set @s <%OBJECTIVES.FRAME(animation.safeName )%> 0
239239 tag @s add <%TAGS.TRANSFORMS_ONLY()%>
240240 execute at @s run function ./zzz/set_frame {frame: 0}
241241 tag @s remove <%TAGS.TRANSFORMS_ONLY()%>
242242 }
243243 function pause {
244244 execute unless entity @s[type=item_display,tag=<%TAGS.PROJECT_ROOT(export_namespace)%>] run return run \
245245 function *global/errors/function_not_executed_as_root_entity \
246- {'export_namespace': '<%export_namespace%>', 'function_path': 'animated_java:<%export_namespace%>/animations/<%animation.name %>/pause'}
247- tag @s remove <%TAGS.ANIMATION_PLAYING(export_namespace, animation.name )%>
246+ {'export_namespace': '<%export_namespace%>', 'function_path': 'animated_java:<%export_namespace%>/animations/<%animation.safeName %>/pause'}
247+ tag @s remove <%TAGS.ANIMATION_PLAYING(export_namespace, animation.safeName )%>
248248 }
249249 function resume {
250250 execute unless entity @s[type=item_display,tag=<%TAGS.PROJECT_ROOT(export_namespace)%>] run return run \
251251 function *global/errors/function_not_executed_as_root_entity \
252- {'export_namespace': '<%export_namespace%>', 'function_path': 'animated_java:<%export_namespace%>/animations/<%animation.name %>/resume'}
253- tag @s add <%TAGS.ANIMATION_PLAYING(export_namespace, animation.name )%>
252+ {'export_namespace': '<%export_namespace%>', 'function_path': 'animated_java:<%export_namespace%>/animations/<%animation.safeName %>/resume'}
253+ tag @s add <%TAGS.ANIMATION_PLAYING(export_namespace, animation.safeName )%>
254254 }
255255 function next_frame {
256256 execute unless entity @s[type=item_display,tag=<%TAGS.PROJECT_ROOT(export_namespace)%>] run return run \
257257 function *global/errors/function_not_executed_as_root_entity \
258- {'export_namespace': '<%export_namespace%>', 'function_path': 'animated_java:<%export_namespace%>/animations/<%animation.name %>/next_frame'}
259- execute if score @s <%OBJECTIVES.FRAME(animation.name )%> matches <%animation.duration%>.. run scoreboard players set @s <%OBJECTIVES.FRAME(animation.name )%> 1
260- execute store result storage aj:temp frame int 1 run scoreboard players get @s <%OBJECTIVES.FRAME(animation.name )%>
258+ {'export_namespace': '<%export_namespace%>', 'function_path': 'animated_java:<%export_namespace%>/animations/<%animation.safeName %>/next_frame'}
259+ execute if score @s <%OBJECTIVES.FRAME(animation.safeName )%> matches <%animation.duration%>.. run scoreboard players set @s <%OBJECTIVES.FRAME(animation.safeName )%> 1
260+ execute store result storage aj:temp frame int 1 run scoreboard players get @s <%OBJECTIVES.FRAME(animation.safeName )%>
261261 execute at @s run function ./zzz/apply_frame with storage aj:temp
262- scoreboard players add @s <%OBJECTIVES.FRAME(animation.name )%> 1
262+ scoreboard players add @s <%OBJECTIVES.FRAME(animation.safeName )%> 1
263263 }
264264 function set_frame {
265265 # Sets the frame without interpolation
266266 #ARGS: {frame: int}
267267 execute unless entity @s[type=item_display,tag=<%TAGS.PROJECT_ROOT(export_namespace)%>] run return run \
268268 function *global/errors/function_not_executed_as_root_entity \
269- {'export_namespace': '<%export_namespace%>', 'function_path': 'animated_java:<%export_namespace%>/animations/<%animation.name %>/set_frame'}
270- $execute store result storage aj:temp frame int 1 run scoreboard players set @s <%OBJECTIVES.FRAME(animation.name )%> $(frame)
269+ {'export_namespace': '<%export_namespace%>', 'function_path': 'animated_java:<%export_namespace%>/animations/<%animation.safeName %>/set_frame'}
270+ $execute store result storage aj:temp frame int 1 run scoreboard players set @s <%OBJECTIVES.FRAME(animation.safeName )%> $(frame)
271271 execute at @s run function ./zzz/set_frame with storage aj:temp
272272 }
273273 function apply_frame {
274274 # ARGS: {frame: int}
275275 execute unless entity @s[type=item_display,tag=<%TAGS.PROJECT_ROOT(export_namespace)%>] run return run \
276276 function *global/errors/function_not_executed_as_root_entity \
277- {'export_namespace': '<%export_namespace%>', 'function_path': 'animated_java:<%export_namespace%>/animations/<%animation.name %>/apply_frame'}
278- $execute store result storage aj:temp frame int 1 run scoreboard players set @s <%OBJECTIVES.FRAME(animation.name )%> $(frame)
277+ {'export_namespace': '<%export_namespace%>', 'function_path': 'animated_java:<%export_namespace%>/animations/<%animation.safeName %>/apply_frame'}
278+ $execute store result storage aj:temp frame int 1 run scoreboard players set @s <%OBJECTIVES.FRAME(animation.safeName )%> $(frame)
279279 execute at @s run function ./zzz/apply_frame with storage aj:temp
280280 }
281281 function tween {
282282 # Attempts to smoothly transition from the currently playing animation into this one.
283283 #ARGS: {duration: int, to_frame: int}
284284 execute unless entity @s[type=item_display,tag=<%TAGS.PROJECT_ROOT(export_namespace)%>] run return run \
285285 function *global/errors/function_not_executed_as_root_entity \
286- {'export_namespace': '<%export_namespace%>', 'function_path': 'animated_java:<%export_namespace%>/animations/<%animation.name %>/tween_play'}
286+ {'export_namespace': '<%export_namespace%>', 'function_path': 'animated_java:<%export_namespace%>/animations/<%animation.safeName %>/tween_play'}
287287 function *<%export_namespace%>/animations/pause_all
288288
289- tag @s add <%TAGS.ANIMATION_PLAYING(export_namespace, animation.name )%>
289+ tag @s add <%TAGS.ANIMATION_PLAYING(export_namespace, animation.safeName )%>
290290 $scoreboard players set @s <%OBJECTIVES.TWEEN_DURATION()%> $(duration)
291- $scoreboard players set @s <%OBJECTIVES.FRAME(animation.name )%> $(to_frame)
291+ $scoreboard players set @s <%OBJECTIVES.FRAME(animation.safeName )%> $(to_frame)
292292
293293 scoreboard players operation #this <%OBJECTIVES.I()%> = @s <%OBJECTIVES.TWEEN_DURATION()%>
294294 scoreboard players add @s <%OBJECTIVES.TWEEN_DURATION()%> 1
@@ -305,25 +305,25 @@ dir <%export_namespace%> {
305305 execute if score @s <%OBJECTIVES.TWEEN_DURATION()%> matches 1.. run return 1
306306 execute if score @s <%OBJECTIVES.TWEEN_DURATION()%> matches 0 on passengers run data modify entity @s interpolation_duration set value <%interpolation_duration%>
307307 # Animation logic
308- execute store result storage aj:temp frame int 1 run scoreboard players get @s <%OBJECTIVES.FRAME(animation.name )%>
308+ execute store result storage aj:temp frame int 1 run scoreboard players get @s <%OBJECTIVES.FRAME(animation.safeName )%>
309309 IF (animation.loopMode === 'loop' && animation.loopDelay === 0) {
310310 # Makes sure commands in the last frame of the animation is run.
311- execute if score @s <%OBJECTIVES.FRAME(animation.name )%> matches -1 run {
311+ execute if score @s <%OBJECTIVES.FRAME(animation.safeName )%> matches -1 run {
312312 function ./apply_frame {frame: <%animation.duration-1%>}
313- scoreboard players add @s <%OBJECTIVES.FRAME(animation.name )%> 1
313+ scoreboard players add @s <%OBJECTIVES.FRAME(animation.safeName )%> 1
314314 }
315315 }
316316 function ./apply_frame with storage aj:temp
317317 IF (animation.loopMode === 'loop') {
318- execute if score @s <%OBJECTIVES.FRAME(animation.name )%> matches <%animation.duration-2 + animation.loopDelay%>.. run return run {
319- scoreboard players set @s <%OBJECTIVES.FRAME(animation.name )%> <%animation.loopDelay === 0 ? -1 : 0%>
318+ execute if score @s <%OBJECTIVES.FRAME(animation.safeName )%> matches <%animation.duration-2 + animation.loopDelay%>.. run return run {
319+ scoreboard players set @s <%OBJECTIVES.FRAME(animation.safeName )%> <%animation.loopDelay === 0 ? -1 : 0%>
320320 }
321321 } ELSE IF (animation.loopMode === 'hold') {
322- execute if score @s <%OBJECTIVES.FRAME(animation.name )%> matches <%animation.duration-1%>.. run return run function ../pause
322+ execute if score @s <%OBJECTIVES.FRAME(animation.safeName )%> matches <%animation.duration-1%>.. run return run function ../pause
323323 } ELSE IF (animation.loopMode === 'once') {
324- execute if score @s <%OBJECTIVES.FRAME(animation.name )%> matches <%animation.duration-1%> run return run function ../stop
324+ execute if score @s <%OBJECTIVES.FRAME(animation.safeName )%> matches <%animation.duration-1%> run return run function ../stop
325325 }
326- scoreboard players add @s <%OBJECTIVES.FRAME(animation.name )%> 1
326+ scoreboard players add @s <%OBJECTIVES.FRAME(animation.safeName )%> 1
327327 }
328328 IF (use_storage_for_animation) {
329329 function set_frame {
@@ -460,7 +460,7 @@ dir <%export_namespace%> {
460460 function *global/errors/function_not_executed_as_root_entity \
461461 {'export_namespace': '<%export_namespace%>', 'function_path': 'animated_java:<%export_namespace%>/animations/pause_all'}
462462 REPEAT (animations) as animation {
463- tag @s remove <%TAGS.ANIMATION_PLAYING(export_namespace, animation.name )%>
463+ tag @s remove <%TAGS.ANIMATION_PLAYING(export_namespace, animation.safeName )%>
464464 }
465465 }
466466 }
0 commit comments