Record Class SpellCastContext

java.lang.Object
java.lang.Record
at.minecraftschurli.mods.arsmagicalegacy.api.spell.SpellCastContext
Record Components:
spell - The Spell that is cast.
level - The Level the Spell is cast in.
caster - The LivingEntity casting the Spell. May be null.
directEntity - The entity applying the Spell, e.g. a projectile. May or may not be identical to the caster. May be null.
hitResult - The HitResult of 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

    Constructors
    Constructor
    Description
    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 SpellHelper and 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 a SpellCastContext record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns the value of the awardXp record component.
    @Nullable net.minecraft.world.entity.LivingEntity
    Returns the value of the caster record component.
    boolean
    Returns the value of the consume record component.
    @Nullable net.minecraft.world.entity.Entity
    Returns the value of the directEntity record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    @Nullable net.minecraft.world.phys.HitResult
    Returns the value of the hitResult record component.
    boolean
     
    net.minecraft.world.level.Level
    Returns the value of the level record 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)
     
    setSpell(Spell spell)
     
    Returns the value of the spell record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class Object

    getClass, notify, notifyAll, wait, wait, wait
  • 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 SpellHelper and 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.

      Parameters:
      spell - The Spell that is cast.
      level - The Level the Spell is cast in.
      caster - The LivingEntity casting the Spell. May be null.
      consume - Whether to consume mana and burnout or not.
      awardXp - Whether to award xp or not.
    • 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 a SpellCastContext record class.
      Parameters:
      spell - the value for the spell record component
      level - the value for the level record component
      caster - the value for the caster record component
      directEntity - the value for the directEntity record component
      hitResult - the value for the hitResult record component
      consume - the value for the consume record component
      awardXp - the value for the awardXp record component
  • Method Details

    • setSpell

      public SpellCastContext setSpell(Spell spell)
      Parameters:
      spell - The Spell to set.
      Returns:
      A new context object with the Spell set.
    • setDirectEntity

      public SpellCastContext setDirectEntity(net.minecraft.world.entity.Entity directEntity)
      Parameters:
      directEntity - The direct Entity to set.
      Returns:
      A new context object with the direct Entity set.
    • setHitResult

      public SpellCastContext setHitResult(net.minecraft.world.phys.HitResult hitResult)
      Parameters:
      hitResult - The HitResult to set.
      Returns:
      A new context object with the HitResult set.
    • setDirectEntityAndHitResult

      public SpellCastContext setDirectEntityAndHitResult(net.minecraft.world.entity.Entity directEntity, net.minecraft.world.phys.HitResult hitResult)
      Parameters:
      directEntity - The direct Entity to set.
      hitResult - The HitResult to set.
      Returns:
      A new context object with the direct Entity and HitResult set.
    • isHitResultNullOrMiss

      public boolean isHitResultNullOrMiss()
      Returns:
      Whether the context's HitResult is null or a miss, effectively meaning it should not be used.
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • spell

      public Spell spell()
      Returns the value of the spell record component.
      Returns:
      the value of the spell record component
    • level

      public net.minecraft.world.level.Level level()
      Returns the value of the level record component.
      Returns:
      the value of the level record component
    • caster

      public @Nullable net.minecraft.world.entity.LivingEntity caster()
      Returns the value of the caster record component.
      Returns:
      the value of the caster record component
    • directEntity

      public @Nullable net.minecraft.world.entity.Entity directEntity()
      Returns the value of the directEntity record component.
      Returns:
      the value of the directEntity record component
    • hitResult

      public @Nullable net.minecraft.world.phys.HitResult hitResult()
      Returns the value of the hitResult record component.
      Returns:
      the value of the hitResult record component
    • consume

      public boolean consume()
      Returns the value of the consume record component.
      Returns:
      the value of the consume record component
    • awardXp

      public boolean awardXp()
      Returns the value of the awardXp record component.
      Returns:
      the value of the awardXp record component