java.lang.Object
johnsmith.enchantingoverhauled.api.enchantment.school.MagicSchools

public class MagicSchools extends Object
Registry key holder and utility class for querying MagicSchool definitions, school enchantment tags, and school cycle relationships.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final net.minecraft.resources.ResourceKey<MagicSchool>
    The fallback ResourceKey representing the unassigned "Aberration" school, applied when an enchantment does not belong to any registered school tag.
    static final int
    The default RGB color (0xFFAA00, gold/amber) associated with ABERRATION.
    static final Map<net.minecraft.resources.ResourceKey<MagicSchool>,MagicSchool>
    Built-in fallback map ensuring ABERRATION always resolves to a valid MagicSchool instance even if queried without datapack registry access.
    static final net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<MagicSchool>>
    The ResourceKey identifying the custom dynamic registry for MagicSchool definitions.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    areInSameCycle(@Nullable net.minecraft.core.RegistryAccess registryAccess, @Nullable net.minecraft.resources.ResourceKey<MagicSchool> firstSchool, @Nullable net.minecraft.resources.ResourceKey<MagicSchool> secondSchool)
    Determines whether two MagicSchools belong to the same magic cycle (e.g., Vitality, Cognition, or Material).
    static net.minecraft.tags.TagKey<MagicSchool>
    getCycleTag(net.minecraft.resources.Identifier cycleId)
    Constructs a magic school cycle TagKey for the given cycle identifier (formatted as #<namespace>:cycle/<path>).
    static List<net.minecraft.tags.TagKey<MagicSchool>>
    getCycleTags(@Nullable net.minecraft.core.RegistryAccess registryAccess, @Nullable net.minecraft.resources.ResourceKey<MagicSchool> schoolKey)
    Retrieves all cycle TagKeys to which the specified MagicSchool belongs.
    static List<net.minecraft.resources.ResourceKey<MagicSchool>>
    getMatchingSchools(@Nullable net.minecraft.core.RegistryAccess registryAccess, net.minecraft.core.Holder<net.minecraft.world.item.enchantment.Enchantment> enchantment)
    Returns all non-aberrant MagicSchool keys whose school tags contain the given enchantment.
    getSchool(@Nullable net.minecraft.core.RegistryAccess registryAccess, net.minecraft.resources.ResourceKey<MagicSchool> schoolKey)
    Resolves the MagicSchool definition for the given key from the dynamic registry, falling back to BUILTIN_FALLBACKS or a synthesized default instance if unavailable.
    static net.minecraft.resources.ResourceKey<MagicSchool>
    getSchoolKey(@Nullable net.minecraft.core.RegistryAccess registryAccess, net.minecraft.core.Holder<net.minecraft.world.item.enchantment.Enchantment> enchantment)
    Finds the primary MagicSchool key assigned to the given enchantment via its school tag, or returns ABERRATION if no registered school tag contains the enchantment.
    static net.minecraft.tags.TagKey<net.minecraft.world.item.enchantment.Enchantment>
    getSchoolTag(net.minecraft.resources.ResourceKey<MagicSchool> schoolKey)
    Constructs the enchantment TagKey corresponding to the given MagicSchool key (formatted as #<namespace>:school/<path>).
    static void
    Triggers static class initialization to ensure registry keys are created.
    static boolean
    isAberration(@Nullable net.minecraft.resources.ResourceKey<MagicSchool> schoolKey)
    Checks whether the given school key is null or represents ABERRATION.
    static boolean
    isCycleTag(net.minecraft.tags.TagKey<MagicSchool> tagKey)
    Checks whether the given MagicSchool tag key represents a school cycle tag (i.e., its path starts with "cycle/").

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • REGISTRY_KEY

      public static final net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<MagicSchool>> REGISTRY_KEY
      The ResourceKey identifying the custom dynamic registry for MagicSchool definitions.
    • ABERRATION

      public static final net.minecraft.resources.ResourceKey<MagicSchool> ABERRATION
      The fallback ResourceKey representing the unassigned "Aberration" school, applied when an enchantment does not belong to any registered school tag.
    • ABERRATION_COLOR

      public static final int ABERRATION_COLOR
      The default RGB color (0xFFAA00, gold/amber) associated with ABERRATION.
      See Also:
    • BUILTIN_FALLBACKS

      public static final Map<net.minecraft.resources.ResourceKey<MagicSchool>,MagicSchool> BUILTIN_FALLBACKS
      Built-in fallback map ensuring ABERRATION always resolves to a valid MagicSchool instance even if queried without datapack registry access.
  • Constructor Details

    • MagicSchools

      public MagicSchools()
  • Method Details

    • getSchoolTag

      public static net.minecraft.tags.TagKey<net.minecraft.world.item.enchantment.Enchantment> getSchoolTag(net.minecraft.resources.ResourceKey<MagicSchool> schoolKey)
      Constructs the enchantment TagKey corresponding to the given MagicSchool key (formatted as #<namespace>:school/<path>).
      Parameters:
      schoolKey - The ResourceKey of the magic school.
      Returns:
      The corresponding enchantment TagKey.
    • getCycleTag

      public static net.minecraft.tags.TagKey<MagicSchool> getCycleTag(net.minecraft.resources.Identifier cycleId)
      Constructs a magic school cycle TagKey for the given cycle identifier (formatted as #<namespace>:cycle/<path>).
      Parameters:
      cycleId - The Identifier of the cycle.
      Returns:
      The corresponding magic school TagKey.
    • isCycleTag

      public static boolean isCycleTag(net.minecraft.tags.TagKey<MagicSchool> tagKey)
      Checks whether the given MagicSchool tag key represents a school cycle tag (i.e., its path starts with "cycle/").
      Parameters:
      tagKey - The TagKey to inspect.
      Returns:
      true if the tag key is a cycle tag; false otherwise.
    • getCycleTags

      public static List<net.minecraft.tags.TagKey<MagicSchool>> getCycleTags(@Nullable @Nullable net.minecraft.core.RegistryAccess registryAccess, @Nullable @Nullable net.minecraft.resources.ResourceKey<MagicSchool> schoolKey)
      Retrieves all cycle TagKeys to which the specified MagicSchool belongs.
      Parameters:
      registryAccess - The active RegistryAccess, or null.
      schoolKey - The ResourceKey of the school to query, or null.
      Returns:
      An immutable list of matching cycle TagKeys, or an empty list if none or aberrant.
    • areInSameCycle

      public static boolean areInSameCycle(@Nullable @Nullable net.minecraft.core.RegistryAccess registryAccess, @Nullable @Nullable net.minecraft.resources.ResourceKey<MagicSchool> firstSchool, @Nullable @Nullable net.minecraft.resources.ResourceKey<MagicSchool> secondSchool)
      Determines whether two MagicSchools belong to the same magic cycle (e.g., Vitality, Cognition, or Material).
      Parameters:
      registryAccess - The active RegistryAccess, or null.
      firstSchool - The first MagicSchool key.
      secondSchool - The second MagicSchool key.
      Returns:
      true if both schools are non-aberrant and share at least one cycle/* tag; false otherwise.
    • isAberration

      public static boolean isAberration(@Nullable @Nullable net.minecraft.resources.ResourceKey<MagicSchool> schoolKey)
      Checks whether the given school key is null or represents ABERRATION.
      Parameters:
      schoolKey - The ResourceKey to check.
      Returns:
      true if the key is null or aberration; false otherwise.
    • getSchool

      public static MagicSchool getSchool(@Nullable @Nullable net.minecraft.core.RegistryAccess registryAccess, net.minecraft.resources.ResourceKey<MagicSchool> schoolKey)
      Resolves the MagicSchool definition for the given key from the dynamic registry, falling back to BUILTIN_FALLBACKS or a synthesized default instance if unavailable.
      Parameters:
      registryAccess - The active RegistryAccess, or null.
      schoolKey - The ResourceKey of the magic school to resolve.
      Returns:
      The resolved or fallback MagicSchool instance.
    • getSchoolKey

      public static net.minecraft.resources.ResourceKey<MagicSchool> getSchoolKey(@Nullable @Nullable net.minecraft.core.RegistryAccess registryAccess, net.minecraft.core.Holder<net.minecraft.world.item.enchantment.Enchantment> enchantment)
      Finds the primary MagicSchool key assigned to the given enchantment via its school tag, or returns ABERRATION if no registered school tag contains the enchantment.
      Parameters:
      registryAccess - The active RegistryAccess, or null.
      enchantment - The enchantment Holder to inspect.
      Returns:
      The matching MagicSchool key, or ABERRATION if unassigned.
    • getMatchingSchools

      public static List<net.minecraft.resources.ResourceKey<MagicSchool>> getMatchingSchools(@Nullable @Nullable net.minecraft.core.RegistryAccess registryAccess, net.minecraft.core.Holder<net.minecraft.world.item.enchantment.Enchantment> enchantment)
      Returns all non-aberrant MagicSchool keys whose school tags contain the given enchantment. Used by AdminSchoolValidator to detect unassigned or multi-school enchantments.
      Parameters:
      registryAccess - The active RegistryAccess, or null.
      enchantment - The enchantment Holder to inspect.
      Returns:
      A list of all matching MagicSchool resource keys.
    • initialize

      public static void initialize()
      Triggers static class initialization to ensure registry keys are created.