Interface EnchantmentLevelLangPatch
- All Known Subinterfaces:
EnchantmentLevelLangPatch.WithFallback
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceAnEnchantmentLevelLangPatchthat receives a fallback string. -
Method Summary
Modifier and TypeMethodDescriptionThe entrypoint forEnchantmentLevelLangPatch.The entrypoint forEnchantmentLevelLangPatch, with fallback string given.static StringintToRoman(@Range(from=1L,to=3998L) int num) Provides an algorithm for int-to-roman translation.static voidregisterEnchantmentPatch(String id, EnchantmentLevelLangPatch edition) Register an extra rendering syntax for enchantment levels.static voidregisterPatch(Predicate<String> keyPredicate, EnchantmentLevelLangPatch edition) Register language patch for any language item you want.static voidregisterPotionPatch(String id, EnchantmentLevelLangPatch edition) Register an extra rendering syntax for potion potency.static EnchantmentLevelLangPatchCreates anEnchantmentLevelLangPatchthat receives a fallback string.
-
Method Details
-
registerPatch
Register language patch for any language item you want.- Parameters:
keyPredicate- Predicate for the language key. Iftrue,editionwill be applied to the corresponding language item.edition- The patch for the corresponding language item- See Also:
-
intToRoman
Provides an algorithm for int-to-roman translation. Since there are only 3,998 roman number entries, this implementation enumerates them from a precalculated table.- Parameters:
num- the integer- Returns:
- The number in roman format, or
nullifnumis out of range (1..3998).
-
registerEnchantmentPatch
static void registerEnchantmentPatch(@Pattern("^([0-9a-z_\\-]+:)?[0-9a-z_\\-/]+$") String id, EnchantmentLevelLangPatch edition) Register an extra rendering syntax for enchantment levels.
Won't be applied without invoking
EnchantmentLevelLangPatchConfig.setCurrentEnchantmentHooks(EnchantmentLevelLangPatch), which switches the enchantment level patch to whichever you want.- Parameters:
id- Namespaced key for your patch. Please follow the naming rule of namespaced keys.edition- Your patch for enchantment levels.- See Also:
-
registerPotionPatch
static void registerPotionPatch(@Pattern("^([0-9a-z_\\-]+:)?[0-9a-z_\\-/]+$") String id, EnchantmentLevelLangPatch edition) Register an extra rendering syntax for potion potency.
Won't be applied without invoking
EnchantmentLevelLangPatchConfig.setCurrentPotionHooks(EnchantmentLevelLangPatch), which switches the potion potency patch to whichever you want.- Parameters:
id- Namespaced key for your patch. Please follow the naming rule of namespaced keys.edition- Your patch for potion potencies.- See Also:
-
apply
The entrypoint forEnchantmentLevelLangPatch.- Parameters:
translationStorage- an unmodifiable wrapping of the current key-translation mapkey- the provided translation key when thispatchis applied.- Returns:
- the translation (value) you modify. Returning null indicates remaining unchanged.
- See Also:
-
apply
default @Nullable String apply(@Unmodifiable Map<String, String> translationStorage, String key, String fallback) The entrypoint forEnchantmentLevelLangPatch, with fallback string given.- Parameters:
translationStorage- an unmodifiable wrapping of the current key-translation mapkey- the provided translation key when thispatchis applied.fallback- the fallback translation provided.- Returns:
- the translation (value) you modify. Returning null indicates remaining unchanged.
- See Also:
- Implementation Note
This method is invoked by Minecraft 1.19.4 or above, which always gives a fallback that is defaulted to
key. So if you want to override this method, please check whetherkeyis equal tofallback.In addition,
apply(Map, String)should be implemented as well even if your mod is not designed for 1.19.3 or older versions.
-
withFallback
@Contract(pure=true, value="_ -> param1") static EnchantmentLevelLangPatch withFallback(EnchantmentLevelLangPatch.WithFallback patch) Creates an
EnchantmentLevelLangPatchthat receives a fallback string.This should be used when your patch is only applied in Minecraft 1.19.4+, as the patch will be ignored when the fallback string is absent.
Example:EnchantmentLevelLangPatch.registerPatch( key -> key.startsWith("example.prefix."), EnchantmentLevelLangPatch.withFallback((storage, key, fallback) -> Example.hook(key, fallback)) )- Parameters:
patch- the patch, recommended to be a lambda- Returns:
- the patch itself
-