Class ConjureItemSpell
java.lang.Object
com.binaris.wizardry.api.content.spell.Spell
com.binaris.wizardry.content.spell.abstr.ConjureItemSpell
- Direct Known Subclasses:
ConjureArmor,Flamecatcher,FlamingAxe,FrostAxe
Base class for spells that conjure items. This class provides the core functionality for conjuring an item and managing
its lifetime through the use of ConjureData. It also includes a static set of supported items that can be conjured, and
utility methods for checking if an item is summonable or currently summoned (you normally won't use this directly when
creating a spell). This can only be used by player casts.
Adding an item to conjure by this spell makes it to always contain a ConjureData.
Check Spells.CONJURE_SWORD and Spells.FLAMECATCHER for examples of how to create conjure item spells.
You must override the properties() to return an actual instance of SpellProperties for this spell or
use Spell.assignProperties(SpellProperties), otherwise the spell will have no properties and may not function
as intended.
- See Also:
-
Field Summary
FieldsFields inherited from class com.binaris.wizardry.api.content.spell.Spell
pitch, pitchVariation, volume -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected net.minecraft.world.item.ItemStackaddItemExtras(PlayerCastContext ctx, net.minecraft.world.item.ItemStack stack) Adds extra properties or NBT data to the conjured item stack before it is given to the caster.booleancast(PlayerCastContext ctx) This cast method is meant to be used for spells that are cast by a player source.protected booleanConjures the item for the caster.static booleanisSummonableItem(net.minecraft.world.item.Item item) Checks if the given item is part of the supported conjure items inside the mod.static booleanisSummonableItem(net.minecraft.world.item.ItemStack stack) Checks if the given item stack is part of the supported conjure items inside the mod.static booleanisSummoned(net.minecraft.world.item.ItemStack stack) Checks if the given item stack is currently summoned (i.e.protected @NotNull SpellPropertiesThis method is where you should set the default properties for your spell when creating a new spell class.static voidregisterSupportedItem(net.minecraft.world.item.Item item) Registers an item as a supported conjure item.protected voidSpawns spark particles around the caster.Methods inherited from class com.binaris.wizardry.api.content.spell.Spell
assignProperties, canCastByEntity, canCastByLocation, cast, cast, endCast, equals, getAction, getChargeUp, getCooldown, getCost, getDesc, getDescriptionFormatted, getDescriptionId, getElement, getIcon, getLocation, getLoopSounds, getOrCreateDescriptionId, getOrCreateLocation, getPitch, getPitchVariation, getProperties, getTier, getType, getVolume, isEnabled, isInstantCast, onCharge, playSound, playSound, playSound, playSoundLoop, playSoundLoop, property, requiresPacket, soundValues, toString
-
Field Details
-
SUPPORTED_ITEMS
-
-
Constructor Details
-
ConjureItemSpell
public ConjureItemSpell(net.minecraft.world.item.Item item)
-
-
Method Details
-
cast
Description copied from class:SpellThis cast method is meant to be used for spells that are cast by a player source. This is useful for spells that are meant to be cast by players, as it provides more information about the caster and the context of the cast.Override this method to implement the casting behavior for spells that are meant to be cast by players.
- Specified by:
castin classSpell- Parameters:
ctx- The context of the spell cast, containing information about the world, caster, hand used, modifiers, etc.- Returns:
- true if the spell was successfully cast, false otherwise. If this returns false, the spell will not be considered as having been cast, so no cooldown will be applied.
-
conjureItem
Conjures the item for the caster. This method creates an ItemStack of the specified item, gets the conjure data for it and establishes the duration and expiration time based on the spell properties and modifiers. The conjure data is then associated with the item stack, and the item is added to the caster's inventory. If the caster's inventory is full, a message is sent to the player and the method returns false.- Parameters:
ctx- the context of the spell cast, containing information about the caster, the world, and the spell modifiers- Returns:
- true if the item was successfully conjured and added to the caster's inventory, false otherwise
- See Also:
-
isSummoned
public static boolean isSummoned(net.minecraft.world.item.ItemStack stack) Checks if the given item stack is currently summoned (i.e. conjured and not expired). The item must also be part of the supported conjure items inside the mod. For a check of whether an item is part of the supported conjure items (not checking if it is summoned), useisSummonableItem(ItemStack).- Parameters:
stack- the item stack to check- Returns:
- true if the item stack is currently summoned, false otherwise
-
isSummonableItem
public static boolean isSummonableItem(net.minecraft.world.item.Item item) Checks if the given item is part of the supported conjure items inside the mod. For a better check of whether an item is actually summoned, useisSummoned(ItemStack).- Parameters:
item- the item to check- Returns:
- true if the item is part of the supported conjure items, false otherwise
-
isSummonableItem
public static boolean isSummonableItem(net.minecraft.world.item.ItemStack stack) Checks if the given item stack is part of the supported conjure items inside the mod. For a better check of whether an item is actually summoned, useisSummoned(ItemStack).- Parameters:
stack- the item stack to check- Returns:
- true if the item stack is part of the supported conjure items, false otherwise
-
registerSupportedItem
public static void registerSupportedItem(net.minecraft.world.item.Item item) Registers an item as a supported conjure item. This should be called in the constructor of any spell that conjures an item or in your mod's common setup. If an item is not registered as a supported conjure item, it will not be recognized as a valid and won't have the conjure data associated with it.- Parameters:
item- the item to register as a supported conjure item
-
spawnParticles
Spawns spark particles around the caster. This is a client-side visual effect that is called when the spell is cast. The particles are spawned in a random pattern around the caster's head and have a light blue color.You could override this to change the particle effect.
- Parameters:
ctx- the context of the spell cast, containing information about the caster and the world
-
addItemExtras
protected net.minecraft.world.item.ItemStack addItemExtras(PlayerCastContext ctx, net.minecraft.world.item.ItemStack stack) Adds extra properties or NBT data to the conjured item stack before it is given to the caster. This method is called during the conjuration process and allows you to customize the item stack based on the spell context. By default, this method returns the original item stack without any modifications.- Parameters:
ctx- the context of the spell cast, containing information about the caster, the world, and the spell modifiersstack- the original item stack that is about to be conjured- Returns:
- the modified item stack with any additional properties or NBT data added
-
properties
Description copied from class:SpellThis method is where you should set the default properties for your spell when creating a new spell class. This method is called in the constructor of the Spell class, and the properties returned by this method are assigned to the spell's properties field.- Specified by:
propertiesin classSpell- Returns:
- A SpellProperties object with the default properties for your spell.
-