Class EntityTransfiguration

Direct Known Subclasses:
EntityDisguise, EVANESCO, ItemToEntityTransfiguration, ItemToItemTransfiguration, LivingEntityToItemTransfiguration

public abstract class EntityTransfiguration extends TransfigurationBase
Abstract base class for entity transfiguration spells.

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:
  • Constructor Details

    • EntityTransfiguration

      public EntityTransfiguration(Ollivanders2 plugin)
      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 plugin
      player - the player who cast this spell
      rightWand - 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:
      revert in class TransfigurationBase
    • isBlockTransfigured

      public boolean isBlockTransfigured(@NotNull @NotNull org.bukkit.block.Block block)
      Is this block transfigured by this spell
      Specified by:
      isBlockTransfigured in class TransfigurationBase
      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:
      isEntityTransfigured in class TransfigurationBase
      Parameters:
      entity - the entity to check
      Returns:
      true if transfigured, false otherwise