getEnchantBonus

public static double getEnchantBonus(ItemStack item, ArmorDefenseCalculator.DamageType type)

Calculates the enchantment bonus for a single item, converted to armor-level units.

Always includes general Protection. Additionally includes the type-specific protection enchantment if the damage type matches:

  • PROJECTILE → + Projectile Protection
  • EXPLOSION → + Blast Protection
  • FIRE → + Fire Protection
  • MELEE/OTHER → general Protection only

Uses getEnchantment which handles both elite items (reads from PersistentDataContainer) and vanilla items (falls back to getEnchantLevel()).

The raw enchantment level sum is multiplied by ENCHANT_SCALE (1/3) to convert to armor-level-equivalent units.

Example: An item with Protection IV + Projectile Protection III, evaluated against PROJECTILE damage: (4 + 3) * (1/3) = 2.33 armor-level units.

Return

The enchant bonus in armor-level-equivalent units (0 if null or no enchants)

Parameters

item

The item to evaluate (may be null)

type

The damage type being defended against