Skip to content

Commit ea9db3b

Browse files
committed
Fixes and framerate
- Fixed animFlag being set to the entity that runs the summon command instead of the root entity - Added .aj.projectName.framerate fakeplayer for controlling animation playback speed
1 parent 460269a commit ea9db3b

File tree

2 files changed

+237
-12
lines changed

2 files changed

+237
-12
lines changed

debug_resourcepack/armor_stand.ajmodel

Lines changed: 224 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"meta": {
33
"format_version": "0.0",
4-
"creation_time": 1643268841,
4+
"creation_time": 1643546437,
55
"model_format": "animated_java/ajmodel",
66
"box_uv": false,
77
"settings": {
@@ -1971,6 +1971,229 @@
19711971
]
19721972
}
19731973
}
1974+
},
1975+
{
1976+
"uuid": "2d2afa82-f54b-f046-ab74-1ee995afdc8a",
1977+
"name": "assemble",
1978+
"loop": "hold",
1979+
"override": false,
1980+
"length": 3.5,
1981+
"snapping": 20,
1982+
"selected": true,
1983+
"saved": false,
1984+
"path": "",
1985+
"anim_time_update": "",
1986+
"blend_weight": "",
1987+
"start_delay": "",
1988+
"loop_delay": "",
1989+
"animators": {
1990+
"fdba905d-125a-46b9-bada-bbc88aedd04a": {
1991+
"name": "body",
1992+
"type": "bone",
1993+
"keyframes": [
1994+
{
1995+
"channel": "position",
1996+
"data_points": [
1997+
{
1998+
"x": "0",
1999+
"y": "0",
2000+
"z": "0"
2001+
}
2002+
],
2003+
"uuid": "6b03f211-1e10-1524-44cd-386b38aeedd0",
2004+
"time": 0,
2005+
"color": -1,
2006+
"interpolation": "linear"
2007+
},
2008+
{
2009+
"channel": "position",
2010+
"data_points": [
2011+
{
2012+
"x": 0,
2013+
"y": 0,
2014+
"z": -2
2015+
}
2016+
],
2017+
"uuid": "055e6ff4-88e3-0dd6-c885-52723e04a81f",
2018+
"time": 0.5,
2019+
"color": -1,
2020+
"interpolation": "linear"
2021+
},
2022+
{
2023+
"channel": "position",
2024+
"data_points": [
2025+
{
2026+
"x": 0,
2027+
"y": -11,
2028+
"z": -2
2029+
}
2030+
],
2031+
"uuid": "22b456d1-4bb2-2c8a-b617-0218f68dd5ff",
2032+
"time": 2,
2033+
"color": -1,
2034+
"interpolation": "linear"
2035+
}
2036+
]
2037+
},
2038+
"cb964881-91e1-bd1c-6502-b1236f581c6a": {
2039+
"name": "head",
2040+
"type": "bone",
2041+
"keyframes": [
2042+
{
2043+
"channel": "rotation",
2044+
"data_points": [
2045+
{
2046+
"x": 37.5,
2047+
"y": 0,
2048+
"z": 0
2049+
}
2050+
],
2051+
"uuid": "f5eb25e3-f8a6-c010-e13b-451592a1b4bb",
2052+
"time": 3.5,
2053+
"color": -1,
2054+
"interpolation": "linear"
2055+
},
2056+
{
2057+
"channel": "rotation",
2058+
"data_points": [
2059+
{
2060+
"x": "0",
2061+
"y": 0,
2062+
"z": 0
2063+
}
2064+
],
2065+
"uuid": "a4d651ab-bbb2-90a4-b3ba-940c3f4fa9ca",
2066+
"time": 3,
2067+
"color": -1,
2068+
"interpolation": "linear"
2069+
},
2070+
{
2071+
"channel": "position",
2072+
"data_points": [
2073+
{
2074+
"x": "0",
2075+
"y": "0",
2076+
"z": "0"
2077+
}
2078+
],
2079+
"uuid": "7bf2b6d5-d94c-36f2-1392-8246a9756ada",
2080+
"time": 2,
2081+
"color": -1,
2082+
"interpolation": "linear"
2083+
},
2084+
{
2085+
"channel": "position",
2086+
"data_points": [
2087+
{
2088+
"x": 0,
2089+
"y": 0,
2090+
"z": 2
2091+
}
2092+
],
2093+
"uuid": "5f00c9de-89d4-07ec-9654-b75edd1196e7",
2094+
"time": 2.5,
2095+
"color": -1,
2096+
"interpolation": "linear"
2097+
}
2098+
]
2099+
},
2100+
"2e341d64-7a7d-ef4c-b582-f153fe280eaa": {
2101+
"name": "left_arm",
2102+
"type": "bone",
2103+
"keyframes": [
2104+
{
2105+
"channel": "position",
2106+
"data_points": [
2107+
{
2108+
"x": "0",
2109+
"y": "0",
2110+
"z": "0"
2111+
}
2112+
],
2113+
"uuid": "e306a87f-a018-1e37-1e11-e6f964ee8e23",
2114+
"time": 2,
2115+
"color": -1,
2116+
"interpolation": "linear"
2117+
},
2118+
{
2119+
"channel": "position",
2120+
"data_points": [
2121+
{
2122+
"x": 0,
2123+
"y": 0,
2124+
"z": 2
2125+
}
2126+
],
2127+
"uuid": "f093f25d-d5bd-0dc5-b8ff-3dbd9e58207e",
2128+
"time": 2.5,
2129+
"color": -1,
2130+
"interpolation": "linear"
2131+
},
2132+
{
2133+
"channel": "position",
2134+
"data_points": [
2135+
{
2136+
"x": -2,
2137+
"y": 0,
2138+
"z": 2
2139+
}
2140+
],
2141+
"uuid": "68f916b2-bc91-2ad5-d586-369f28091811",
2142+
"time": 3,
2143+
"color": -1,
2144+
"interpolation": "linear"
2145+
}
2146+
]
2147+
},
2148+
"984fb351-e168-0caa-8538-20c2ee83dd2b": {
2149+
"name": "right_arm",
2150+
"type": "bone",
2151+
"keyframes": [
2152+
{
2153+
"channel": "position",
2154+
"data_points": [
2155+
{
2156+
"x": 0,
2157+
"y": "0",
2158+
"z": "0"
2159+
}
2160+
],
2161+
"uuid": "c4e70a7d-d903-21c7-f570-aedec2bf4d32",
2162+
"time": 2,
2163+
"color": -1,
2164+
"interpolation": "linear"
2165+
},
2166+
{
2167+
"channel": "position",
2168+
"data_points": [
2169+
{
2170+
"x": 0,
2171+
"y": 0,
2172+
"z": 2
2173+
}
2174+
],
2175+
"uuid": "f9bbdc3d-735a-c494-d10c-58d47df93ee4",
2176+
"time": 2.5,
2177+
"color": -1,
2178+
"interpolation": "linear"
2179+
},
2180+
{
2181+
"channel": "position",
2182+
"data_points": [
2183+
{
2184+
"x": 2,
2185+
"y": 0,
2186+
"z": 2
2187+
}
2188+
],
2189+
"uuid": "b6973120-3a1b-0ca0-a2fc-4485b8df912d",
2190+
"time": 3,
2191+
"color": -1,
2192+
"interpolation": "linear"
2193+
}
2194+
]
2195+
}
2196+
}
19742197
}
19752198
]
19762199
}

src/exporters/animationExporter.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ async function createMCFile(
257257
.join('\n')}
258258
function ${projectName}:reset_animation_flags
259259
scoreboard players set #uninstall ${scoreboards.internal} 0
260+
scoreboard players set .aj.${projectName}.framerate ${scoreboards.internal} 1
260261
tellraw @a ${installJsonText}
261262
}
262263
`)
@@ -627,9 +628,10 @@ async function createMCFile(
627628
${Object.values(animations).map(
628629
v => `scoreboard players set @s ${scoreboards.animationLoopMode.replace('%animationName',v.name)} ${loopModeIDs.indexOf(v.loopMode)}`
629630
).join('\n')}
631+
scoreboard players set @s ${scoreboards.frame} 0
632+
scoreboard players set @s ${scoreboards.animatingFlag} 0
630633
}
631634
# Assert animation flags
632-
scoreboard players set @s ${scoreboards.animatingFlag} 0
633635
function ${projectName}:assert_animation_flags
634636
}
635637
`)
@@ -1018,28 +1020,28 @@ async function createMCFile(
10181020
` : ''}
10191021
10201022
# Increment frame
1021-
scoreboard players add @s ${scoreboards.frame} 1
1023+
scoreboard players operation @s ${scoreboards.frame} += .aj.${projectName}.framerate ${scoreboards.internal}
10221024
# Let the anim_loop know we're still running
10231025
scoreboard players set .aj.animation ${scoreboards.animatingFlag} 1
10241026
# If (the next frame is the end of the animation) perform the necessary actions for the loop mode of the animation
1025-
execute if score @s ${scoreboards.frame} matches ${animation.frames.length}.. run function ${projectName}:animations/${animation.name}/end
1027+
execute unless score @s ${scoreboards.frame} matches 1..${animation.frames.length} run function ${projectName}:animations/${animation.name}/edge
10261028
}`
10271029
)
10281030

10291031
// prettier-ignore
10301032
FILE.push(`# Performs a loop mode action depending on what the animation's configured loop mode is
1031-
function end {
1033+
function edge {
10321034
# Play Once
1033-
execute if score @s ${thisAnimationLoopMode} matches 0 run {
1034-
function ${projectName}:animations/${animation.name}/stop
1035-
}
1035+
execute if score @s ${thisAnimationLoopMode} matches 0 run function ${projectName}:animations/${animation.name}/stop
10361036
# Hold on last frame
1037-
execute if score @s ${thisAnimationLoopMode} matches 1 run {
1038-
function ${projectName}:animations/${animation.name}/pause
1039-
}
1037+
execute if score @s ${thisAnimationLoopMode} matches 1 run function ${projectName}:animations/${animation.name}/pause
10401038
# loop
10411039
execute if score @s ${thisAnimationLoopMode} matches 2 run {
1042-
scoreboard players set @s ${scoreboards.frame} 0
1040+
execute (if score @s ${scoreboards.frame} matches ..1) {
1041+
scoreboard players set @s ${scoreboards.frame} ${animation.frames.length}
1042+
} else {
1043+
scoreboard players set @s ${scoreboards.frame} 0
1044+
}
10431045
}
10441046
}
10451047
`)

0 commit comments

Comments
 (0)