Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-275917

Consumable blocking animation is broken in first person

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • 24w44a
    • 24w34a, 24w35a, 24w36a, 24w38a, 1.21.2
    • None
    • Confirmed
    • Player Animation
    • Normal
    • 1287857
    • Expansion B

      When using the "block" animation via the consumable component, there is no visual animation in first person

      /give @s iron_sword[consumable={animation:"block",consume_seconds:72000}] 

      My proposition to fix this, is by using this piece of code taken from one of the early 1.9 snapshots before shields where added, and still had sword blocking:

      (The piece of code has been updated to work in 1.21 (Mappings: Mojang (via Intermediary)))

      this.applyItemArmTransform(matrices, arm, equipProgress);
      this.applyItemArmAttackTransform(matrices, arm, swingProgress);
      matrices.translate(l * -0.14142136F, 0.08F, 0.14142136F);
      matrices.mulPose(Axis.XP.rotationDegrees(-102.25F));
      matrices.mulPose(Axis.YP.rotationDegrees(l * 13.365F));
      matrices.mulPose(Axis.ZP.rotationDegrees(l * 78.05F)); 

      This piece of code is from ItemInHandRenderer.renderArmWithItem, in the item usage switch branch for BLOCK enum value

      Do note, this code doesn't work with the shield model sadly but does work for everything else. This is presumably because, the shield has a predicate & seperate model for when blocking which this collides with.

            Unassigned Unassigned
            lowercasebtw lowercasebtw
            Votes:
            12 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: