@@ -116,7 +116,7 @@ dir <%export_namespace%> {
116
116
function on_load {
117
117
<%%
118
118
animations.forEach(animation => {
119
- emit(`scoreboard objectives add ${OBJECTIVES.FRAME(animation.name )} dummy`)
119
+ emit(`scoreboard objectives add ${OBJECTIVES.FRAME(animation.safeName )} dummy`)
120
120
})
121
121
%%>
122
122
@@ -157,8 +157,8 @@ dir <%export_namespace%> {
157
157
function #*<%export_namespace%>/as_root/pre_tick
158
158
# Animations
159
159
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
162
162
}
163
163
execute on passengers if entity @s[tag=<%TAGS.PROJECT_DATA(export_namespace)%>] run {
164
164
REPEAT (Object.values(rig.nodeMap).filter(v => v.type === 'locator')) as node {
@@ -218,77 +218,77 @@ dir <%export_namespace%> {
218
218
219
219
dir animations {
220
220
REPEAT (animations) as animation {
221
- dir <%animation.name %> {
221
+ dir <%animation.safeName %> {
222
222
# TODO: Maybe add an exclusive argument to the play function that will pause all other animations before playing this one.
223
223
function play {
224
224
execute unless entity @s[type=item_display,tag=<%TAGS.PROJECT_ROOT(export_namespace)%>] run return run \
225
225
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
229
229
tag @s add <%TAGS.TRANSFORMS_ONLY()%>
230
230
execute at @s run function ./zzz/set_frame {frame: 0}
231
231
tag @s remove <%TAGS.TRANSFORMS_ONLY()%>
232
232
}
233
233
function stop {
234
234
execute unless entity @s[type=item_display,tag=<%TAGS.PROJECT_ROOT(export_namespace)%>] run return run \
235
235
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
239
239
tag @s add <%TAGS.TRANSFORMS_ONLY()%>
240
240
execute at @s run function ./zzz/set_frame {frame: 0}
241
241
tag @s remove <%TAGS.TRANSFORMS_ONLY()%>
242
242
}
243
243
function pause {
244
244
execute unless entity @s[type=item_display,tag=<%TAGS.PROJECT_ROOT(export_namespace)%>] run return run \
245
245
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 )%>
248
248
}
249
249
function resume {
250
250
execute unless entity @s[type=item_display,tag=<%TAGS.PROJECT_ROOT(export_namespace)%>] run return run \
251
251
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 )%>
254
254
}
255
255
function next_frame {
256
256
execute unless entity @s[type=item_display,tag=<%TAGS.PROJECT_ROOT(export_namespace)%>] run return run \
257
257
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 )%>
261
261
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
263
263
}
264
264
function set_frame {
265
265
# Sets the frame without interpolation
266
266
#ARGS: {frame: int}
267
267
execute unless entity @s[type=item_display,tag=<%TAGS.PROJECT_ROOT(export_namespace)%>] run return run \
268
268
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)
271
271
execute at @s run function ./zzz/set_frame with storage aj:temp
272
272
}
273
273
function apply_frame {
274
274
# ARGS: {frame: int}
275
275
execute unless entity @s[type=item_display,tag=<%TAGS.PROJECT_ROOT(export_namespace)%>] run return run \
276
276
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)
279
279
execute at @s run function ./zzz/apply_frame with storage aj:temp
280
280
}
281
281
function tween {
282
282
# Attempts to smoothly transition from the currently playing animation into this one.
283
283
#ARGS: {duration: int, to_frame: int}
284
284
execute unless entity @s[type=item_display,tag=<%TAGS.PROJECT_ROOT(export_namespace)%>] run return run \
285
285
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'}
287
287
function *<%export_namespace%>/animations/pause_all
288
288
289
- tag @s add <%TAGS.ANIMATION_PLAYING(export_namespace, animation.name )%>
289
+ tag @s add <%TAGS.ANIMATION_PLAYING(export_namespace, animation.safeName )%>
290
290
$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)
292
292
293
293
scoreboard players operation #this <%OBJECTIVES.I()%> = @s <%OBJECTIVES.TWEEN_DURATION()%>
294
294
scoreboard players add @s <%OBJECTIVES.TWEEN_DURATION()%> 1
@@ -305,25 +305,25 @@ dir <%export_namespace%> {
305
305
execute if score @s <%OBJECTIVES.TWEEN_DURATION()%> matches 1.. run return 1
306
306
execute if score @s <%OBJECTIVES.TWEEN_DURATION()%> matches 0 on passengers run data modify entity @s interpolation_duration set value <%interpolation_duration%>
307
307
# 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 )%>
309
309
IF (animation.loopMode === 'loop' && animation.loopDelay === 0) {
310
310
# 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 {
312
312
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
314
314
}
315
315
}
316
316
function ./apply_frame with storage aj:temp
317
317
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%>
320
320
}
321
321
} 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
323
323
} 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
325
325
}
326
- scoreboard players add @s <%OBJECTIVES.FRAME(animation.name )%> 1
326
+ scoreboard players add @s <%OBJECTIVES.FRAME(animation.safeName )%> 1
327
327
}
328
328
IF (use_storage_for_animation) {
329
329
function set_frame {
@@ -460,7 +460,7 @@ dir <%export_namespace%> {
460
460
function *global/errors/function_not_executed_as_root_entity \
461
461
{'export_namespace': '<%export_namespace%>', 'function_path': 'animated_java:<%export_namespace%>/animations/pause_all'}
462
462
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 )%>
464
464
}
465
465
}
466
466
}
0 commit comments