Class BlockTransfiguration

Direct Known Subclasses:
AGUAMENTI, AQUA_ERUCTO, BlockToEntityTransfiguration, DURO, FATUUS_AURUM, GlaciusSuper, PYROSVESTIRAS, SPONGIFY, TERGEO

public abstract class BlockTransfiguration extends TransfigurationBase
Abstract base class for block transfiguration spells.

Manages the transfiguration of blocks and terrain into other material types. Provides core transfiguration logic including block targeting, type validation, success rate checking, and reversion. Block transfigurations can be temporary (reverted after spell duration) or permanent.

Subclasses must override this class to define specific block transformation behavior. Configuration of transfigureType (target material) and optionally transfigurationMap (mapping of source materials to different targets) should be done in subclass constructors.

Affected blocks are validated against WorldGuard BUILD flag if enabled, and against material block and allow lists defined in the configuration.

See Also:
  • Field Details

    • transfigurationMap

      protected Map<org.bukkit.Material,org.bukkit.Material> transfigurationMap
      If this is populated, any material type key will be changed to the value
    • radius

      protected int radius
      How many blocks out from the target are affects. Usually for permanent spells this is 1.
  • Constructor Details

    • BlockTransfiguration

      public BlockTransfiguration(Ollivanders2 plugin)
      Default constructor for use in generating spell text. Do not use to cast the spell.
      Parameters:
      plugin - the Ollivanders2 plugin
    • BlockTransfiguration

      public BlockTransfiguration(@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

    • transfigure

      protected void transfigure()
      Transfigures blocks in a radius around the spell's target location.

      This method is called each tick while the spell is active. It identifies all blocks within the spell's radius from the target location and attempts to transfigure them. The radius is modified by radiusModifier and clamped between minRadius and maxRadius.

      For permanent spells, the spell is immediately killed after transfiguration. For temporary spells, the spell continues until its duration expires.

      Validation checks are performed via canTransfigure(Block) for each block:

      • Success rate check must pass (based on player skill)
      • Block cannot already be the target material type
      • Block cannot be on the material blocked list (unbreakable materials)
      • Block must be on the allow list if one is populated
      • Block cannot already be transfigured by another active spell

      If no blocks are successfully transfigured, the spell fails and is killed.

    • revert

      public void revert()
      Restores all transfigured blocks to their original material types.

      Called when the spell duration expires or the spell is explicitly ended. This method only applies to temporary (non-permanent) transfigurations. Permanent transfigurations are not reverted and the spell should be killed immediately after transfiguration.

      Iterates through all blocks stored in changedBlocks and restores each block to its original material type. After all blocks are reverted, clears the changedBlocks map and calls doRevert() for any subclass-specific cleanup.

      Specified by:
      revert in class TransfigurationBase
    • isBlockTransfigured

      public boolean isBlockTransfigured(@NotNull @NotNull org.bukkit.block.Block block)
      Is this spell currently affecting this block?
      Specified by:
      isBlockTransfigured in class TransfigurationBase
      Parameters:
      block - the block to check
      Returns:
      true if this spell is affecting this block, false otherwise
    • isEntityTransfigured

      public boolean isEntityTransfigured(@NotNull @NotNull org.bukkit.entity.Entity entity)
      Check if an entity is transfigured by this spell.

      Always returns false for block transfiguration spells, as they only affect blocks. Entity transfigurations are handled by EntityTransfiguration.

      Specified by:
      isEntityTransfigured in class TransfigurationBase
      Parameters:
      entity - the entity to check
      Returns:
      false, as block transfiguration spells do not affect entities