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

Armor durability affecting protection is not working right

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Minecraft 15w36a
    • Minecraft 15w34b, Minecraft 15w34c, Minecraft 15w34d
    • None
    • Community Consensus

      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).

            Unassigned Unassigned
            anomie x Anomie X
            Votes:
            19 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: