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

Armor durability affecting protection is not working right

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Resolution: Fixed
    • Affects Version/s: Minecraft 15w34b, Minecraft 15w34c, Minecraft 15w34d
    • Fix Version/s: Minecraft 15w36a
    • Labels:
      None
    • Confirmation Status:
      Community Consensus

      Description

      The code for the new "damaged armor doesn't protect as well" feature seems broken. In particular, the code looks something like this:

      int protection = ((ItemArmor)itemStack.getItem()).protectionAmount;
      int durability = itemStack.getDurability();
      int damage = itemStack.getDamage();
      if ( damage > durability / 2 ) {
          protection = Math.ceiling( (float)(durability - damage) / (float)(durability / 2) );
      }
      

      The code seems pretty clear that it's trying to gradually decrease the protection, full protection until half-damaged then decreasing linearly to no protection when fully-damaged. But as it is it instead sets the protection to 1 as soon as the armor hits half-damaged. To calculate that correctly, it should be

          protection = Math.ceiling( (float)protection * (float)(durability - damage) / (float)(durability / 2) );
      

      (Mods: If "set to 1 at half-damaged" were the intended behavior, it would just do that as "protection = 1" instead of the formula shown).

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              anomie x Anomie X
            • Votes:
              19 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                CHK: