Class DynamicDescriptionParser

java.lang.Object
johnsmith.enchantmentcore.api.tooltip.DynamicDescriptionParser

public class DynamicDescriptionParser extends Object
Utility class responsible for interpolating evaluated LevelBasedValue pointers into localized enchantment description strings.

Supports two distinct placeholder syntaxes within language files:

  • <val:key>: Evaluates the bound LevelBasedValue at the enchantment's currentLevel.
  • <array:key>: Generates a bracketed progression list [lvl 1, lvl 2, ..., maxLevel] up to maxLevel.
  • Constructor Details

    • DynamicDescriptionParser

      public DynamicDescriptionParser()
  • Method Details

    • parse

      public static String parse(String translatedBase, int currentLevel, int maxLevel, Map<String, net.minecraft.world.item.enchantment.LevelBasedValue> args)
      Parses a raw translation string and replaces all <val:key> and <array:key> placeholders using the provided map of LevelBasedValue arguments.

      If a referenced key is missing from args, the raw placeholder token is left intact in the output string to aid debugging.

      Parameters:
      translatedBase - The raw localized string containing pointer placeholders.
      currentLevel - The active level of the enchantment used to evaluate <val:key> tags.
      maxLevel - The maximum level of the enchantment used to evaluate <array:key> tags.
      args - The map of string pointer IDs to LevelBasedValue instances (from EnchantmentEffectComponents.DESCRIPTION_ARGS).
      Returns:
      The interpolated string with all resolved numeric values formatted cleanly.