Record Class SpellCastContext
java.lang.Object
java.lang.Record
at.minecraftschurli.mods.arsmagicalegacy.api.spell.SpellCastContext
- Record Components:
spell- TheSpellthat is cast.level- TheLeveltheSpellis cast in.caster- TheLivingEntitycasting theSpell. May be null.directEntity- The entity applying theSpell, e.g. a projectile. May or may not be identical to the caster. May be null.hitResult- TheHitResultof the spell cast. May be null.consume- Whether to consume mana and burnout or not.awardXp- Whether to award xp or not.
public record SpellCastContext(Spell spell, net.minecraft.world.level.Level level, @Nullable net.minecraft.world.entity.LivingEntity caster, @Nullable net.minecraft.world.entity.Entity directEntity, @Nullable net.minecraft.world.phys.HitResult hitResult, boolean consume, boolean awardXp)
extends Record
The context of a spell cast, passed into many spell casting methods in
SpellHelper and related places.-
Constructor Summary
ConstructorsConstructorDescriptionSpellCastContext(Spell spell, net.minecraft.world.level.Level level, @Nullable net.minecraft.world.entity.LivingEntity caster, boolean consume, boolean awardXp) The context of a spell cast, passed into many spell casting methods inSpellHelperand related places.SpellCastContext(Spell spell, net.minecraft.world.level.Level level, @Nullable net.minecraft.world.entity.LivingEntity caster, @Nullable net.minecraft.world.entity.Entity directEntity, @Nullable net.minecraft.world.phys.HitResult hitResult, boolean consume, boolean awardXp) Creates an instance of aSpellCastContextrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbooleanawardXp()Returns the value of theawardXprecord component.@Nullable net.minecraft.world.entity.LivingEntitycaster()Returns the value of thecasterrecord component.booleanconsume()Returns the value of theconsumerecord component.@Nullable net.minecraft.world.entity.EntityReturns the value of thedirectEntityrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.@Nullable net.minecraft.world.phys.HitResultReturns the value of thehitResultrecord component.booleannet.minecraft.world.level.Levellevel()Returns the value of thelevelrecord component.setDirectEntity(net.minecraft.world.entity.Entity directEntity) setDirectEntityAndHitResult(net.minecraft.world.entity.Entity directEntity, net.minecraft.world.phys.HitResult hitResult) setHitResult(net.minecraft.world.phys.HitResult hitResult) spell()Returns the value of thespellrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
SpellCastContext
public SpellCastContext(Spell spell, net.minecraft.world.level.Level level, @Nullable net.minecraft.world.entity.LivingEntity caster, boolean consume, boolean awardXp) The context of a spell cast, passed into many spell casting methods in
SpellHelperand related places.This constructor is called when beginning a spell cast, as a direct entity and a hit result will never be present at that stage.
-
SpellCastContext
public SpellCastContext(Spell spell, net.minecraft.world.level.Level level, @Nullable net.minecraft.world.entity.LivingEntity caster, @Nullable net.minecraft.world.entity.Entity directEntity, @Nullable net.minecraft.world.phys.HitResult hitResult, boolean consume, boolean awardXp) Creates an instance of aSpellCastContextrecord class.- Parameters:
spell- the value for thespellrecord componentlevel- the value for thelevelrecord componentcaster- the value for thecasterrecord componentdirectEntity- the value for thedirectEntityrecord componenthitResult- the value for thehitResultrecord componentconsume- the value for theconsumerecord componentawardXp- the value for theawardXprecord component
-
-
Method Details
-
setSpell
-
setDirectEntity
- Parameters:
directEntity- The directEntityto set.- Returns:
- A new context object with the direct
Entityset.
-
setHitResult
- Parameters:
hitResult- TheHitResultto set.- Returns:
- A new context object with the
HitResultset.
-
setDirectEntityAndHitResult
public SpellCastContext setDirectEntityAndHitResult(net.minecraft.world.entity.Entity directEntity, net.minecraft.world.phys.HitResult hitResult) - Parameters:
directEntity- The directEntityto set.hitResult- TheHitResultto set.- Returns:
- A new context object with the direct
EntityandHitResultset.
-
isHitResultNullOrMiss
public boolean isHitResultNullOrMiss()- Returns:
- Whether the context's
HitResultis null or a miss, effectively meaning it should not be used.
-
toString
-
hashCode
-
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 thecomparemethod from their corresponding wrapper classes. -
spell
-
level
-
caster
-
directEntity
public @Nullable net.minecraft.world.entity.Entity directEntity()Returns the value of thedirectEntityrecord component.- Returns:
- the value of the
directEntityrecord component
-
hitResult
-
consume
-
awardXp
-