Skip to content

Commit 9630f94

Browse files
SnaveSutitgitbutler-client
authored andcommitted
✨ Add Use Entity Stacking option to Blueprint rig settings
1 parent 12c04be commit 9630f94

5 files changed

Lines changed: 141 additions & 82 deletions

File tree

src/formats/blueprint/settings.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export interface BlueprintSettings {
3737
teleportation_duration: number
3838
auto_update_rig_orientation: boolean
3939
use_storage_for_animation: boolean
40+
use_entity_stacking: boolean
4041
// Plugin Settings
4142
baked_animations: boolean
4243
json_file: string
@@ -75,7 +76,7 @@ export const defaultValues: BlueprintSettings = {
7576

7677
auto_update_rig_orientation: true,
7778
use_storage_for_animation: false,
78-
79+
use_entity_stacking: false,
7980
// Plugin Settings
8081
baked_animations: true,
8182
json_file: '',

src/mods/globalCssMod.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,13 @@ dialog.dialog pre:has(code) {
2626
white-space: nowrap !important;
2727
max-width: 75% !important;
2828
}
29+
30+
div.base-sidebar-dialog-item p.description ul {
31+
padding-left: 2em;
32+
}
33+
div.base-sidebar-dialog-item p.description li {
34+
list-style: disc;
35+
}
36+
div.base-sidebar-dialog-item p.description code {
37+
background: var(--color-back);
38+
}

src/systems/datapackCompiler/1.21.4/main.mcb

Lines changed: 64 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,20 @@ dir root {
7070
IF (has_locators || has_cameras) {
7171
function <%blueprint_id%>/root/on_tick/transform_floating_entities
7272
}
73-
74-
block { with storage <%temp_storage%> entry.data.uuids_by_name
75-
REPEAT (Object.values(rig.nodes).filter(node => BONE_TYPES.includes(node.type))) as node {
76-
$tp $(<%node.storage_name%>) ~ ~ ~ ~ ~
77-
# Precise Rotation Workaround. Fixes MC-272913.
78-
# Thanks @Triton365! (https://discord.com/channels/154777837382008833/157097006500806656/1402253905408163842)
79-
$execute \
80-
as $(<%node.storage_name%>) \
81-
store success entity @s OnGround byte 1 \
82-
store success score @s <%OBJECTIVES.I()%> \
83-
unless score @s <%OBJECTIVES.I()%> matches 1
73+
IF (use_entity_stacking) {
74+
execute on passengers run rotate @s ~ ~
75+
} ELSE {
76+
block { with storage <%temp_storage%> entry.data.uuids_by_name
77+
REPEAT (Object.values(rig.nodes).filter(node => BONE_TYPES.includes(node.type))) as node {
78+
$tp $(<%node.storage_name%>) ~ ~ ~ ~ ~
79+
# Precise Rotation Workaround. Fixes MC-272913.
80+
# Thanks @Triton365! (https://discord.com/channels/154777837382008833/157097006500806656/1402253905408163842)
81+
$execute \
82+
as $(<%node.storage_name%>) \
83+
store success entity @s OnGround byte 1 \
84+
store success score @s <%OBJECTIVES.I()%> \
85+
unless score @s <%OBJECTIVES.I()%> matches 1
86+
}
8487
}
8588
}
8689
} ELSE IF (has_ticking_locators) {
@@ -176,17 +179,20 @@ IF (!auto_update_rig_orientation) {
176179
IF (has_locators || has_cameras) {
177180
function <%blueprint_id%>/root/on_tick/transform_floating_entities
178181
}
179-
180-
block { with storage <%temp_storage%> entry.data.uuids_by_name
181-
REPEAT (Object.values(rig.nodes).filter(node => BONE_TYPES.includes(node.type))) as node {
182-
$tp $(<%node.storage_name%>) ~ ~ ~ ~ ~
183-
# Precise Rotation Workaround. Fixes MC-272913.
184-
# Thanks @Triton365! (https://discord.com/channels/154777837382008833/157097006500806656/1402253905408163842)
185-
$execute \
186-
as $(<%node.storage_name%>) \
187-
store success entity @s OnGround byte 1 \
188-
store success score @s <%OBJECTIVES.I()%> \
189-
unless score @s <%OBJECTIVES.I()%> matches 1
182+
IF (use_entity_stacking) {
183+
execute at @s on passengers run rotate @s ~ ~
184+
} ELSE {
185+
block { with storage <%temp_storage%> entry.data.uuids_by_name
186+
REPEAT (Object.values(rig.nodes).filter(node => BONE_TYPES.includes(node.type))) as node {
187+
$tp $(<%node.storage_name%>) ~ ~ ~ ~ ~
188+
# Precise Rotation Workaround. Fixes MC-272913.
189+
# Thanks @Triton365! (https://discord.com/channels/154777837382008833/157097006500806656/1402253905408163842)
190+
$execute \
191+
as $(<%node.storage_name%>) \
192+
store success entity @s OnGround byte 1 \
193+
store success score @s <%OBJECTIVES.I()%> \
194+
unless score @s <%OBJECTIVES.I()%> matches 1
195+
}
190196
}
191197
}
192198
}
@@ -285,13 +291,17 @@ IF (has_animations) {
285291
$execute at @s run function ./zzz/apply_frame {frame: $(to_frame)}
286292
tag @s remove <%TAGS.TRANSFORMS_ONLY()%>
287293

288-
data_manager prep read
289-
block { with storage <%temp_storage%> entry.data.uuids_by_name
290-
REPEAT (Object.values(rig.nodes).filter(node => BONE_TYPES.includes(node.type))) as node {
291-
$execute \
292-
as $(<%node.storage_name%>) \
293-
store result entity @s interpolation_duration int 1 \
294-
run scoreboard players get #this <%OBJECTIVES.I()%>
294+
IF (use_entity_stacking) {
295+
execute on passengers store result entity @s interpolation_duration int 1 run scoreboard players get #this <%OBJECTIVES.I()%>
296+
} ELSE {
297+
data_manager prep read
298+
block { with storage <%temp_storage%> entry.data.uuids_by_name
299+
REPEAT (Object.values(rig.nodes).filter(node => BONE_TYPES.includes(node.type))) as node {
300+
$execute \
301+
as $(<%node.storage_name%>) \
302+
store result entity @s interpolation_duration int 1 \
303+
run scoreboard players get #this <%OBJECTIVES.I()%>
304+
}
295305
}
296306
}
297307
}
@@ -301,12 +311,17 @@ IF (has_animations) {
301311
# Tweening logic
302312
scoreboard players remove @s <%OBJECTIVES.TWEEN_DURATION()%> 1
303313
execute if score @s <%OBJECTIVES.TWEEN_DURATION()%> matches 1.. run return 1
304-
execute if score @s <%OBJECTIVES.TWEEN_DURATION()%> matches 0 run \
305-
block { with storage <%temp_storage%> entry.data.uuids_by_name
306-
REPEAT (Object.values(rig.nodes).filter(node => BONE_TYPES.includes(node.type))) as node {
307-
$data modify entity $(<%node.storage_name%>) interpolation_duration set value <%interpolation_duration%>
314+
IF (use_entity_stacking) {
315+
execute if score @s <%OBJECTIVES.TWEEN_DURATION()%> matches 0 on passengers run \
316+
data modify entity @s interpolation_duration set value <%interpolation_duration%>
317+
} ELSE {
318+
execute if score @s <%OBJECTIVES.TWEEN_DURATION()%> matches 0 run \
319+
block { with storage <%temp_storage%> entry.data.uuids_by_name
320+
REPEAT (Object.values(rig.nodes).filter(node => BONE_TYPES.includes(node.type))) as node {
321+
$data modify entity $(<%node.storage_name%>) interpolation_duration set value <%interpolation_duration%>
322+
}
308323
}
309-
}
324+
}
310325

311326
# Animation logic
312327
IF (animation.loop_mode === 'loop' && animation.loop_delay === 0) {
@@ -356,9 +371,13 @@ IF (has_animations) {
356371
function set_frame {
357372
#ARGS: {frame: int}
358373
$function ./apply_frame {frame: $(frame)}
359-
block { with storage <%temp_storage%> entry.data.uuids_by_name
360-
REPEAT (Object.values(rig.nodes).filter(node => BONE_TYPES.includes(node.type))) as node {
361-
$data modify entity $(<%node.storage_name%>) start_interpolation set value -1
374+
IF (use_entity_stacking) {
375+
execute on passengers run data modify entity @s start_interpolation set value -1
376+
} ELSE {
377+
block { with storage <%temp_storage%> entry.data.uuids_by_name
378+
REPEAT (Object.values(rig.nodes).filter(node => BONE_TYPES.includes(node.type))) as node {
379+
$data modify entity $(<%node.storage_name%>) start_interpolation set value -1
380+
}
362381
}
363382
}
364383
return 1
@@ -398,9 +417,14 @@ IF (has_animations) {
398417

399418
$function ./frames/$(frame) with storage <%temp_storage%> entry.data.uuids_by_name
400419

401-
block { with storage <%temp_storage%> entry.data.uuids_by_name
402-
REPEAT (Object.values(rig.nodes).filter(node => BONE_TYPES.includes(node.type))) as node {
403-
$data modify entity $(<%node.storage_name%>) start_interpolation set value -1
420+
IF (use_entity_stacking) {
421+
execute on passengers run \
422+
data modify entity @s start_interpolation set value -1
423+
} ELSE {
424+
block { with storage <%temp_storage%> entry.data.uuids_by_name
425+
REPEAT (Object.values(rig.nodes).filter(node => BONE_TYPES.includes(node.type))) as node {
426+
$data modify entity $(<%node.storage_name%>) start_interpolation set value -1
427+
}
404428
}
405429
}
406430

src/systems/datapackCompiler/1.21.5/main.mcb

Lines changed: 64 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,20 @@ dir root {
6969
IF (has_locators || has_cameras) {
7070
function <%blueprint_id%>/root/on_tick/transform_floating_entities
7171
}
72-
73-
block { with storage <%temp_storage%> entry.data.uuids_by_name
74-
REPEAT (Object.values(rig.nodes).filter(node => BONE_TYPES.includes(node.type))) as node {
75-
$tp $(<%node.storage_name%>) ~ ~ ~ ~ ~
76-
# Precise Rotation Workaround. Fixes MC-272913.
77-
# Thanks @Triton365! (https://discord.com/channels/154777837382008833/157097006500806656/1402253905408163842)
78-
$execute \
79-
as $(<%node.storage_name%>) \
80-
store success entity @s OnGround byte 1 \
81-
store success score @s <%OBJECTIVES.I()%> \
82-
unless score @s <%OBJECTIVES.I()%> matches 1
72+
IF (use_entity_stacking) {
73+
execute on passengers run rotate @s ~ ~
74+
} ELSE {
75+
block { with storage <%temp_storage%> entry.data.uuids_by_name
76+
REPEAT (Object.values(rig.nodes).filter(node => BONE_TYPES.includes(node.type))) as node {
77+
$tp $(<%node.storage_name%>) ~ ~ ~ ~ ~
78+
# Precise Rotation Workaround. Fixes MC-272913.
79+
# Thanks @Triton365! (https://discord.com/channels/154777837382008833/157097006500806656/1402253905408163842)
80+
$execute \
81+
as $(<%node.storage_name%>) \
82+
store success entity @s OnGround byte 1 \
83+
store success score @s <%OBJECTIVES.I()%> \
84+
unless score @s <%OBJECTIVES.I()%> matches 1
85+
}
8386
}
8487
}
8588
} ELSE IF (has_ticking_locators) {
@@ -175,17 +178,20 @@ IF (!auto_update_rig_orientation) {
175178
IF (has_locators || has_cameras) {
176179
function <%blueprint_id%>/root/on_tick/transform_floating_entities
177180
}
178-
179-
block { with storage <%temp_storage%> entry.data.uuids_by_name
180-
REPEAT (Object.values(rig.nodes).filter(node => BONE_TYPES.includes(node.type))) as node {
181-
$tp $(<%node.storage_name%>) ~ ~ ~ ~ ~
182-
# Precise Rotation Workaround. Fixes MC-272913.
183-
# Thanks @Triton365! (https://discord.com/channels/154777837382008833/157097006500806656/1402253905408163842)
184-
$execute \
185-
as $(<%node.storage_name%>) \
186-
store success entity @s OnGround byte 1 \
187-
store success score @s <%OBJECTIVES.I()%> \
188-
unless score @s <%OBJECTIVES.I()%> matches 1
181+
IF (use_entity_stacking) {
182+
execute at @s on passengers run rotate @s ~ ~
183+
} ELSE {
184+
block { with storage <%temp_storage%> entry.data.uuids_by_name
185+
REPEAT (Object.values(rig.nodes).filter(node => BONE_TYPES.includes(node.type))) as node {
186+
$tp $(<%node.storage_name%>) ~ ~ ~ ~ ~
187+
# Precise Rotation Workaround. Fixes MC-272913.
188+
# Thanks @Triton365! (https://discord.com/channels/154777837382008833/157097006500806656/1402253905408163842)
189+
$execute \
190+
as $(<%node.storage_name%>) \
191+
store success entity @s OnGround byte 1 \
192+
store success score @s <%OBJECTIVES.I()%> \
193+
unless score @s <%OBJECTIVES.I()%> matches 1
194+
}
189195
}
190196
}
191197
}
@@ -284,13 +290,17 @@ IF (has_animations) {
284290
$execute at @s run function ./zzz/apply_frame {frame: $(to_frame)}
285291
tag @s remove <%TAGS.TRANSFORMS_ONLY()%>
286292

287-
data_manager prep read
288-
block { with storage <%temp_storage%> entry.data.uuids_by_name
289-
REPEAT (Object.values(rig.nodes).filter(node => BONE_TYPES.includes(node.type))) as node {
290-
$execute \
291-
as $(<%node.storage_name%>) \
292-
store result entity @s interpolation_duration int 1 \
293-
run scoreboard players get #this <%OBJECTIVES.I()%>
293+
IF (use_entity_stacking) {
294+
execute on passengers store result entity @s interpolation_duration int 1 run scoreboard players get #this <%OBJECTIVES.I()%>
295+
} ELSE {
296+
data_manager prep read
297+
block { with storage <%temp_storage%> entry.data.uuids_by_name
298+
REPEAT (Object.values(rig.nodes).filter(node => BONE_TYPES.includes(node.type))) as node {
299+
$execute \
300+
as $(<%node.storage_name%>) \
301+
store result entity @s interpolation_duration int 1 \
302+
run scoreboard players get #this <%OBJECTIVES.I()%>
303+
}
294304
}
295305
}
296306
}
@@ -300,12 +310,17 @@ IF (has_animations) {
300310
# Tweening logic
301311
scoreboard players remove @s <%OBJECTIVES.TWEEN_DURATION()%> 1
302312
execute if score @s <%OBJECTIVES.TWEEN_DURATION()%> matches 1.. run return 1
303-
execute if score @s <%OBJECTIVES.TWEEN_DURATION()%> matches 0 run \
304-
block { with storage <%temp_storage%> entry.data.uuids_by_name
305-
REPEAT (Object.values(rig.nodes).filter(node => BONE_TYPES.includes(node.type))) as node {
306-
$data modify entity $(<%node.storage_name%>) interpolation_duration set value <%interpolation_duration%>
313+
IF (use_entity_stacking) {
314+
execute if score @s <%OBJECTIVES.TWEEN_DURATION()%> matches 0 on passengers run \
315+
data modify entity @s interpolation_duration set value <%interpolation_duration%>
316+
} ELSE {
317+
execute if score @s <%OBJECTIVES.TWEEN_DURATION()%> matches 0 run \
318+
block { with storage <%temp_storage%> entry.data.uuids_by_name
319+
REPEAT (Object.values(rig.nodes).filter(node => BONE_TYPES.includes(node.type))) as node {
320+
$data modify entity $(<%node.storage_name%>) interpolation_duration set value <%interpolation_duration%>
321+
}
307322
}
308-
}
323+
}
309324

310325
# Animation logic
311326
IF (animation.loop_mode === 'loop' && animation.loop_delay === 0) {
@@ -355,9 +370,13 @@ IF (has_animations) {
355370
function set_frame {
356371
#ARGS: {frame: int}
357372
$function ./apply_frame {frame: $(frame)}
358-
block { with storage <%temp_storage%> entry.data.uuids_by_name
359-
REPEAT (Object.values(rig.nodes).filter(node => BONE_TYPES.includes(node.type))) as node {
360-
$data modify entity $(<%node.storage_name%>) start_interpolation set value -1
373+
IF (use_entity_stacking) {
374+
execute on passengers run data modify entity @s start_interpolation set value -1
375+
} ELSE {
376+
block { with storage <%temp_storage%> entry.data.uuids_by_name
377+
REPEAT (Object.values(rig.nodes).filter(node => BONE_TYPES.includes(node.type))) as node {
378+
$data modify entity $(<%node.storage_name%>) start_interpolation set value -1
379+
}
361380
}
362381
}
363382
return 1
@@ -397,9 +416,14 @@ IF (has_animations) {
397416

398417
$function ./frames/$(frame) with storage <%temp_storage%> entry.data.uuids_by_name
399418

400-
block { with storage <%temp_storage%> entry.data.uuids_by_name
401-
REPEAT (Object.values(rig.nodes).filter(node => BONE_TYPES.includes(node.type))) as node {
402-
$data modify entity $(<%node.storage_name%>) start_interpolation set value -1
419+
IF (use_entity_stacking) {
420+
execute on passengers run \
421+
data modify entity @s start_interpolation set value -1
422+
} ELSE {
423+
block { with storage <%temp_storage%> entry.data.uuids_by_name
424+
REPEAT (Object.values(rig.nodes).filter(node => BONE_TYPES.includes(node.type))) as node {
425+
$data modify entity $(<%node.storage_name%>) start_interpolation set value -1
426+
}
403427
}
404428
}
405429

src/systems/datapackCompiler/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,6 @@ const dataPackCompiler: DataPackCompiler = async ({
547547
TextComponent.defaultMinecraftVersion = version
548548

549549
const aj = Project!.animated_java
550-
const isStatic = animations.length === 0
551550

552551
const parsed = parseResourceLocation(aj.blueprint_id)
553552
const relativePathToSrc = parsed.path
@@ -603,6 +602,7 @@ const dataPackCompiler: DataPackCompiler = async ({
603602
data_storage: `animated_java:data`,
604603
auto_update_rig_orientation: aj.auto_update_rig_orientation,
605604
debug_mode: debugMode,
605+
use_entity_stacking: aj.use_entity_stacking,
606606
}
607607

608608
const mcbFiles = getMCBFilesByVersion(version)

0 commit comments

Comments
 (0)