#Using q.bone_orientation_trs to define a variable inside the player's molang variables

1 messages ยท Page 1 of 1 (latest)

rocky badge
#

This is an odd situation, but my goal is to get the transformation of a bone of minecraft:player in a way where it is defined in a variable that overrides the player's molang variables for me to access. I've tried straight up overriding a variable in pre_animation, but molang complained about not finding a queryable bone. The next thing I tried was to define it in attachments and then reference it, but molang still complained about not finding a bone and that a variable was undefined.

#

The end goal is to have a variable defined by the player to be a pointer to the bone's transformation, since in my case I can only access the player's molang variables.

#

I have not tried temp leaking yet.

vivid cedar
#

That query alongside others dont really work well in the player file from my testing.

rocky badge
#

I was hoping there was some loophole where an environment that allows that query makes it doable

vivid cedar
#

I was thinking of the locator molang, apologies.

rocky badge
rocky badge
#

thank you, ill try it

rocky badge
# vivid cedar Yes.

Seems to give me the same error: ```
[Molang][error]-minecraft:player.0.aaaaaaaa-7b21-4637-9b63-8ad63622ef01.8dcf7264-3d21-45ac-9693-ad89f05c0198 | entity/player.entity.json | v.is_rendered ? {v.rightarm = q.bone_orientation_trs('rightarm'); v.map_angle = v.rightarm.r.x;};v.is_rendered = true;variable.helmet_layer_visible = !query.has_head_gear;variable.leg_layer_visible = 1.0;variable.boot_layer_visible = 1.0;variable.chest_layer_visible = 1.0;variable.attack_body_rot_y = math.sin(360*math.sqrt(variable.attack_time)) * 5.0;variable.tcos0 = (math.cos(query.modified_distance_moved * 38.17) * query.modified_move_speed / variable.gliding_speed_value) * 57.3;variable.first_person_rotation_factor = math.sin((1 - variable.attack_time) * 180.0);variable.hand_bob = query.life_time < 0.01 ? 0.0 : variable.hand_bob + ((query.is_on_ground && query.is_alive ? math.clamp(math.sqrt(math.pow(query.position_delta(0), 2.0) + math.pow(query.position_delta(2), 2.0)), 0.0, 0.1) : 0.0) - variable.hand_bob) * 0.02;variable.map_angle = math.clamp(1 - variable.player_x_rotation / 45.1, 0.0, 1.0);variable.item_use_normalized = query.main_hand_item_use_duration / query.main_hand_item_max_duration;variable.riding_y_offset = query.is_riding_any_entity_of_type('minecraft:minecart', 'minecraft:boat', 'minecraft:chest_boat', 'minecraft:strider') ? -3.0 : 0.0; | query.bone_orientation_trs couldn't find the specified bone in the current entity's queryable geometry.

#

@fathom crypt im just going to ping you here since it was your method, wondering if you could help as well

vivid cedar
#

initialize

"v.trs_struct.t.x = 0; v.trs_struct.t.y = 0; v.trs_struct.t.z = 0;",
          "v.trs_struct.r.x = 0; v.trs_struct.r.y = 0; v.trs_struct.r.z = 0;",
          "v.trs_struct.s.x = 0; v.trs_struct.s.y = 0; v.trs_struct.s.z = 0;",
          "v.body = v.trs_struct;",
 "v.is_rendered = false;"

pre anim

 "v.is_rendered ? {v.body = q.bone_orientation_trs('rightItem');};",
          "v.is_rendered = true;",
#

This is what I had.

#

I also had this

        "variables": {
          "variable.body": "public"
        },
vivid cedar
rocky badge
#

where should I move it?

vivid cedar
#

Right after v.is_rendered=true;

#

So in your case.

"v.is_rendered ? {v.rightarm = q.bone_orientation_trs('rightarm');};",
"v.is_rendered = true;",
 v.map_angle = v.rightarm.r.x;
rocky badge
#

okay ill try that

#

also added the public variable

#

ill try to copy what you had exactly

vivid cedar
#

Can you do rightItem instead?

rocky badge
#

sure ill try that

vivid cedar
#

Now I unfortunately cannot share the full code I had working since it's NDA. However, I did use

v.offset_x=c.owning_entity->v.body.t.x;
          v.offset_y=c.owning_entity->v.body.t.y;
          v.offset_z=c.owning_entity->v.body.t.z;
``` in an animation file.
rocky badge
#
        "initialize": [
          "variable.is_holding_right = 0.0;",
          "variable.is_blinking = 0.0;",
          "variable.last_blink_time = 0.0;",
          "variable.hand_bob = 0.0;",

          "v.trs_struct.t.x = 0; v.trs_struct.t.y = 0; v.trs_struct.t.z = 0;",
          "v.trs_struct.r.x = 0; v.trs_struct.r.y = 0; v.trs_struct.r.z = 0;",
          "v.trs_struct.s.x = 0; v.trs_struct.s.y = 0; v.trs_struct.s.z = 0;",

          "v.body = v.trs_struct;",
          "v.is_rendered = false;"
        ],
        "pre_animation": [
          "variable.helmet_layer_visible = !query.has_head_gear;",
          "variable.leg_layer_visible = 1.0;",
          "variable.boot_layer_visible = 1.0;",
          "variable.chest_layer_visible = 1.0;",
          "variable.attack_body_rot_y = Math.sin(360*Math.sqrt(variable.attack_time)) * 5.0;",
          "variable.tcos0 = (math.cos(query.modified_distance_moved * 38.17) * query.modified_move_speed / variable.gliding_speed_value) * 57.3;",
          "variable.first_person_rotation_factor = math.sin((1 - variable.attack_time) * 180.0);",
          "variable.hand_bob = query.life_time < 0.01 ? 0.0 : variable.hand_bob + ((query.is_on_ground && query.is_alive ? math.clamp(math.sqrt(math.pow(query.position_delta(0), 2.0) + math.pow(query.position_delta(2), 2.0)), 0.0, 0.1) : 0.0) - variable.hand_bob) * 0.02;",
          "variable.map_angle = math.clamp(1 - variable.player_x_rotation / 45.1, 0.0, 1.0);",
          "variable.item_use_normalized = query.main_hand_item_use_duration / query.main_hand_item_max_duration;",
          "variable.riding_y_offset = query.is_riding_any_entity_of_type('minecraft:minecart', 'minecraft:boat', 'minecraft:chest_boat', 'minecraft:strider') ? -3.0 : 0.0;",

          "v.is_rendered ? {v.body = q.bone_orientation_trs('rightItem');};",
          "v.is_rendered = true;"
        ],
#
v.is_rendered ? {v.body = q.bone_orientation_trs('rightitem');};v.is_rendered = true; | query.bone_orientation_trs couldn't find the specified bone in the current entity's queryable geometry.
``` again same error
vivid cedar
#

That's so weird, I wonder if adding "min_engine_version": "1.12.0", works. That's the only difference I have that your file doesn't.

rocky badge
#

ill try it just because

#

where do I add it?

#

at the top?

vivid cedar
#

I put it under the identifier

rocky badge
#

yeah no its still erroring, so weird

vivid cedar
#

This is what I had. I do wonder if it is due to a custom geometry.

rocky badge
#

do you think that I should like include the humanoid_custom.geo file in my resource pack or

#

change it somehow

vivid cedar
#

Does using this on a pig work?

#

If that works, then do try a custom geometry.

rocky badge
#

interestingly when using it on a pig nothing errors

#

I copied everything exactly, so should I just like edit the humanoid_custom geometry metadata or something to match the pig?

vivid cedar
#

Ok, so neither of us were crazy, just Mojang moment ๐Ÿ˜‚

rocky badge
#

but wait that makes no sense

#

rightItem is correct

#

but doesnt work

vivid cedar
#

Can you copy pase the current model that vanilla uses but change the id and make your player entity use that new model?

rocky badge
#

do i change this?

vivid cedar
#

Yeah, I would copy the vanilla model into your pack, change the id and make the player use that.

rocky badge
#

i made it geometry.custom_model.player, what should I set the filename?

#

custom_model.player.geo?

#

After all of that including changing the identifiers, filename, geometry, etc, it still errors saying the bone isnt found

#

resource packs really are very particular in what they want

vivid cedar
#

That's so weird :/ everything looks the same. @rocky badge , what if you made the player use the pig model instead?

rocky badge
#

ill try that i guess

#

tried that and edited this, all it did was change my skin to steve, break my animations, and give the same error

thorn lily
#

Try it on a non-player entity, to eliminate the possibility of it being broken specifically for players. Also, sometimes you have to wait longer than 1 frame for that query to work, so content log is not an indication that it's not working. You can also add "queryable_geometry": "default" to change which geo that query operates on, but it should be default by default. Also query.bone_orientation_trs(...).r.x stuff like this doesn't work and you have to set it to a variable and only then extract struct members v.example = query.bone_orientation_trs(...); t.foo = v.example.r.x;

fathom crypt
#

Try it on a non-player entity, to eliminate the possibility of it being broken specifically for players

@rocky badge did try it on a pig entity, and it did not throw errors.
It may be that the player model is overwritten or changed a few ticks after loading, with all the persona skin shenanigans.

I've made it work for a player attachable, but I have forgotten about on the player entity directly, I'll see if I get the same issue.

Also query.bone_orientation_trs(...).r.x stuff like this doesn't work and you have to set it to a variable and only then extract struct members
๐Ÿ‘† true

fathom crypt
#

The error was coming from the paperdoll/UI player.
Use "v.has_rendered && !q.is_in_ui && !v.is_paperdoll ? {v.test_rightitem = q.bone_orientation_trs('rightitem');};" to fix it.

Some hard-coded variables were also missing (the ones involving the new spear animations), causing other errors, I quickly initialized them just to make them go away, but I have not looked into what values they should have, so the first person attack animation will look wonky with the following: