Skip to content

Commit de1c5ae

Browse files
committed
🧼 Simplify locator and camera data.
- `data.positions.locators` -> `data.locators` - `data.positions.cameras` -> `data.cameras`
1 parent ab7e9d4 commit de1c5ae

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

src/systems/animated_java.mcb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ dir <%export_namespace%> {
163163
}
164164
REPEAT (Object.values(rig.nodeMap).filter(v => v.type === 'locator')) as node {
165165
IF (node.config?.use_entity) {
166-
execute on passengers if entity @s[tag=<%TAGS.PROJECT_DATA(export_namespace)%>] run { with entity @s data.positions.locators.<%node.name%>
166+
execute on passengers if entity @s[tag=<%TAGS.PROJECT_DATA(export_namespace)%>] run { with entity @s data.locators.<%node.name%>
167167
$execute as $(uuid) positioned ^$(posx) ^$(posy) ^$(posz) rotated ~$(roty) ~$(rotx) run {
168168
tp @s ~ ~ ~ ~ ~
169169
<%%
@@ -174,7 +174,7 @@ dir <%export_namespace%> {
174174
}
175175
}
176176
} ELSE IF (node.config?.ticking_commands) {
177-
execute on passengers if entity @s[tag=<%TAGS.PROJECT_DATA(export_namespace)%>] run { with entity @s data.positions.locators.<%node.name%>
177+
execute on passengers if entity @s[tag=<%TAGS.PROJECT_DATA(export_namespace)%>] run { with entity @s data.locators.<%node.name%>
178178
$execute positioned ^$(posx) ^$(posy) ^$(posz) rotated ~$(roty) ~$(rotx) run {
179179
<%%
180180
if (node.config?.ticking_commands) {
@@ -186,7 +186,7 @@ dir <%export_namespace%> {
186186
}
187187
}
188188
REPEAT (Object.values(rig.nodeMap).filter(v => v.type === 'camera')) as node {
189-
execute on passengers if entity @s[tag=<%TAGS.PROJECT_DATA(export_namespace)%>] run { with entity @s data.positions.cameras.<%node.name%>
189+
execute on passengers if entity @s[tag=<%TAGS.PROJECT_DATA(export_namespace)%>] run { with entity @s data.cameras.<%node.name%>
190190
$execute as $(uuid) positioned ^$(posx) ^$(posy) ^$(posz) rotated ~$(roty) ~$(rotx) run tp @s ~ ~ ~ ~ ~
191191
}
192192
}
@@ -382,7 +382,7 @@ dir <%export_namespace%> {
382382
global.rot = getRotationFromQuaternion(node.rot)
383383
%%>
384384
execute on passengers if entity @s[tag=<%TAGS.PROJECT_DATA(export_namespace)%>] run \
385-
data modify entity @s data.positions.locators.<%node.name%> merge value { \
385+
data modify entity @s data.locators.<%node.name%> merge value { \
386386
posx: <%node.pos.x%>, posy: <%node.pos.y%>, posz: <%node.pos.z%>, \
387387
rotx: <%global.rot.x%>, roty: <%global.rot.y%>, \
388388
}
@@ -407,7 +407,7 @@ dir <%export_namespace%> {
407407
global.rot = getRotationFromQuaternion(node.rot)
408408
%%>
409409
execute on passengers if entity @s[tag=<%TAGS.PROJECT_DATA(export_namespace)%>] run \
410-
data modify entity @s data.positions.cameras.<%node.name%> merge value { \
410+
data modify entity @s data.cameras.<%node.name%> merge value { \
411411
posx: <%node.pos.x%>, posy: <%node.pos.y%>, posz: <%node.pos.z%>, \
412412
rotx: <%global.rot.x%>, roty: <%global.rot.y%>, \
413413
}
@@ -456,7 +456,7 @@ dir <%export_namespace%> {
456456

457457
function animated_java:global/internal/gu/convert_uuid_array_to_string with entity @s
458458
execute as @e[type=item_display,tag=<%TAGS.NEW()%>,limit=1,distance=..0.01] on passengers if entity @s[tag=<%TAGS.GLOBAL_DATA()%>] run {
459-
data modify entity @s data.positions.locators.<%locator.name%>.uuid set from storage aj:uuid main.out
459+
data modify entity @s data.locators.<%locator.name%>.uuid set from storage aj:uuid main.out
460460
}
461461
<%%
462462
if (locator.config.summon_commands) {
@@ -474,7 +474,7 @@ dir <%export_namespace%> {
474474

475475
function animated_java:global/internal/gu/convert_uuid_array_to_string with entity @s
476476
execute as @e[type=item_display,tag=<%TAGS.NEW()%>,limit=1,distance=..0.01] on passengers if entity @s[tag=<%TAGS.GLOBAL_DATA()%>] run {
477-
data modify entity @s data.positions.cameras.<%camera.name%>.uuid set from storage aj:uuid main.out
477+
data modify entity @s data.cameras.<%camera.name%>.uuid set from storage aj:uuid main.out
478478
}
479479
}
480480
}
@@ -560,7 +560,7 @@ dir <%export_namespace%> {
560560
$data modify storage aj:temp command set value '$(command)'
561561
execute on passengers if entity @s[tag=<%TAGS.GLOBAL_DATA()%>] run {
562562
REPEAT (Object.values(rig.nodeMap).filter(v => v.type === 'locator')) as locator {
563-
data modify storage aj:temp uuid set from entity @s data.positions.locators.<%locator.name%>.uuid
563+
data modify storage aj:temp uuid set from entity @s data.locators.<%locator.name%>.uuid
564564
block zzz/execute { with storage aj:temp
565565
$execute as $(uuid) run $(command)
566566
}
@@ -585,7 +585,7 @@ dir <%export_namespace%> {
585585

586586
execute on passengers if entity @s[tag=<%TAGS.GLOBAL_DATA()%>] run {
587587
REPEAT (Object.values(rig.nodeMap).filter(v => v.type === 'locator' && v.config?.use_entity)) as locator {
588-
block zzz/kill { with entity @s data.positions.locators.<%locator.name%>
588+
block zzz/kill { with entity @s data.locators.<%locator.name%>
589589
# Recursively remove any stacked locator entities
590590
$execute as $(uuid) run block kill_passengers {
591591
execute on passengers run function ^0

src/systems/datapackCompiler.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ async function generateRootEntityPassengers(rig: IRenderedRig, rigHash: string)
205205
const aj = Project!.animated_java
206206
const passengers: NbtList = new NbtList()
207207

208+
const { locators, cameras } = createPositionStorage(rig)
208209
passengers.add(
209210
new NbtCompound()
210211
.set('id', new NbtString('minecraft:marker'))
@@ -220,7 +221,8 @@ async function generateRootEntityPassengers(rig: IRenderedRig, rigHash: string)
220221
'data',
221222
new NbtCompound()
222223
.set('rigHash', new NbtString(rigHash))
223-
.set('positions', createPositionStorage(rig))
224+
.set('locators', locators)
225+
.set('cameras', cameras)
224226
)
225227
)
226228

@@ -444,11 +446,8 @@ function getRotationFromQuaternion(q: THREE.Quaternion) {
444446
}
445447

446448
function createPositionStorage(rig: IRenderedRig) {
447-
const storage = new NbtCompound()
448449
const locators = new NbtCompound()
449450
const cameras = new NbtCompound()
450-
storage.set('locators', locators)
451-
storage.set('cameras', cameras)
452451
for (const node of Object.values(rig.defaultPose)) {
453452
if (node.type !== 'locator' && node.type !== 'camera') continue
454453
const rot = getRotationFromQuaternion(node.rot)
@@ -463,7 +462,7 @@ function createPositionStorage(rig: IRenderedRig) {
463462
.set('roty', new NbtFloat(Math.radToDeg(rot.y)))
464463
)
465464
}
466-
return storage
465+
return { locators, cameras }
467466
}
468467

469468
function nodeSorter(a: AnyRenderedNode, b: AnyRenderedNode): number {

0 commit comments

Comments
 (0)