Class MagicSchools
java.lang.Object
johnsmith.enchantingoverhauled.api.enchantment.school.MagicSchools
Registry key holder and utility class for querying
MagicSchool definitions,
school enchantment tags, and school cycle relationships.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final net.minecraft.resources.ResourceKey<MagicSchool> The fallbackResourceKeyrepresenting the unassigned "Aberration" school, applied when an enchantment does not belong to any registered school tag.static final intThe default RGB color (0xFFAA00, gold/amber) associated withABERRATION.static final Map<net.minecraft.resources.ResourceKey<MagicSchool>, MagicSchool> Built-in fallback map ensuringABERRATIONalways resolves to a validMagicSchoolinstance even if queried without datapack registry access.static final net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<MagicSchool>> TheResourceKeyidentifying the custom dynamic registry forMagicSchooldefinitions. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanareInSameCycle(@Nullable net.minecraft.core.RegistryAccess registryAccess, @Nullable net.minecraft.resources.ResourceKey<MagicSchool> firstSchool, @Nullable net.minecraft.resources.ResourceKey<MagicSchool> secondSchool) Determines whether twoMagicSchools 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 cycleTagKeyfor 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 cycleTagKeys to which the specifiedMagicSchoolbelongs.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-aberrantMagicSchoolkeys whose school tags contain the given enchantment.static MagicSchoolgetSchool(@Nullable net.minecraft.core.RegistryAccess registryAccess, net.minecraft.resources.ResourceKey<MagicSchool> schoolKey) Resolves theMagicSchooldefinition for the given key from the dynamic registry, falling back toBUILTIN_FALLBACKSor 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 primaryMagicSchoolkey assigned to the given enchantment via its school tag, or returnsABERRATIONif 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 enchantmentTagKeycorresponding to the givenMagicSchoolkey (formatted as#<namespace>:school/<path>).static voidTriggers static class initialization to ensure registry keys are created.static booleanisAberration(@Nullable net.minecraft.resources.ResourceKey<MagicSchool> schoolKey) Checks whether the given school key isnullor representsABERRATION.static booleanisCycleTag(net.minecraft.tags.TagKey<MagicSchool> tagKey) Checks whether the givenMagicSchooltag key represents a school cycle tag (i.e., its path starts with"cycle/").
-
Field Details
-
REGISTRY_KEY
public static final net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<MagicSchool>> REGISTRY_KEYTheResourceKeyidentifying the custom dynamic registry forMagicSchooldefinitions. -
ABERRATION
The fallbackResourceKeyrepresenting the unassigned "Aberration" school, applied when an enchantment does not belong to any registered school tag. -
ABERRATION_COLOR
public static final int ABERRATION_COLORThe default RGB color (0xFFAA00, gold/amber) associated withABERRATION.- See Also:
-
BUILTIN_FALLBACKS
public static final Map<net.minecraft.resources.ResourceKey<MagicSchool>,MagicSchool> BUILTIN_FALLBACKSBuilt-in fallback map ensuringABERRATIONalways resolves to a validMagicSchoolinstance 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 enchantmentTagKeycorresponding to the givenMagicSchoolkey (formatted as#<namespace>:school/<path>).- Parameters:
schoolKey- TheResourceKeyof 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 cycleTagKeyfor the given cycle identifier (formatted as#<namespace>:cycle/<path>).- Parameters:
cycleId- TheIdentifierof the cycle.- Returns:
- The corresponding magic school
TagKey.
-
isCycleTag
Checks whether the givenMagicSchooltag key represents a school cycle tag (i.e., its path starts with"cycle/").- Parameters:
tagKey- TheTagKeyto inspect.- Returns:
trueif the tag key is a cycle tag;falseotherwise.
-
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 cycleTagKeys to which the specifiedMagicSchoolbelongs.- Parameters:
registryAccess- The activeRegistryAccess, ornull.schoolKey- TheResourceKeyof the school to query, ornull.- 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 twoMagicSchools belong to the same magic cycle (e.g., Vitality, Cognition, or Material).- Parameters:
registryAccess- The activeRegistryAccess, ornull.firstSchool- The firstMagicSchoolkey.secondSchool- The secondMagicSchoolkey.- Returns:
trueif both schools are non-aberrant and share at least onecycle/*tag;falseotherwise.
-
isAberration
public static boolean isAberration(@Nullable @Nullable net.minecraft.resources.ResourceKey<MagicSchool> schoolKey) Checks whether the given school key isnullor representsABERRATION.- Parameters:
schoolKey- TheResourceKeyto check.- Returns:
trueif the key isnulloraberration;falseotherwise.
-
getSchool
public static MagicSchool getSchool(@Nullable @Nullable net.minecraft.core.RegistryAccess registryAccess, net.minecraft.resources.ResourceKey<MagicSchool> schoolKey) Resolves theMagicSchooldefinition for the given key from the dynamic registry, falling back toBUILTIN_FALLBACKSor a synthesized default instance if unavailable.- Parameters:
registryAccess- The activeRegistryAccess, ornull.schoolKey- TheResourceKeyof the magic school to resolve.- Returns:
- The resolved or fallback
MagicSchoolinstance.
-
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 primaryMagicSchoolkey assigned to the given enchantment via its school tag, or returnsABERRATIONif no registered school tag contains the enchantment.- Parameters:
registryAccess- The activeRegistryAccess, ornull.enchantment- The enchantmentHolderto inspect.- Returns:
- The matching
MagicSchoolkey, orABERRATIONif 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-aberrantMagicSchoolkeys whose school tags contain the given enchantment. Used byAdminSchoolValidatorto detect unassigned or multi-school enchantments.- Parameters:
registryAccess- The activeRegistryAccess, ornull.enchantment- The enchantmentHolderto inspect.- Returns:
- A list of all matching
MagicSchoolresource keys.
-
initialize
public static void initialize()Triggers static class initialization to ensure registry keys are created.
-