Skip to content

Commit b4ab4e6

Browse files
authored
➕ Merge PR #354: Fix variant change in animation with “Use storage for animation”
Fix #353
1 parent 544b88c commit b4ab4e6

File tree

5 files changed

+72
-0
lines changed

5 files changed

+72
-0
lines changed

src/systems/datapackCompiler/1.20.4/animation.mcb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,11 @@ dir <%export_namespace%> {
365365
storage aj.<%export_namespace%>:animations <%animation.safe_name%>.$(frame).<%node.type + '_' + node.safe_name%>
366366
}
367367
}
368+
IF (animation.frames.some(v => v.variant)) {
369+
$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
370+
$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
371+
$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
372+
}
368373
execute on passengers run data modify entity @s[type=!marker] start_interpolation set value -1
369374
}
370375
function apply_frame {
@@ -378,6 +383,17 @@ dir <%export_namespace%> {
378383
storage aj.<%export_namespace%>:animations <%animation.safe_name%>.$(frame).<%node.type + '_' + node.safe_name%>
379384
}
380385
}
386+
IF (animation.frames.some(v => v.variant)) {
387+
$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
388+
$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
389+
$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
390+
}
391+
}
392+
IF (animation.frames.some(v => v.variant)) {
393+
function apply_variant {
394+
#ARGS: {name: string, condition: string}
395+
$execute $(condition)run function *<%export_namespace%>/variants/$(name)/apply
396+
}
381397
}
382398
} ELSE {
383399
function set_frame {

src/systems/datapackCompiler/1.20.5/animation.mcb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,11 @@ dir <%export_namespace%> {
365365
storage aj.<%export_namespace%>:animations <%animation.safe_name%>.$(frame).<%node.type + '_' + node.safe_name%>
366366
}
367367
}
368+
IF (animation.frames.some(v => v.variant)) {
369+
$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
370+
$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
371+
$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
372+
}
368373
execute on passengers run data modify entity @s[type=!marker] start_interpolation set value -1
369374
}
370375
function apply_frame {
@@ -378,6 +383,17 @@ dir <%export_namespace%> {
378383
storage aj.<%export_namespace%>:animations <%animation.safe_name%>.$(frame).<%node.type + '_' + node.safe_name%>
379384
}
380385
}
386+
IF (animation.frames.some(v => v.variant)) {
387+
$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
388+
$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
389+
$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
390+
}
391+
}
392+
IF (animation.frames.some(v => v.variant)) {
393+
function apply_variant {
394+
#ARGS: {name: string, condition: string}
395+
$execute $(condition)run function *<%export_namespace%>/variants/$(name)/apply
396+
}
381397
}
382398
} ELSE {
383399
function set_frame {

src/systems/datapackCompiler/1.21.2/animation.mcb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,11 @@ dir <%export_namespace%> {
365365
storage aj.<%export_namespace%>:animations <%animation.safe_name%>.$(frame).<%node.type + '_' + node.safe_name%>
366366
}
367367
}
368+
IF (animation.frames.some(v => v.variant)) {
369+
$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
370+
$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
371+
$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
372+
}
368373
execute on passengers run data modify entity @s[type=!marker] start_interpolation set value -1
369374
}
370375
function apply_frame {
@@ -378,6 +383,17 @@ dir <%export_namespace%> {
378383
storage aj.<%export_namespace%>:animations <%animation.safe_name%>.$(frame).<%node.type + '_' + node.safe_name%>
379384
}
380385
}
386+
IF (animation.frames.some(v => v.variant)) {
387+
$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
388+
$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
389+
$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
390+
}
391+
}
392+
IF (animation.frames.some(v => v.variant)) {
393+
function apply_variant {
394+
#ARGS: {name: string, condition: string}
395+
$execute $(condition)run function *<%export_namespace%>/variants/$(name)/apply
396+
}
381397
}
382398
} ELSE {
383399
function set_frame {

src/systems/datapackCompiler/1.21.4/animation.mcb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,11 @@ dir <%export_namespace%> {
365365
storage aj.<%export_namespace%>:animations <%animation.safe_name%>.$(frame).<%node.type + '_' + node.safe_name%>
366366
}
367367
}
368+
IF (animation.frames.some(v => v.variant)) {
369+
$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
370+
$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
371+
$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
372+
}
368373
execute on passengers run data modify entity @s[type=!marker] start_interpolation set value -1
369374
}
370375
function apply_frame {
@@ -378,6 +383,17 @@ dir <%export_namespace%> {
378383
storage aj.<%export_namespace%>:animations <%animation.safe_name%>.$(frame).<%node.type + '_' + node.safe_name%>
379384
}
380385
}
386+
IF (animation.frames.some(v => v.variant)) {
387+
$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
388+
$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
389+
$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
390+
}
391+
}
392+
IF (animation.frames.some(v => v.variant)) {
393+
function apply_variant {
394+
#ARGS: {name: string, condition: string}
395+
$execute $(condition)run function *<%export_namespace%>/variants/$(name)/apply
396+
}
381397
}
382398
} ELSE {
383399
function set_frame {

src/systems/datapackCompiler/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,14 @@ async function createAnimationStorage(rig: IRenderedRig, animations: IRenderedAn
554554
)
555555
}
556556
}
557+
if (frame.variant) {
558+
thisFrame.set(
559+
'variant',
560+
new NbtCompound()
561+
.set('name', new NbtString(rig.variants[frame.variant.uuid].name))
562+
.set('condition', new NbtString(frame.variant.execute_condition ? `${frame.variant.execute_condition} ` : ''))
563+
)
564+
}
557565
if (frames.toString().length > 1000000) {
558566
addFrameDataCommand()
559567
}

0 commit comments

Comments
 (0)