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