Class MinionSpell<T extends net.minecraft.world.entity.Mob>
- Type Parameters:
T- The type of mob that is summoned by this spell.
- Direct Known Subclasses:
SummonIceGiant,SummonSkeleton,SummonSkeletonLegion,SummonWitherSkeleton,SummonZombie
Minions are spawned on the ground near the caster by default, but this can be changed to midair by calling
flying(boolean) with true as the argument. In this case, if no suitable ground position can be found within
the summon radius, they will be spawned at y=2 at a random horizontal position within the summon radius instead.
The process of creating the minion data and overwriting the original entity logic is handled by the MinionData
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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanWhether the minions are spawned in midair.static final StringAttribute Modifier idA factory that creates the minions.static final StringAttribute Modifier idprotected booleanTag if the minion shouldn't have it's base goals when created (e.g.protected booleanWhen the created minion should follow the ownerFields inherited from class com.binaris.wizardry.api.content.spell.Spell
pitch, pitchVariation, volume -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddMinionExtras(T minion, CastContext ctx, int alreadySpawned) Applies additional effects or modifications to the minion after it has been created and its lifetime has been set, but before it is added to the world.booleanWhether this spell can be cast by an entity source (e.g.booleanWhether this spell can be cast by a non-entity source (e.g.booleancast(EntityCastContext ctx) This cast method is meant to be used for spells that are cast by an entity source, like a mob.booleancast(LocationCastContext ctx) This cast method is meant to be used for spells that are not cast by an entity, but rather by a non-entity source, like a command block or a dispenser.booleancast(PlayerCastContext ctx) This cast method is meant to be used for spells that are cast by a player source.protected TcreateMinion(net.minecraft.world.level.Level world, @Nullable net.minecraft.world.entity.LivingEntity caster, SpellModifiers modifiers) Creates the minion entity.protected booleanextraConditions(CastContext ctx, net.minecraft.core.BlockPos containing) Checks additional conditions for whether the spell can be cast at the given location.flying(boolean flying) Sets whether the minions are spawned in midair.protected @NotNull SpellPropertiesThis method is where you should set the default properties for your spell when creating a new spell class.booleanWhether this spell requires a packet to be sent on client when it is cast.protected voidsetLifetime(T minion, int lifetime) Sets the lifetime of the minion on the MinionData.setSearchNearbyTargets(boolean searchNearbyTargets) Sets whether the minion should search for nearby targets and target them.setShouldDeleteGoals(boolean shouldDeleteGoals) Sets whether the minion shouldn't have its original goals, used to normally get rid of problematic goals that are in the base mob, this doesn't include the target goals.setShouldFollowOwner(boolean shouldFollowOwner) Sets whether the minions should follow their owner.protected booleanspawnMinions(CastContext ctx) Spawns the minions in the world.Methods inherited from class com.binaris.wizardry.api.content.spell.Spell
assignProperties, 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, soundValues, toString
-
Field Details
-
HEALTH_MODIFIER
Attribute Modifier id- See Also:
-
POTENCY_ATTRIBUTE_MODIFIER
Attribute Modifier id- See Also:
-
minionFactory
protected final Function<net.minecraft.world.level.Level,T extends net.minecraft.world.entity.Mob> minionFactoryA factory that creates the minions. -
flying
protected boolean flyingWhether the minions are spawned in midair. Defaults to false. -
shouldFollowOwner
protected boolean shouldFollowOwnerWhen the created minion should follow the owner -
shouldDeleteBaseGoals
protected boolean shouldDeleteBaseGoalsTag if the minion shouldn't have it's base goals when created (e.g. zombie breaks doors)
-
-
Constructor Details
-
MinionSpell
-
-
Method Details
-
setShouldFollowOwner
Sets whether the minions should follow their owner. Defaults to true.- Parameters:
shouldFollowOwner- True if the minions should follow their owner, false if they should stay in place.- Returns:
- The spell instance, allowing this method to be chained onto the constructor.
-
setShouldDeleteGoals
Sets whether the minion shouldn't have its original goals, used to normally get rid of problematic goals that are in the base mob, this doesn't include the target goals. Defaults to false.- Parameters:
shouldDeleteGoals- True if the mod should delete the base goals, false if they should stay the same- Returns:
- The spell instance, allowing this method to be chained onto the constructor.
-
setSearchNearbyTargets
Sets whether the minion should search for nearby targets and target them. The target conditions are: Doesn't attack owner's minions, can't attack allies minions and can't target passive mobs.- Parameters:
searchNearbyTargets- true to search nearby targets, false if they shouldn't have this goal- Returns:
- The spell instance, allowing this method to be chained onto the constructor.
-
flying
Sets whether the minions are spawned in midair.- Parameters:
flying- True to spawn the minions in midair, false to spawn them on the ground.- Returns:
- The spell instance, allowing this method to be chained onto the constructor.
-
canCastByLocation
public boolean canCastByLocation()Description copied from class:SpellWhether this spell can be cast by a non-entity source (e.g. a command block or a dispenser). By default, this returns false, as most spells are meant to be cast by entities, but you can override this to return true if your spell is designed to be cast by non-entity sources.- Overrides:
canCastByLocationin classSpell- Returns:
- true if this spell can be cast by a non-entity source, false otherwise.
-
canCastByEntity
public boolean canCastByEntity()Description copied from class:SpellWhether this spell can be cast by an entity source (e.g. a player or a mob). By default, this returns false, as some spells may be designed to only be cast by non-entity sources, but you can override this to return true if your spell is meant to be cast by entities.- Overrides:
canCastByEntityin classSpell- Returns:
- true if this spell can be cast by an entity source, false otherwise.
-
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.
-
cast
Description copied from class:SpellThis cast method is meant to be used for spells that are cast by an entity source, like a mob. This is useful for spells that are meant to be cast by entities, 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 entities.
- Overrides:
castin classSpell- Parameters:
ctx- The context of the spell cast, containing information about the world, caster, 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.
-
cast
Description copied from class:SpellThis cast method is meant to be used for spells that are not cast by an entity, but rather by a non-entity source, like a command block or a dispenser. This is useful for spells that are meant to be cast in a specific location without needing an entity to cast them. By default, this returns false, as most spells are meant to be cast by entities. You can override this to return true if your spell is meant to be cast by non-entity sources and to implement the casting behavior for that case.- Overrides:
castin classSpell- Parameters:
ctx- The context of the spell cast, containing information about the world, location, 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.
-
spawnMinions
Spawns the minions in the world. Handles finding suitable positions for the minions to be spawned at, creating the minion entities and adding them to the world. By default, this spawns the minions on the ground near the caster, but this can be changed by overriding this method or by using theflying(boolean)method to allow midair spawns.- Parameters:
ctx- The context of the spell cast, which may contain useful information for spawning the minions.- Returns:
- True if the minions were successfully spawned, false if there was an error (e.g. no suitable spawn position could be found).
-
setLifetime
Sets the lifetime of the minion on the MinionData. this gives you the opportunity to modify the lifetime of the minion after it has been created, but before it is added to the world.- Parameters:
minion- The minion to set the lifetime of.lifetime- The lifetime to set, in ticks.
-
createMinion
protected T createMinion(net.minecraft.world.level.Level world, @Nullable @Nullable net.minecraft.world.entity.LivingEntity caster, SpellModifiers modifiers) Creates the minion entity. This is called during the casting process, and allows you to modify the minion before it is added to the world by applying modifiers or passing the caster as an argument. By default, this just calls the minion factory, but it can be overridden to provide more complex behavior.- Parameters:
world- The world the minion is being created in.caster- The caster of the spell, if available. This may be null if the spell is being cast by a non-entity or if the caster is not available for some reason.modifiers- The spell modifiers that may affect the minion's attributes or behavior.- Returns:
- The created minion entity.
-
addMinionExtras
Applies additional effects or modifications to the minion after it has been created and its lifetime has been set, but before it is added to the world. This is called for each minion that is spawned, and allows you to apply spell-specific behavior or effects to the minions.- Parameters:
minion- The minion entity that has been created and had its lifetime set, but has not yet been added to the world.ctx- The context of the spell cast, which may contain useful information for modifying the minion.alreadySpawned- The number of minions that have already been spawned by this spell cast. This can be used to apply different effects to different minions if multiple are spawned.
-
extraConditions
Checks additional conditions for whether the spell can be cast at the given location. This is called during the casting process, and allows you to prevent the spell from being cast if certain conditions are not met.- Parameters:
ctx- The context of the spell cast, which may contain useful information for checking the conditions.containing- The block position that the minions will be spawned around. This can be used to check if the location is suitable for spawning minions.- Returns:
- True if the spell can be cast at the given location, false otherwise.
-
requiresPacket
public boolean requiresPacket()Description copied from class:SpellWhether this spell requires a packet to be sent on client when it is cast. Returns true by default, but can be overridden to return false if the spell's cast() method does not use any code that must be executed client-side (i.e. particle spawning).If in doubt, leave this method as is; it is purely an optimization.
- Overrides:
requiresPacketin classSpell- Returns:
- true if the spell code should be run on the server and all clients in the dimension, false if the spell code should only be run on the server and the client of the player casting it.
-
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.
-