Skip to content

Fix variant change in animation with “Use storage for animation” #354

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/systems/datapackCompiler/1.20.4/animation.mcb
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,11 @@ dir <%export_namespace%> {
storage aj.<%export_namespace%>:animations <%animation.safe_name%>.$(frame).<%node.type + '_' + node.safe_name%>
}
}
IF (animation.frames.some(v => v.variant)) {
$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
$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
$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
}
execute on passengers run data modify entity @s[type=!marker] start_interpolation set value -1
}
function apply_frame {
Expand All @@ -378,6 +383,17 @@ dir <%export_namespace%> {
storage aj.<%export_namespace%>:animations <%animation.safe_name%>.$(frame).<%node.type + '_' + node.safe_name%>
}
}
IF (animation.frames.some(v => v.variant)) {
$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
$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
$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
}
}
IF (animation.frames.some(v => v.variant)) {
function apply_variant {
#ARGS: {name: string, condition: string}
$execute $(condition)run function *<%export_namespace%>/variants/$(name)/apply
}
}
} ELSE {
function set_frame {
Expand Down
16 changes: 16 additions & 0 deletions src/systems/datapackCompiler/1.20.5/animation.mcb
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,11 @@ dir <%export_namespace%> {
storage aj.<%export_namespace%>:animations <%animation.safe_name%>.$(frame).<%node.type + '_' + node.safe_name%>
}
}
IF (animation.frames.some(v => v.variant)) {
$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
$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
$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
}
execute on passengers run data modify entity @s[type=!marker] start_interpolation set value -1
}
function apply_frame {
Expand All @@ -378,6 +383,17 @@ dir <%export_namespace%> {
storage aj.<%export_namespace%>:animations <%animation.safe_name%>.$(frame).<%node.type + '_' + node.safe_name%>
}
}
IF (animation.frames.some(v => v.variant)) {
$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
$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
$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
}
}
IF (animation.frames.some(v => v.variant)) {
function apply_variant {
#ARGS: {name: string, condition: string}
$execute $(condition)run function *<%export_namespace%>/variants/$(name)/apply
}
}
} ELSE {
function set_frame {
Expand Down
16 changes: 16 additions & 0 deletions src/systems/datapackCompiler/1.21.2/animation.mcb
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,11 @@ dir <%export_namespace%> {
storage aj.<%export_namespace%>:animations <%animation.safe_name%>.$(frame).<%node.type + '_' + node.safe_name%>
}
}
IF (animation.frames.some(v => v.variant)) {
$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
$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
$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
}
execute on passengers run data modify entity @s[type=!marker] start_interpolation set value -1
}
function apply_frame {
Expand All @@ -378,6 +383,17 @@ dir <%export_namespace%> {
storage aj.<%export_namespace%>:animations <%animation.safe_name%>.$(frame).<%node.type + '_' + node.safe_name%>
}
}
IF (animation.frames.some(v => v.variant)) {
$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
$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
$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
}
}
IF (animation.frames.some(v => v.variant)) {
function apply_variant {
#ARGS: {name: string, condition: string}
$execute $(condition)run function *<%export_namespace%>/variants/$(name)/apply
}
}
} ELSE {
function set_frame {
Expand Down
16 changes: 16 additions & 0 deletions src/systems/datapackCompiler/1.21.4/animation.mcb
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,11 @@ dir <%export_namespace%> {
storage aj.<%export_namespace%>:animations <%animation.safe_name%>.$(frame).<%node.type + '_' + node.safe_name%>
}
}
IF (animation.frames.some(v => v.variant)) {
$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
$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
$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
}
execute on passengers run data modify entity @s[type=!marker] start_interpolation set value -1
}
function apply_frame {
Expand All @@ -378,6 +383,17 @@ dir <%export_namespace%> {
storage aj.<%export_namespace%>:animations <%animation.safe_name%>.$(frame).<%node.type + '_' + node.safe_name%>
}
}
IF (animation.frames.some(v => v.variant)) {
$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
$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
$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
}
}
IF (animation.frames.some(v => v.variant)) {
function apply_variant {
#ARGS: {name: string, condition: string}
$execute $(condition)run function *<%export_namespace%>/variants/$(name)/apply
}
}
} ELSE {
function set_frame {
Expand Down
8 changes: 8 additions & 0 deletions src/systems/datapackCompiler/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,14 @@ async function createAnimationStorage(rig: IRenderedRig, animations: IRenderedAn
)
}
}
if (frame.variant) {
thisFrame.set(
'variant',
new NbtCompound()
.set('name', new NbtString(rig.variants[frame.variant.uuid].name))
.set('condition', new NbtString(frame.variant.execute_condition ? `${frame.variant.execute_condition} ` : ''))
)
}
if (frames.toString().length > 1000000) {
addFrameDataCommand()
}
Expand Down