@@ -2,9 +2,13 @@ dir global {
2
2
3
3
function on_load minecraft:load {
4
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
5
9
<%%
6
- Object.values(OBJECTIVES). forEach(obj => {
7
- emit(`scoreboard objectives add ${obj( )} dummy`)
10
+ animations. forEach(animation => {
11
+ emit(`scoreboard objectives add ${OBJECTIVES.FRAME(animation.name )} dummy`)
8
12
})
9
13
%%>
10
14
@@ -220,16 +224,20 @@ dir <%export_namespace%> {
220
224
function *global/errors/function_not_executed_as_root_entity \
221
225
{'export_namespace': '<%export_namespace%>', 'function_path': 'animated_java:<%export_namespace%>/animations/<%animation.name%>/play'}
222
226
tag @s add <%TAGS.ANIMATION_PLAYING(export_namespace, animation.name)%>
223
- scoreboard players set @s <%OBJECTIVES.FRAME()%> 0
227
+ scoreboard players set @s <%OBJECTIVES.FRAME(animation.name)%> 0
228
+ tag @s add <%TAGS.TRANSFORMS_ONLY()%>
224
229
execute at @s run function ./zzz/set_frame {frame: 0}
230
+ tag @s remove <%TAGS.TRANSFORMS_ONLY()%>
225
231
}
226
232
function stop {
227
233
execute unless entity @s[type=item_display,tag=<%TAGS.PROJECT_ROOT(export_namespace)%>] run return run \
228
234
function *global/errors/function_not_executed_as_root_entity \
229
235
{'export_namespace': '<%export_namespace%>', 'function_path': 'animated_java:<%export_namespace%>/animations/<%animation.name%>/stop'}
230
236
tag @s remove <%TAGS.ANIMATION_PLAYING(export_namespace, animation.name)%>
231
- scoreboard players set @s <%OBJECTIVES.FRAME()%> 0
237
+ scoreboard players set @s <%OBJECTIVES.FRAME(animation.name)%> 0
238
+ tag @s add <%TAGS.TRANSFORMS_ONLY()%>
232
239
execute at @s run function ./zzz/set_frame {frame: 0}
240
+ tag @s remove <%TAGS.TRANSFORMS_ONLY()%>
233
241
}
234
242
function pause {
235
243
execute unless entity @s[type=item_display,tag=<%TAGS.PROJECT_ROOT(export_namespace)%>] run return run \
@@ -247,26 +255,26 @@ dir <%export_namespace%> {
247
255
execute unless entity @s[type=item_display,tag=<%TAGS.PROJECT_ROOT(export_namespace)%>] run return run \
248
256
function *global/errors/function_not_executed_as_root_entity \
249
257
{'export_namespace': '<%export_namespace%>', 'function_path': 'animated_java:<%export_namespace%>/animations/<%animation.name%>/next_frame'}
250
- execute if score @s <%OBJECTIVES.FRAME()%> matches <%animation.duration%>.. run scoreboard players set @s <%OBJECTIVES.FRAME()%> 1
251
- execute store result storage aj:temp frame int 1 run scoreboard players get @s <%OBJECTIVES.FRAME()%>
258
+ execute if score @s <%OBJECTIVES.FRAME(animation.name )%> matches <%animation.duration%>.. run scoreboard players set @s <%OBJECTIVES.FRAME(animation.name )%> 1
259
+ execute store result storage aj:temp frame int 1 run scoreboard players get @s <%OBJECTIVES.FRAME(animation.name )%>
252
260
execute at @s run function ./zzz/apply_frame with storage aj:temp
253
- scoreboard players add @s <%OBJECTIVES.FRAME()%> 1
261
+ scoreboard players add @s <%OBJECTIVES.FRAME(animation.name )%> 1
254
262
}
255
263
function set_frame {
256
264
# Sets the frame without interpolation
257
265
#ARGS: {frame: int}
258
266
execute unless entity @s[type=item_display,tag=<%TAGS.PROJECT_ROOT(export_namespace)%>] run return run \
259
267
function *global/errors/function_not_executed_as_root_entity \
260
268
{'export_namespace': '<%export_namespace%>', 'function_path': 'animated_java:<%export_namespace%>/animations/<%animation.name%>/set_frame'}
261
- $execute store result storage aj:temp frame int 1 run scoreboard players set @s <%OBJECTIVES.FRAME()%> $(frame)
269
+ $execute store result storage aj:temp frame int 1 run scoreboard players set @s <%OBJECTIVES.FRAME(animation.name )%> $(frame)
262
270
execute at @s run function ./zzz/set_frame with storage aj:temp
263
271
}
264
272
function apply_frame {
265
273
# ARGS: {frame: int}
266
274
execute unless entity @s[type=item_display,tag=<%TAGS.PROJECT_ROOT(export_namespace)%>] run return run \
267
275
function *global/errors/function_not_executed_as_root_entity \
268
276
{'export_namespace': '<%export_namespace%>', 'function_path': 'animated_java:<%export_namespace%>/animations/<%animation.name%>/apply_frame'}
269
- $execute store result storage aj:temp frame int 1 run scoreboard players set @s <%OBJECTIVES.FRAME()%> $(frame)
277
+ $execute store result storage aj:temp frame int 1 run scoreboard players set @s <%OBJECTIVES.FRAME(animation.name )%> $(frame)
270
278
execute at @s run function ./zzz/apply_frame with storage aj:temp
271
279
}
272
280
function tween {
@@ -279,12 +287,14 @@ dir <%export_namespace%> {
279
287
280
288
tag @s add <%TAGS.ANIMATION_PLAYING(export_namespace, animation.name)%>
281
289
$scoreboard players set @s <%OBJECTIVES.TWEEN_DURATION()%> $(duration)
282
- $scoreboard players set @s <%OBJECTIVES.FRAME()%> $(to_frame)
290
+ $scoreboard players set @s <%OBJECTIVES.FRAME(animation.name )%> $(to_frame)
283
291
284
292
scoreboard players operation #this <%OBJECTIVES.I()%> = @s <%OBJECTIVES.TWEEN_DURATION()%>
285
293
scoreboard players add @s <%OBJECTIVES.TWEEN_DURATION()%> 1
294
+ tag @s add <%TAGS.TRANSFORMS_ONLY()%>
286
295
execute at @s run function ./zzz/apply_frame {frame: 0}
287
296
$execute at @s run function ./zzz/apply_frame {frame: $(to_frame)}
297
+ tag @s remove <%TAGS.TRANSFORMS_ONLY()%>
288
298
execute on passengers store result entity @s interpolation_duration int 1 run scoreboard players get #this <%OBJECTIVES.I()%>
289
299
}
290
300
dir zzz {
@@ -294,25 +304,25 @@ dir <%export_namespace%> {
294
304
execute if score @s <%OBJECTIVES.TWEEN_DURATION()%> matches 1.. run return 1
295
305
execute if score @s <%OBJECTIVES.TWEEN_DURATION()%> matches 0 on passengers run data modify entity @s interpolation_duration set value <%interpolation_duration%>
296
306
# Animation logic
297
- execute store result storage aj:temp frame int 1 run scoreboard players get @s <%OBJECTIVES.FRAME()%>
307
+ execute store result storage aj:temp frame int 1 run scoreboard players get @s <%OBJECTIVES.FRAME(animation.name )%>
298
308
IF (animation.loopMode === 'loop' && animation.loopDelay === 0) {
299
309
# Makes sure commands in the last frame of the animation is run.
300
- execute if score @s <%OBJECTIVES.FRAME()%> matches -1 run {
310
+ execute if score @s <%OBJECTIVES.FRAME(animation.name )%> matches -1 run {
301
311
function ./apply_frame {frame: <%animation.duration-1%>}
302
- scoreboard players add @s <%OBJECTIVES.FRAME()%> 1
312
+ scoreboard players add @s <%OBJECTIVES.FRAME(animation.name )%> 1
303
313
}
304
314
}
305
315
function ./apply_frame with storage aj:temp
306
316
IF (animation.loopMode === 'loop') {
307
- execute if score @s <%OBJECTIVES.FRAME()%> matches <%animation.duration-2 + animation.loopDelay%>.. run return run {
308
- scoreboard players set @s <%OBJECTIVES.FRAME()%> <%animation.loopDelay === 0 ? -1 : 0%>
317
+ execute if score @s <%OBJECTIVES.FRAME(animation.name )%> matches <%animation.duration-2 + animation.loopDelay%>.. run return run {
318
+ scoreboard players set @s <%OBJECTIVES.FRAME(animation.name )%> <%animation.loopDelay === 0 ? -1 : 0%>
309
319
}
310
320
} ELSE IF (animation.loopMode === 'hold') {
311
- execute if score @s <%OBJECTIVES.FRAME()%> matches <%animation.duration-1%>.. run return run function ../pause
321
+ execute if score @s <%OBJECTIVES.FRAME(animation.name )%> matches <%animation.duration-1%>.. run return run function ../pause
312
322
} ELSE IF (animation.loopMode === 'once') {
313
- execute if score @s <%OBJECTIVES.FRAME()%> matches <%animation.duration-1%> run return run function ../stop
323
+ execute if score @s <%OBJECTIVES.FRAME(animation.name )%> matches <%animation.duration-1%> run return run function ../stop
314
324
}
315
- scoreboard players add @s <%OBJECTIVES.FRAME()%> 1
325
+ scoreboard players add @s <%OBJECTIVES.FRAME(animation.name )%> 1
316
326
}
317
327
IF (use_storage_for_animation) {
318
328
function set_frame {
@@ -366,7 +376,7 @@ dir <%export_namespace%> {
366
376
if (frame.variant) {
367
377
const variant = variants.find(v => v.uuid === frame.variant.uuid)
368
378
if (!variant) return
369
- emit.mcb(`execute on vehicle run function *${export_namespace}/variants/${variant.name}/apply`)
379
+ emit.mcb(`execute on vehicle unless entity @s[tag=<%TAGS.TRANSFORMS_ONLY()%>] run function *${export_namespace}/variants/${variant.name}/apply`)
370
380
}
371
381
global.merged = {
372
382
locators: {},
@@ -406,7 +416,7 @@ dir <%export_namespace%> {
406
416
%%>
407
417
}
408
418
IF (node.commands) {
409
- execute on vehicle <%node.execute_condition ? node.execute_condition.trim() + ' ' : ''%>positioned \
419
+ execute on vehicle unless entity @s[tag=<%TAGS.TRANSFORMS_ONLY()%>] <%node.execute_condition ? node.execute_condition.trim() + ' ' : ''%>positioned \
410
420
^<%roundTo(node.pos[0], 10)%> \
411
421
^<%roundTo(node.pos[1], 10)%> \
412
422
^<%roundTo(node.pos[2], 10)%> \
0 commit comments