Record Class AiSpellField
java.lang.Object
java.lang.Record
johnsmith.enchantingoverhauled.api.enchantment.spellfield.AiSpellField
- Record Components:
weight- The base selection weight of this spell (must be positive to be selectable).role- The tacticalSpellRole(Offensive, Defensive, or Supportive).target- The intendedSpellTargetcategory (Self, Ally, or Hostile).castType- The deliveryCastType(Projectile or Direct).difficultyGate- The minimum worldDifficultyGaterequired for AI entities to cast this spell.griefing- Whether this spell modifies blocks or causes griefing and therefore requiresmobGriefingto be enabled.schools- An optionalHolderSetofMagicSchools associated with this spell.theme- TheEnchantmentThemekey required to cast this spell (defaults toEnchantmentThemes.COMMON).anchor- An optionalAiSpellField.AnchorPayloadif the spell persists over time via aSpellFieldAnchorEntityor attached tick loop.spellField- The underlyingSpellFieldComponentdefining the volumes, entity/block/volume effects, and visuals.
public record AiSpellField(int weight, SpellRole role, SpellTarget target, CastType castType, DifficultyGate difficultyGate, boolean griefing, Optional<net.minecraft.core.HolderSet<MagicSchool>> schools, net.minecraft.resources.ResourceKey<EnchantmentTheme> theme, Optional<AiSpellField.AnchorPayload> anchor, johnsmith.enchantmentcore.api.enchantment.spellfield.SpellFieldComponent spellField)
extends Record
A data-driven record defining an AI spell field that can be selected and cast by flying arcane book
entities (
AbstractFlyingBookEntity).
Encapsulates selection weight, tactical SpellRole, intended SpellTarget,
delivery CastType, minimum world DifficultyGate, mobGriefing requirement,
school/theme affinities, optional persistent AiSpellField.AnchorPayload, and the underlying
SpellFieldComponent from Enchantment Core.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordConfiguration record defining the lifecycle and visual parameters for a persistentSpellFieldAnchorEntitydeployed by anAiSpellField.static enumRepresents the degree of compatibility between a caster'sMagicSchooland anAiSpellField. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec<AiSpellField> Lazily initialized codec so referencingAiSpellField.CODECduring Forge'sDataPackRegistryEvent.NewRegistrydoes not prematurely triggerSpellFieldComponentclass initialization beforeNewRegistryEvent.fill()populates Enchantment Core's custom registry suppliers. -
Constructor Summary
ConstructorsConstructorDescriptionAiSpellField(int weight, SpellRole role, Optional<net.minecraft.core.HolderSet<MagicSchool>> schools, net.minecraft.resources.ResourceKey<EnchantmentTheme> theme, Optional<AiSpellField.AnchorPayload> anchor, johnsmith.enchantmentcore.api.enchantment.spellfield.SpellFieldComponent spellField) Convenience constructor deriving bothtargetandcastTypefromrole, and defaultingdifficultyGatetoDifficultyGate.EASYandgriefingtofalse.AiSpellField(int weight, SpellRole role, SpellTarget target, Optional<net.minecraft.core.HolderSet<MagicSchool>> schools, net.minecraft.resources.ResourceKey<EnchantmentTheme> theme, Optional<AiSpellField.AnchorPayload> anchor, johnsmith.enchantmentcore.api.enchantment.spellfield.SpellFieldComponent spellField) Convenience constructor derivingcastTypefromtargetandrole, and defaultingdifficultyGatetoDifficultyGate.EASYandgriefingtofalse.AiSpellField(int weight, SpellRole role, SpellTarget target, CastType castType, Optional<net.minecraft.core.HolderSet<MagicSchool>> schools, net.minecraft.resources.ResourceKey<EnchantmentTheme> theme, Optional<AiSpellField.AnchorPayload> anchor, johnsmith.enchantmentcore.api.enchantment.spellfield.SpellFieldComponent spellField) AiSpellField(int weight, SpellRole role, SpellTarget target, CastType castType, DifficultyGate difficultyGate, boolean griefing, Optional<net.minecraft.core.HolderSet<MagicSchool>> schools, net.minecraft.resources.ResourceKey<EnchantmentTheme> theme, Optional<AiSpellField.AnchorPayload> anchor, johnsmith.enchantmentcore.api.enchantment.spellfield.SpellFieldComponent spellField) Creates an instance of aAiSpellFieldrecord class.AiSpellField(int weight, SpellRole role, SpellTarget target, CastType castType, DifficultyGate difficultyGate, Optional<net.minecraft.core.HolderSet<MagicSchool>> schools, net.minecraft.resources.ResourceKey<EnchantmentTheme> theme, Optional<AiSpellField.AnchorPayload> anchor, johnsmith.enchantmentcore.api.enchantment.spellfield.SpellFieldComponent spellField) Convenience constructor defaultinggriefingtofalse.AiSpellField(int weight, SpellRole role, SpellTarget target, DifficultyGate difficultyGate, Optional<net.minecraft.core.HolderSet<MagicSchool>> schools, net.minecraft.resources.ResourceKey<EnchantmentTheme> theme, Optional<AiSpellField.AnchorPayload> anchor, johnsmith.enchantmentcore.api.enchantment.spellfield.SpellFieldComponent spellField) Convenience constructor derivingcastTypefromtargetandrole, and defaultinggriefingtofalse. -
Method Summary
Modifier and TypeMethodDescriptionanchor()Returns the value of theanchorrecord component.intcalculateEffectiveWeight(@Nullable net.minecraft.core.RegistryAccess registryAccess, @Nullable net.minecraft.resources.ResourceKey<EnchantmentTheme> entityTheme, @Nullable net.minecraft.resources.ResourceKey<MagicSchool> entitySchool) Calculates the effective selection weight of this spell for a caster with the givenentityThemeandentitySchool.castType()Returns the value of thecastTyperecord component.voiddeployAt(net.minecraft.server.level.ServerLevel serverLevel, net.minecraft.world.phys.Vec3 position, @Nullable net.minecraft.world.entity.LivingEntity owner, net.minecraft.world.entity.Entity spatialSource, net.minecraft.world.item.ItemStack weapon) Deploys this spell field at the specified world position.static voiddeployPayload(net.minecraft.server.level.ServerLevel serverLevel, net.minecraft.world.phys.Vec3 position, @Nullable net.minecraft.world.entity.LivingEntity owner, net.minecraft.world.entity.Entity spatialSource, net.minecraft.world.item.ItemStack weapon, @Nullable johnsmith.enchantmentcore.api.enchantment.spellfield.SpellFieldComponent spellField, Optional<AiSpellField.AnchorPayload> anchorPayload) Deploys aSpellFieldComponentpayload at the given world position, either attaching it directly to a flying book, spawning a persistentSpellFieldAnchorEntity(with hostility tags forCasterHostileCondition), or executing an immediate one-shot application within aMirageEntity.withCasterContext(Entity, Runnable)block.Returns the value of thedifficultyGaterecord component.final booleanIndicates whether some other object is "equal to" this one.evaluateSchoolAffinity(@Nullable net.minecraft.core.RegistryAccess registryAccess, @Nullable net.minecraft.resources.ResourceKey<MagicSchool> entitySchool) Evaluates theAiSpellField.SchoolAffinitybetween this spell's allowedschoolsand the caster'sentitySchool.booleangriefing()Returns the value of thegriefingrecord component.booleanhasExactNonCommonThemeMatch(@Nullable net.minecraft.resources.ResourceKey<EnchantmentTheme> entityTheme) Checks whether both this spell and the caster share the exact same non-commonEnchantmentTheme.final inthashCode()Returns a hash code value for this object.booleanisDifficultyMet(@Nullable net.minecraft.world.Difficulty difficulty) Checks whether the given worldDifficultysatisfies this spell'sdifficultyGate.booleanisThemeCompatible(@Nullable net.minecraft.resources.ResourceKey<EnchantmentTheme> entityTheme) Checks whether a caster with the givenentityThemeis compatible with this spell's theme.Optional<net.minecraft.resources.ResourceKey<MagicSchool>> resolveSpellSchool(@Nullable net.minecraft.core.RegistryAccess registryAccess, @Nullable net.minecraft.resources.ResourceKey<MagicSchool> entitySchool) Resolves the specificMagicSchoolidentity under which this spell is cast by an entity withentitySchool(used for tinting chanting particles and projectiles).role()Returns the value of therolerecord component.Optional<net.minecraft.core.HolderSet<MagicSchool>> schools()Returns the value of theschoolsrecord component.johnsmith.enchantmentcore.api.enchantment.spellfield.SpellFieldComponentReturns the value of thespellFieldrecord component.target()Returns the value of thetargetrecord component.net.minecraft.resources.ResourceKey<EnchantmentTheme> theme()Returns the value of thethemerecord component.final StringtoString()Returns a string representation of this record class.intweight()Returns the value of theweightrecord component.
-
Field Details
-
CODEC
Lazily initialized codec so referencingAiSpellField.CODECduring Forge'sDataPackRegistryEvent.NewRegistrydoes not prematurely triggerSpellFieldComponentclass initialization beforeNewRegistryEvent.fill()populates Enchantment Core's custom registry suppliers.
-
-
Constructor Details
-
AiSpellField
public AiSpellField(int weight, SpellRole role, SpellTarget target, CastType castType, DifficultyGate difficultyGate, Optional<net.minecraft.core.HolderSet<MagicSchool>> schools, net.minecraft.resources.ResourceKey<EnchantmentTheme> theme, Optional<AiSpellField.AnchorPayload> anchor, johnsmith.enchantmentcore.api.enchantment.spellfield.SpellFieldComponent spellField) Convenience constructor defaultinggriefingtofalse.- Parameters:
weight- The base selection weight.role- The tactical spell role.target- The intended target category.castType- The delivery cast type.difficultyGate- The minimum world difficulty gate.schools- The optional set of associated magic schools.theme- The required enchantment theme key.anchor- The optional anchor configuration.spellField- The spell field component payload.
-
AiSpellField
public AiSpellField(int weight, SpellRole role, SpellTarget target, CastType castType, Optional<net.minecraft.core.HolderSet<MagicSchool>> schools, net.minecraft.resources.ResourceKey<EnchantmentTheme> theme, Optional<AiSpellField.AnchorPayload> anchor, johnsmith.enchantmentcore.api.enchantment.spellfield.SpellFieldComponent spellField) - Parameters:
weight- The base selection weight.role- The tactical spell role.target- The intended target category.castType- The delivery cast type.schools- The optional set of associated magic schools.theme- The required enchantment theme key.anchor- The optional anchor configuration.spellField- The spell field component payload.
-
AiSpellField
public AiSpellField(int weight, SpellRole role, SpellTarget target, DifficultyGate difficultyGate, Optional<net.minecraft.core.HolderSet<MagicSchool>> schools, net.minecraft.resources.ResourceKey<EnchantmentTheme> theme, Optional<AiSpellField.AnchorPayload> anchor, johnsmith.enchantmentcore.api.enchantment.spellfield.SpellFieldComponent spellField) Convenience constructor derivingcastTypefromtargetandrole, and defaultinggriefingtofalse.- Parameters:
weight- The base selection weight.role- The tactical spell role.target- The intended target category.difficultyGate- The minimum world difficulty gate.schools- The optional set of associated magic schools.theme- The required enchantment theme key.anchor- The optional anchor configuration.spellField- The spell field component payload.
-
AiSpellField
public AiSpellField(int weight, SpellRole role, SpellTarget target, Optional<net.minecraft.core.HolderSet<MagicSchool>> schools, net.minecraft.resources.ResourceKey<EnchantmentTheme> theme, Optional<AiSpellField.AnchorPayload> anchor, johnsmith.enchantmentcore.api.enchantment.spellfield.SpellFieldComponent spellField) Convenience constructor derivingcastTypefromtargetandrole, and defaultingdifficultyGatetoDifficultyGate.EASYandgriefingtofalse.- Parameters:
weight- The base selection weight.role- The tactical spell role.target- The intended target category.schools- The optional set of associated magic schools.theme- The required enchantment theme key.anchor- The optional anchor configuration.spellField- The spell field component payload.
-
AiSpellField
public AiSpellField(int weight, SpellRole role, Optional<net.minecraft.core.HolderSet<MagicSchool>> schools, net.minecraft.resources.ResourceKey<EnchantmentTheme> theme, Optional<AiSpellField.AnchorPayload> anchor, johnsmith.enchantmentcore.api.enchantment.spellfield.SpellFieldComponent spellField) Convenience constructor deriving bothtargetandcastTypefromrole, and defaultingdifficultyGatetoDifficultyGate.EASYandgriefingtofalse.- Parameters:
weight- The base selection weight.role- The tactical spell role.schools- The optional set of associated magic schools.theme- The required enchantment theme key.anchor- The optional anchor configuration.spellField- The spell field component payload.
-
AiSpellField
public AiSpellField(int weight, SpellRole role, SpellTarget target, CastType castType, DifficultyGate difficultyGate, boolean griefing, Optional<net.minecraft.core.HolderSet<MagicSchool>> schools, net.minecraft.resources.ResourceKey<EnchantmentTheme> theme, Optional<AiSpellField.AnchorPayload> anchor, johnsmith.enchantmentcore.api.enchantment.spellfield.SpellFieldComponent spellField) Creates an instance of aAiSpellFieldrecord class.- Parameters:
weight- the value for theweightrecord componentrole- the value for therolerecord componenttarget- the value for thetargetrecord componentcastType- the value for thecastTyperecord componentdifficultyGate- the value for thedifficultyGaterecord componentgriefing- the value for thegriefingrecord componentschools- the value for theschoolsrecord componenttheme- the value for thethemerecord componentanchor- the value for theanchorrecord componentspellField- the value for thespellFieldrecord component
-
-
Method Details
-
isDifficultyMet
public boolean isDifficultyMet(@Nullable @Nullable net.minecraft.world.Difficulty difficulty) Checks whether the given worldDifficultysatisfies this spell'sdifficultyGate.- Parameters:
difficulty- The current worldDifficulty, ornull.- Returns:
trueif the difficulty gate is met;falseotherwise.
-
isThemeCompatible
public boolean isThemeCompatible(@Nullable @Nullable net.minecraft.resources.ResourceKey<EnchantmentTheme> entityTheme) Checks whether a caster with the givenentityThemeis compatible with this spell's theme.Compatibility holds if either the spell's theme or the entity's theme is
EnchantmentThemes.COMMON, or if both themes match exactly.- Parameters:
entityTheme- The caster'sEnchantmentThemekey, ornull.- Returns:
trueif the themes are compatible;falseotherwise.
-
hasExactNonCommonThemeMatch
public boolean hasExactNonCommonThemeMatch(@Nullable @Nullable net.minecraft.resources.ResourceKey<EnchantmentTheme> entityTheme) Checks whether both this spell and the caster share the exact same non-commonEnchantmentTheme.- Parameters:
entityTheme- The caster'sEnchantmentThemekey, ornull.- Returns:
trueif both themes are non-common and equal;falseotherwise.
-
evaluateSchoolAffinity
public AiSpellField.SchoolAffinity evaluateSchoolAffinity(@Nullable @Nullable net.minecraft.core.RegistryAccess registryAccess, @Nullable @Nullable net.minecraft.resources.ResourceKey<MagicSchool> entitySchool) Evaluates theAiSpellField.SchoolAffinitybetween this spell's allowedschoolsand the caster'sentitySchool.- Parameters:
registryAccess- The activeRegistryAccessused to check school cycle tags, ornull.entitySchool- The caster'sMagicSchoolkey, ornull.- Returns:
- The resolved
AiSpellField.SchoolAffinitytier.
-
resolveSpellSchool
public Optional<net.minecraft.resources.ResourceKey<MagicSchool>> resolveSpellSchool(@Nullable @Nullable net.minecraft.core.RegistryAccess registryAccess, @Nullable @Nullable net.minecraft.resources.ResourceKey<MagicSchool> entitySchool) Resolves the specificMagicSchoolidentity under which this spell is cast by an entity withentitySchool(used for tinting chanting particles and projectiles).- Parameters:
registryAccess- The activeRegistryAccess, ornull.entitySchool- The caster's ownMagicSchoolkey, ornull.- Returns:
- An
Optionalcontaining the resolvedMagicSchoolkey, or empty if unrestricted.
-
calculateEffectiveWeight
public int calculateEffectiveWeight(@Nullable @Nullable net.minecraft.core.RegistryAccess registryAccess, @Nullable @Nullable net.minecraft.resources.ResourceKey<EnchantmentTheme> entityTheme, @Nullable @Nullable net.minecraft.resources.ResourceKey<MagicSchool> entitySchool) Calculates the effective selection weight of this spell for a caster with the givenentityThemeandentitySchool.Applies a
3xmultiplier for a primary school match,2xfor a cycle sibling match, and an additional3xmultiplier for an exact non-common theme match. Returns0if the theme or school is incompatible.- Parameters:
registryAccess- The activeRegistryAccess, ornull.entityTheme- The caster'sEnchantmentThemekey, ornull.entitySchool- The caster'sMagicSchoolkey, ornull.- Returns:
- The non-negative effective selection weight.
-
deployAt
public void deployAt(net.minecraft.server.level.ServerLevel serverLevel, net.minecraft.world.phys.Vec3 position, @Nullable @Nullable net.minecraft.world.entity.LivingEntity owner, net.minecraft.world.entity.Entity spatialSource, net.minecraft.world.item.ItemStack weapon) Deploys this spell field at the specified world position.- Parameters:
serverLevel- The executingServerLevel.position- The world coordinates where the spell field is deployed.owner- The casterLivingEntity, ornull.spatialSource- The spatial reference entity (such as the target or impact projectile).weapon- The catalystItemStackheld by the caster.
-
deployPayload
public static void deployPayload(net.minecraft.server.level.ServerLevel serverLevel, net.minecraft.world.phys.Vec3 position, @Nullable @Nullable net.minecraft.world.entity.LivingEntity owner, net.minecraft.world.entity.Entity spatialSource, net.minecraft.world.item.ItemStack weapon, @Nullable @Nullable johnsmith.enchantmentcore.api.enchantment.spellfield.SpellFieldComponent spellField, Optional<AiSpellField.AnchorPayload> anchorPayload) Deploys aSpellFieldComponentpayload at the given world position, either attaching it directly to a flying book, spawning a persistentSpellFieldAnchorEntity(with hostility tags forCasterHostileCondition), or executing an immediate one-shot application within aMirageEntity.withCasterContext(Entity, Runnable)block.- Parameters:
serverLevel- The executingServerLevel.position- The world coordinates for deployment.owner- The casterLivingEntity, ornull.spatialSource- The spatial reference entity.weapon- The catalystItemStackheld by the caster.spellField- TheSpellFieldComponentto apply, ornull.anchorPayload- The optionalAiSpellField.AnchorPayloadgoverning duration and tick phases.
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
weight
public int weight()Returns the value of theweightrecord component.- Returns:
- the value of the
weightrecord component
-
role
Returns the value of therolerecord component.- Returns:
- the value of the
rolerecord component
-
target
Returns the value of thetargetrecord component.- Returns:
- the value of the
targetrecord component
-
castType
Returns the value of thecastTyperecord component.- Returns:
- the value of the
castTyperecord component
-
difficultyGate
Returns the value of thedifficultyGaterecord component.- Returns:
- the value of the
difficultyGaterecord component
-
griefing
public boolean griefing()Returns the value of thegriefingrecord component.- Returns:
- the value of the
griefingrecord component
-
schools
Returns the value of theschoolsrecord component.- Returns:
- the value of the
schoolsrecord component
-
theme
Returns the value of thethemerecord component.- Returns:
- the value of the
themerecord component
-
anchor
Returns the value of theanchorrecord component.- Returns:
- the value of the
anchorrecord component
-
spellField
public johnsmith.enchantmentcore.api.enchantment.spellfield.SpellFieldComponent spellField()Returns the value of thespellFieldrecord component.- Returns:
- the value of the
spellFieldrecord component
-