mojira.dev
MC-276385

Players' elytra don't move with the yaw of their bodies when swinging

The Bug:

Players' elytra don't move with the yaw of their bodies when swinging.

Players' worn equipment usually follow their motion in every other instance but this one.

Steps to Reproduce:

  1. Equip elytra, look directly down, and switch perspectives once (hit F5 once).

  2. Punch the ground constantly and observe the movement of your body and your elytra.

Observed Behavior:

Your elytra remain completely still despite your body rotating.

Expected Behavior:

Your elytra would rotate with your body.

Code Analysis:

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

Swinging twists the torso by setting body.yRot in HumanoidModel.setupAttackAnimation. Anything attached below that part twists with it.

net.minecraft.client.model.player.PlayerCapeModel.java

public class PlayerCapeModel extends PlayerModel {
   private final ModelPart cape = this.body.getChild("cape");

net.minecraft.client.model.object.equipment.ElytraModel.java

public class ElytraModel extends EntityModel<HumanoidRenderState> {

If we look at the above classes, we can see that the cape is a child of the body part, so it follows the twist. The elytra is a separate model with its own root, drawn by WingsLayer at the player's origin, so it does not.

Armor, the jacket skin layer, held items and arrows stuck in the torso all follow the swing. CapeLayer also hides the cape whenever an elytra is worn, so the elytra behaves unlike what it replaces.

Fixed Code:

net.minecraft.client.renderer.entity.layers.WingsLayer.java

poseStack.pushPose();
poseStack.mulPose(new Quaternionf().rotationY(this.getParentModel().body.yRot));
poseStack.translate(0.0F, 0.0F, 0.125F);

The above gives the elytra the movement it would have had as a child of the body part.

The rotation must come before the existing offset, as ModelPart.translateAndRotate translates and then rotates, so rotating afterwards would turn the elytra about a point already moved backwards.

This needs WingsLayer to take a HumanoidModel rather than any model, which all three places it is registered already provide.

This change was applied to a modified client and tested against the steps above, and the elytra now moves with the body.

Linked issues

Attachments

Comments 1

I’m able to reproduce the behavior in question. It has been present in the game since the addition of elytra in Minecraft 15w41a.

Avoma

(Unassigned)

Community Consensus

Platform

Low

Player Animation

Minecraft 15w41a, 1.21.1, 24w36a, 1.21.2, 1.21.4, 25w03a, 1.21.5, 1.21.7, 26.2, 26.3

Retrieved