mojira.dev
MC-265935

The player model in the inventory jitters and is choppy when changing states

The Bug:

The player model in the inventory jitters and is choppy when changing states.

Outside of the inventory, when a player changes their state/pose, for example, entering the crawling animation, the animation is perfectly smooth and does not harshly jitter. However, inside the inventory, the player model is not smooth when changing states/poses and slightly jitters. Instead, it looks choppy and not smooth.

See the attached video for a narrated explanation.

Steps to Reproduce:

  1. Place down a trapdoor and stand in a way that will make you enter the crawling state when opening the trapdoor.

  2. As soon as you interact in the trapdoor and you're in the process of changing your state, open your inventory and watch your player model closely.

  3. Take note as to whether or not the player model in the inventory jitters and is choppy when changing states.

Observed Behavior:

The inventory player model jitters and is choppy.

Expected Behavior:

The inventory player model would be smooth and not jitter.

Code Analysis:

The following is based on a decompiled version of Minecraft 26.3 Snapshot 4 using Mojang mappings.

The game updates the world 20 times a second but draws much more often than that. Each frame, it works out how far it is between one update and the next, a fraction known as the partial tick, and uses it to blend the model's previous pose with its current one. That blending is what makes a change of pose look smooth.

net.minecraft.client.gui.screens.inventory.InventoryScreen.java

private static EntityRenderState extractRenderState(final LivingEntity entity) {
   EntityRenderDispatcher entityRenderDispatcher = Minecraft.getInstance().getEntityRenderDispatcher();
   EntityRenderer<? super LivingEntity, ?> renderer = entityRenderDispatcher.getRenderer(entity);
   EntityRenderState renderState = renderer.createRenderState(entity, 1.0F);

If we look at the above class, we can see that the inventory always passes 1.0 as the partial tick, which means the end of the current update. The blending therefore lands on the new pose every time and the previous one is discarded. The model is rebuilt every frame, but each rebuild produces the same pose, so it only changes 20 times a second while the rest of the screen runs at the full framerate.

This is the only place in the game that passes a fixed partial tick. Everywhere else, including the world itself, uses the real one.

Crawling shows it most clearly because it is a slow change, taking around 12 updates to complete, so it is drawn as roughly 12 separate poses. Anything else that is blended steps in the same way, such as drawing a bow, eating, and arm swings. The same method is also used by the creative inventory and the horse inventory.

Fixed Code:

net.minecraft.client.gui.screens.inventory.InventoryScreen.java

float partialTicks = Minecraft.getInstance().getDeltaTracker()
   .getGameTimeDeltaPartialTick(!entity.level().tickRateManager().isEntityFrozen(entity));
EntityRenderState renderState = renderer.createRenderState(entity, partialTicks);

The above uses the real partial tick, so the model is blended the same way it is in the world.

This change was applied to a modified client and tested against the steps above, and the model is now smooth.

Linked issues

Attachments

Comments 1

Please note that this is not the same issue as MC-261134. MC-261134 talks about how the player model in the inventory is choppy in general or all of the time, whereas this report (MC-265935) talks about a specific case where the inventory player model jitters and is choppy.

Avoma

(Unassigned)

Confirmed

Platform

Low

Rendering

1.20.2, 23w42a, 24w10a, 24w19b, 1.21, 1.21.4, 1.21.5, 25w21a, 26.3 Snapshot 4

Retrieved