Skip to content

Commit

Permalink
Fix 45-degree alignment
Browse files Browse the repository at this point in the history
- Utilising a wrapper bone on which the position and rotation alignment animations are applied as a parent for the root bone with the offset animation, an offset with an armour stand placed at 45-degree angles will be properly axis-aligned
- Bounding box outline particles are now emitted at the hologram root, meaning that they inherit the offset and rotation of the hologram.
- The block validation wrong block overlay also has an alignment wrapper parent, to which animations are applied. Unfortunately, since the wrong block overlay is in a different geometry than the rest of the hologram, we can't set its parent to be the hologram root and as such animations must be separately defined for it.
- Also slightly optimised Molang
  • Loading branch information
SuperLlama88888 committed Oct 11, 2024
1 parent 4c2a127 commit 54a9847
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 10 deletions.
12 changes: 5 additions & 7 deletions HoloPrint.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ export default class HoloPrint {
t.hologram_offset_x ??= 0;
t.hologram_offset_y ??= 0;
t.hologram_offset_z ??= 0;
t.structure_w = $[structureSize[0]];
t.structure_h = $[structureSize[1]];
t.structure_d = $[structureSize[2]];
if(q.distance_from_camera <= 10) {
t.render_hologram = true;
t.hologram_layer = -1;
Expand All @@ -170,9 +173,6 @@ export default class HoloPrint {
t.wrong_block_x = 0;
t.wrong_block_y = 0;
t.wrong_block_z = 0;
t.structure_w = $[structureSize[0]];
t.structure_h = $[structureSize[1]];
t.structure_d = $[structureSize[2]];
} else {
t.render_hologram ??= true;
t.hologram_layer ??= -1;
Expand All @@ -181,9 +181,6 @@ export default class HoloPrint {
t.wrong_block_x ??= 0;
t.wrong_block_y ??= 0;
t.wrong_block_z ??= 0;
t.structure_w ??= $[structureSize[0]];
t.structure_h ??= $[structureSize[1]];
t.structure_d ??= $[structureSize[2]];
}
}, { structureSize })); // particles need to access structure dimensions later, but their `v.` scope is different to the armour stand's, so these have to be temp variables.
entityDescription["geometry"]["hologram"] = "geometry.armor_stand.hologram";
Expand Down Expand Up @@ -221,7 +218,8 @@ export default class HoloPrint {
let particleName = `bounding_box_outline_${i}`;
entityDescription["particle_effects"][particleName] = `holoprint:${particleName}`;
hologramAnimationControllers["animation_controllers"]["controller.animation.armor_stand.hologram.bounding_box"]["states"]["default"]["particle_effects"].push({
"effect": particleName
"effect": particleName,
"locator": "hologram_root"
});
});

Expand Down
21 changes: 20 additions & 1 deletion packTemplate/animations/armor_stand.hologram.animation.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ I also wonder if we could have a "rotation lock" option which makes the hologram
"animation.armor_stand.hologram.align": {
"loop": "hold_on_last_frame",
"bones": {
"hologram_root": {
"hologram_alignment_wrapper": {
"position": [
// Snap to nearest block. Unfortunately looks glitchy when moving since it takes a tick for the position to update.
// x and z of armor stands is +0.5
Expand All @@ -26,6 +26,18 @@ I also wonder if we could have a "rotation lock" option which makes the hologram
"-(q.body_y_rotation - 90 * math.floor(q.body_y_rotation / 90))", // Snap to 90-deg directions
0
]
},
"wrong_block_overlay_alignment_wrapper": {
"position": [
0,
"-16 * (q.position(1) - math.floor(q.position(1)))",
0
],
"rotation": [
0,
"-(q.body_y_rotation - 90 * math.floor(q.body_y_rotation / 90))",
0
]
}
}
},
Expand All @@ -38,6 +50,13 @@ I also wonder if we could have a "rotation lock" option which makes the hologram
"t.hologram_offset_y * 16",
"t.hologram_offset_z * 16"
]
},
"wrong_block_overlay": {
"position": [
"t.hologram_offset_x * 16",
"t.hologram_offset_y * 16",
"t.hologram_offset_z * 16"
]
}
}
},
Expand Down
12 changes: 11 additions & 1 deletion packTemplate/models/entity/armor_stand.hologram.geo.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@
"visible_bounds_offset": [0, 1.5, 0] // do we need this?!
},
"bones": [
{
"name": "hologram_alignment_wrapper"
},
{
"name": "hologram_root",
"pivot": [0, 0, 0]
"parent": "hologram_alignment_wrapper",
"locators": {
"hologram_root": [0, 0, 0]
}
}
]
},
Expand All @@ -20,8 +26,12 @@
"texture_height": 16
},
"bones": [
{
"name": "wrong_block_overlay_alignment_wrapper"
},
{
"name": "wrong_block_overlay",
"parent": "wrong_block_overlay_alignment_wrapper",
"cubes": [
{
"origin": [-8, 0, -8],
Expand Down
2 changes: 1 addition & 1 deletion packTemplate/particles/bounding_box_outline.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"expiration_expression": "!t.render_hologram"
},
"minecraft:particle_motion_parametric": {
"relative_position": ["(v.x ?? (v.dir == 0? v.size : 0)) - 0.5 - t.hologram_offset_x", "(v.y ?? v.dir == 1? v.size : 0) + math.floor(q.position(1)) - q.position(1) + t.hologram_offset_y", "(v.z ?? (v.dir == 2? v.size : 0)) - 0.5 + t.hologram_offset_z"] // we need to apply the y-snapping and offset here as well.
"relative_position": ["-(v.x ?? (v.dir == 0? v.size : 0)) + 0.5", "-(v.y ?? v.dir == 1? v.size : 0)", "(v.z ?? (v.dir == 2? v.size : 0)) - 0.5"]
},
"minecraft:particle_appearance_billboard": {
"size": ["v.size", 0.01],
Expand Down

0 comments on commit 54a9847

Please sign in to comment.