Package com.binaris.wizardry.content
Class Forfeit
java.lang.Object
com.binaris.wizardry.content.Forfeit
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 -
Constructor Summary
ConstructorsConstructorDescriptionForfeit(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 TypeMethodDescriptionvoidapply(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.ComponentgetMessage(net.minecraft.network.chat.Component implementName) Returns the forfeit message with the given implement name.net.minecraft.network.chat.ComponentReturns the forfeit message for when it is applied via a scroll.net.minecraft.network.chat.ComponentReturns the forfeit message for when it is applied via a wand.net.minecraft.resources.ResourceLocationgetName()Returns the name of this forfeit.net.minecraft.sounds.SoundEventgetSound()Returns the sound associated with this forfeit.Returns the spell tier associated with this forfeit.static voidHandles post-spell-cast events to discover the spell for the player if they have successfully cast it.static voidHandles pre-spell-cast events to potentially apply a forfeit to the player if they fail to cast the spell.
-
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
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
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
Returns the element associated with this forfeit.- Returns:
- The forfeit element.
-
getSpellTier
Returns the spell tier associated with this forfeit.- Returns:
- The forfeit spell tier.
-