Class BlockTransfiguration
- Direct Known Subclasses:
AGUAMENTI,AQUA_ERUCTO,BlockToEntityTransfiguration,DURO,FATUUS_AURUM,GlaciusSuper,PYROSVESTIRAS,SPONGIFY,TERGEO
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 Summary
FieldsModifier and TypeFieldDescriptionprotected intHow many blocks out from the target are affects.protected Map<org.bukkit.Material, org.bukkit.Material> If this is populated, any material type key will be changed to the valueFields 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
ConstructorsConstructorDescriptionBlockTransfiguration(@NotNull Ollivanders2 plugin, @NotNull org.bukkit.entity.Player player, @NotNull Double rightWand) Constructor.BlockTransfiguration(Ollivanders2 plugin) Default constructor for use in generating spell text. -
Method Summary
Modifier and TypeMethodDescriptionbooleanisBlockTransfigured(@NotNull org.bukkit.block.Block block) Is this spell currently affecting this block?booleanisEntityTransfigured(@NotNull org.bukkit.entity.Entity entity) Check if an entity is transfigured by this spell.voidrevert()Restores all transfigured blocks to their original material types.protected voidTransfigures blocks in a radius around the spell's target location.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
-
Field Details
-
transfigurationMap
If this is populated, any material type key will be changed to the value -
radius
protected int radiusHow many blocks out from the target are affects. Usually for permanent spells this is 1.
-
-
Constructor Details
-
BlockTransfiguration
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 pluginplayer- the player who cast this spellrightWand- 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
radiusModifierand clamped betweenminRadiusandmaxRadius.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
changedBlocksand restores each block to its original material type. After all blocks are reverted, clears the changedBlocks map and callsdoRevert()for any subclass-specific cleanup.- Specified by:
revertin classTransfigurationBase
-
isBlockTransfigured
public boolean isBlockTransfigured(@NotNull @NotNull org.bukkit.block.Block block) Is this spell currently affecting this block?- Specified by:
isBlockTransfiguredin classTransfigurationBase- 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:
isEntityTransfiguredin classTransfigurationBase- Parameters:
entity- the entity to check- Returns:
- false, as block transfiguration spells do not affect entities
-