Mojira Archive
MC-267629

Integer division of "enchantability" nullifies some of its intended advantages.

Enchantability is intended to describe an Item's propensity to receive rarer and higher level enchantments from the Enchanting Table. The greater the enchantability, the more likely the item will receive these enchantments.

The enchantability of all enchantable items ranks as follows:

Item Enchantability
Golden Armor 25
Golden Tools 22
Netherite Armor and Tools
Leather Armor
Wooden Tools
15
Iron Tools 14
Chainmail Armor 12
Diamond Armor and Tools 10
Iron and Turtle Armor 9
Stone Tools 5
Other (e.g. Books) 1

In code, enchantability's intended function is achieved by modifying the enchantment level. However-before this is done-it is first integer divided by 4, then added to 1. This integer division truncates the differences between any two enchantabilities within the same modulus of 4, creating the following effective ranking:

Item Effective Enchantability
Golden Armor 7
Golden Tools 6
Netherite Armor and Tools
Leather Armor
Wooden Tools
Iron Tools
Chainmail Armor
4
Diamond Armor and Tools
Iron and Turtle Armor
3
Stone Tools 2
Other (e.g. Books) 1

As an example of the faulty results this causes, Netherite is intended to modify the enchantment level up to 25% greater than Chainmail (15 versus 12), yet their enchantabilities modify the enchantment level equally. At worst, this behavior nullifies the intended benefit of enchanting Netherite over Chainmail entirely. At best, it creates unnecessary computation. 

A graphical demonstration can be found here:
https://www.desmos.com/calculator/pvu7whrb0g
where:

  • L = the enchantment level
  • E = (int) enchantability / 4
  • f( x ) = the probability distribution function of the modified enchantment level
  • xi = a modified enchantment level, which is followed by the equation for the unweighted probability of achieving xi

 

Works As Intended

Eben Gino Lester

2023-12-28, 09:25 AM

2024-04-25, 12:11 AM

2024-01-04, 08:09 AM

4

3

Plausible

Enchantments

1.20.4

-