Class Forfeit

java.lang.Object
com.binaris.wizardry.content.Forfeit

public class Forfeit extends Object
Abstract base class for all spell forfeits. A forfeit is a negative effect that is applied to the caster when they use a spell scroll or wand and the casts fail. Each forfeit has an associated sound and message that can be displayed to the player...
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final net.minecraft.sounds.SoundEvent
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Forfeit(String name, Element element, SpellTier spellTier, @Nullable BiConsumer<net.minecraft.world.level.Level,net.minecraft.world.entity.player.Player> effect)
     
    Forfeit(net.minecraft.resources.ResourceLocation name, Element element, SpellTier spellTier, @Nullable BiConsumer<net.minecraft.world.level.Level,net.minecraft.world.entity.player.Player> effect)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    apply(net.minecraft.world.level.Level world, net.minecraft.world.entity.player.Player player)
    Applies the forfeit to the given player in the given world.
    Returns the element associated with this forfeit.
    net.minecraft.network.chat.Component
    getMessage(net.minecraft.network.chat.Component implementName)
    Returns the forfeit message with the given implement name.
    net.minecraft.network.chat.Component
    Returns the forfeit message for when it is applied via a scroll.
    net.minecraft.network.chat.Component
    Returns the forfeit message for when it is applied via a wand.
    net.minecraft.resources.ResourceLocation
    Returns the name of this forfeit.
    net.minecraft.sounds.SoundEvent
    Returns the sound associated with this forfeit.
    Returns the spell tier associated with this forfeit.
    static void
    Handles post-spell-cast events to discover the spell for the player if they have successfully cast it.
    static void
    Handles pre-spell-cast events to potentially apply a forfeit to the player if they fail to cast the spell.

    Methods inherited from class java.lang.Object

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

    • sound

      protected final net.minecraft.sounds.SoundEvent sound
  • Constructor Details

    • Forfeit

      public Forfeit(net.minecraft.resources.ResourceLocation name, Element element, SpellTier spellTier, @Nullable @Nullable BiConsumer<net.minecraft.world.level.Level,net.minecraft.world.entity.player.Player> effect)
    • Forfeit

      public Forfeit(String name, Element element, SpellTier spellTier, @Nullable @Nullable BiConsumer<net.minecraft.world.level.Level,net.minecraft.world.entity.player.Player> effect)
  • Method Details

    • onSpellCastPreEvent

      public static void onSpellCastPreEvent(SpellCastEvent.Pre event)
      Handles pre-spell-cast events to potentially apply a forfeit to the player if they fail to cast the spell.
      Parameters:
      event - The spell cast pre event.
    • onSpellCastPostEvent

      public static void onSpellCastPostEvent(SpellCastEvent.Post event)
      Handles post-spell-cast events to discover the spell for the player if they have successfully cast it.
      Parameters:
      event - The spell cast post event.
    • apply

      public void apply(net.minecraft.world.level.Level world, net.minecraft.world.entity.player.Player player)
      Applies the forfeit to the given player in the given world. If there is no effect, this method does nothing (so addon devs can override this method if they want to implement custom behaviour). With an effect (BiConsumer with world and player parameters), it calls the effect.
      Parameters:
      world - The world in which to apply the effect.
      player - The player to whom the effect is applied.
    • getMessage

      public net.minecraft.network.chat.Component getMessage(net.minecraft.network.chat.Component implementName)
      Returns the forfeit message with the given implement name.
      Parameters:
      implementName - The name of the implement used to cast the spell.
      Returns:
      The forfeit message.
    • getMessageForWand

      public net.minecraft.network.chat.Component getMessageForWand()
      Returns the forfeit message for when it is applied via a wand.
      Returns:
      The forfeit message for wands.
    • getMessageForScroll

      public net.minecraft.network.chat.Component getMessageForScroll()
      Returns the forfeit message for when it is applied via a scroll.
      Returns:
      The forfeit message for scrolls.
    • getName

      public net.minecraft.resources.ResourceLocation getName()
      Returns the name of this forfeit.
      Returns:
      The forfeit name.
    • getSound

      public net.minecraft.sounds.SoundEvent getSound()
      Returns the sound associated with this forfeit.
      Returns:
      The forfeit sound.
    • getElement

      public Element getElement()
      Returns the element associated with this forfeit.
      Returns:
      The forfeit element.
    • getSpellTier

      public SpellTier getSpellTier()
      Returns the spell tier associated with this forfeit.
      Returns:
      The forfeit spell tier.