Custom Player Model (CPM) Remake

Custom Player Model (CPM) Remake

30.9k Downloads

entity.getPose() is a few frames too slow, making it unviable to use it for custom sneaking poses

floral-qua-floral opened this issue ยท 1 comments

commented

When the player begins crouching, entity.getPose() will still return "standing" for a few frames while the character is already visually in the sneaking animation. Similarly, when the player stops crouching, entity.getPose() will still return "crouching" for a few frames afterwards. As a result, using entity.getPose() to create a custom sneaking pose results in some really janky transitions between the standing and sneaking positions.

To demonstrate, I created a Steve model and configured his animation.js to give him a custom sneaking pose, in which he wiggles his left arm instead of crouching. I then tested two different methods of running the code that replaces his sneak position: The first checks entity.isCrouching(), while the second method checks entity.getPose() == "crouching". A recording is attached below demonstrating the difference: When I swap the check to use getPose(), the animation becomes rather ugly and broken during the transition between crouching and standing, whereas when it uses isCrouching(), it looks fine. I've also confirmed that checking model.getBone("body").getRotationX() != 0 also responds immediately.
https://user-images.githubusercontent.com/49110090/129812992-254e1fa9-4267-4406-b95e-0df6c3140bf4.mp4

Here is the model in its current state, in case it would be useful for replicating the issue. Changing the value of use_entity_getPose on Line 68 between True and False allows you to swap between the two evaluation functions, as I did in the recording.
steve_no_c.zip

commented

It is an issue caused by the multithreaded networking system of minecraft. Some variables are updated outside the main tick event, but the pose get updated only once per tick. Both isCrouching() and getPose() are functions from vanilla minecraft and CPM just exposes them to users. Just avoid using getPose() when immediacy is required.