Class EntityTransfiguration
- Direct Known Subclasses:
EntityDisguise,EVANESCO,ItemToEntityTransfiguration,ItemToItemTransfiguration,LivingEntityToItemTransfiguration
Manages the transfiguration of living entities (mobs, animals) into other entity types. Provides core transfiguration logic including entity targeting, type validation, and reversion. Entity transfigurations are always temporary (non-permanent) and will be reverted when the spell duration expires or the spell is explicitly reverted.
Subclasses must implement transfigureEntity(Entity) to define the actual transformation logic.
- See Also:
-
Field Summary
Fields inherited from class net.pottercraft.ollivanders2.spell.TransfigurationBase
successRateFields inherited from class net.pottercraft.ollivanders2.spell.O2Spell
branch, cooldownMessage, defaultRadius, flavorText, isAllowedFailureMessage, location, maxProjectileDistance, maxSpellLifetime, noProjectile, player, rightWand, spellMasteryLevel, spellType, text, usesModifier, vector -
Constructor Summary
ConstructorsConstructorDescriptionEntityTransfiguration(@NotNull Ollivanders2 plugin, @NotNull org.bukkit.entity.Player player, @NotNull Double rightWand) Constructor.EntityTransfiguration(Ollivanders2 plugin) Default constructor for use in generating spell text. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleancanTransfigure(@NotNull org.bukkit.entity.Entity entity) Determine if this entity can be transfigured by this spell.booleanisBlockTransfigured(@NotNull org.bukkit.block.Block block) Is this block transfigured by this spellbooleanisEntityTransfigured(@NotNull org.bukkit.entity.Entity entity) Is this entity transfigured by this spellprotected voidrevert()Revert the transfigured entity back to its original state.protected abstract @Nullable org.bukkit.entity.EntitytransfigureEntity(@NotNull org.bukkit.entity.Entity entity) Transfigures entity into new EntityType.Methods inherited from class net.pottercraft.ollivanders2.spell.TransfigurationBase
doCheckEffect, isConsumeOriginal, isPermanent, isTransfiguredMethods inherited from class net.pottercraft.ollivanders2.spell.O2Spell
checkEffect, getCloseEntities, getCoolDown, getFailureMessage, getFlavorText, getLevel, getLifeTicks, getMagicBranch, getName, getNearbyDamageableEntities, getNearbyItems, getNearbyLivingEntities, getNearbyPlayers, getSuccessMessage, getTargetBlock, getText, getWorldGuardFlags, hasHitTarget, isAtMaxDistance, isKilled, isSpellAllowed, kill, move, sendFailureMessage, sendSuccessMessage, setUsesModifier
-
Constructor Details
-
EntityTransfiguration
Default constructor for use in generating spell text. Do not use to cast the spell.- Parameters:
plugin- the Ollivanders2 plugin
-
EntityTransfiguration
public EntityTransfiguration(@NotNull @NotNull Ollivanders2 plugin, @NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull Double rightWand) Constructor.- Parameters:
plugin- a callback to the MC pluginplayer- the player who cast this spellrightWand- which wand the player was using
-
-
Method Details
-
canTransfigure
protected boolean canTransfigure(@NotNull @NotNull org.bukkit.entity.Entity entity) Determine if this entity can be transfigured by this spell.- Parameters:
entity- the entity to check- Returns:
- true if the entity can be transfigured, false otherwise.
-
transfigureEntity
@Nullable protected abstract @Nullable org.bukkit.entity.Entity transfigureEntity(@NotNull @NotNull org.bukkit.entity.Entity entity) Transfigures entity into new EntityType.- Parameters:
entity- the entity to transfigure- Returns:
- the transfigured entity
-
revert
protected void revert()Revert the transfigured entity back to its original state.Removes the transfigured entity from the world and restores the original entity if the spell was not set to consume the original. For regular entities, respawns the original entity with preserved properties. For Items and FallingBlocks, drops or respawns them appropriately. If the transfigured entity has inventory (is an InventoryHolder), drops all inventory contents before removal.
This method also calls
doRevert()to allow subclasses to perform spell-specific cleanup beyond basic reversion.- Specified by:
revertin classTransfigurationBase
-
isBlockTransfigured
public boolean isBlockTransfigured(@NotNull @NotNull org.bukkit.block.Block block) Is this block transfigured by this spell- Specified by:
isBlockTransfiguredin classTransfigurationBase- Parameters:
block- the block to check- Returns:
- true if transfigured, false otherwise
-
isEntityTransfigured
public boolean isEntityTransfigured(@NotNull @NotNull org.bukkit.entity.Entity entity) Is this entity transfigured by this spell- Specified by:
isEntityTransfiguredin classTransfigurationBase- Parameters:
entity- the entity to check- Returns:
- true if transfigured, false otherwise
-