Search In
• More options...
Find results that contain...
Find results in...

# [1.17.1] Apply rotations to ModelPart in different order

## Recommended Posts

Hello! I want to add tilted ears to some animals. Under ideal circumstances, I'd just modelPart.zRot = t. However, the rotation around the z axis is applied before the other rotations, which makes a big mess of everything.

As far as I can tell, transformation of the matrix M represented by the PoseStack to the result R depending on the rotation matrices X, Y, Z and the translation matrix P is applied as such: R=XYZPM. My solution prior to 1.17 was to extend ModelRenderer and apply the transformations in the order ZXYPM - solving the problem very simply. But since ModelPart - the 1.17 counterpart to the old ModelRenderer - is final, I see no such simple solution.

I see two possible approaches:

1. Denote T=XYZP. Apply T^-1(ZXYP) to the PoseStack before I ModelPart#render. The ModelPart will then apply T, resulting in my desired ZXYP  transformation. No problem in theory, but quite convoluted in practice.
2. Consider Z(z)X(x)Y(y). Do some linear algebra and trigonometry to find out (s,t,u) such that X(s)Y(t)Z(u)=Z(z)X(x)Y(y), then ModelPart#setRotation(s,t,u). I haven't done the math on this, so I'm not sure how feasible this is.

Anyone got a simpler solution? Or should I rather do a feature request to make ModelPart not final?

##### Share on other sites

Posted (edited)
7 hours ago, Anrza said:

My solution prior to 1.17 was to extend ModelRenderer and apply the transformations in the order ZXYPM - solving the problem very simply. But since ModelPart - the 1.17 counterpart to the old ModelRenderer - is final

you can use Access Transformer to remove the final modifier from the class

Edited by Luis_ST
##### Share on other sites

I must've struck gold if the recommendation is to use access transformers. Thanks.

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

×   Pasted as rich text.   Restore formatting

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×

• ### Posts

• A friendly community with lots of awesome plugins to make your Minecraft experience enjoyable :)
• Actually yea that's a good point, I'll just call super instead, but also I've figured out why it wasn't working By looking at SweetBerryBush I figured out that you have to replace the block to change the block state, so I just changed my previous state.setValue to world.setBlock(pos, state.setValue(POWER, Math.min(state.getValue(POWER) + 1, 100)), 2); and it all works now.
• Could Anyone Else Help?
• You know you could just do the second if statement, right? Think about it. If the second one is true, the first one MUST be true. The vanilla code is then wrapped in an if-else that checks for flint and steel or fire charges, and a final else-return-super. If the catch-fire portion ("from here on its vanilla code") is the code from the TNT block (your super) you could just call super...
• What. Gross. First off, you could just loop ax = -1; ax <= 1 (same for y and z) and then use BlockPos.add(ax, ay, az) Or you could use the static method in the BlockPos class to get all blocks in range and iterate over the resulting collection (the MCP name was getAllInBox).   Older code, but example of the latter: https://github.com/Draco18s/ReasonableRealism/blob/1.14.4/src/main/java/com/draco18s/harderores/EventHandlers.java#L121

• 2
• 4
• 7
• 4
• 3
• ### Who's Online (See full list)

×

• #### Activity

×
• Create New...