Record Class TemporaryTransmuteBlockEffect
java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.spellfield.effect.block.TemporaryTransmuteBlockEffect
- Record Components:
targetBlocks- An optionalHolderSetwhitelist of blocks eligible for transmutation.replacementBlock- The temporary replacementBlockto place.lifetime- TheLevelBasedValueduration (in ticks) the transmuted block remains stable before decaying.decayDuration- TheLevelBasedValueduration (in ticks) of the block-breaking crack animation prior to restoration.evaluator- TheTopologyEvaluatorgoverning deterministic threshold or probabilistic block selection.
- All Implemented Interfaces:
SpellFieldBlockEffect, SpellFieldEffect
public record TemporaryTransmuteBlockEffect(Optional<net.minecraft.core.HolderSet<net.minecraft.world.level.block.Block>> targetBlocks, net.minecraft.world.level.block.Block replacementBlock, net.minecraft.world.item.enchantment.LevelBasedValue lifetime, net.minecraft.world.item.enchantment.LevelBasedValue decayDuration, TopologyEvaluator evaluator)
extends Record
implements SpellFieldBlockEffect
A
SpellFieldBlockEffect that temporarily transmutes existing non-air blocks into a replacement
Block and schedules automatic restoration of the original block state and BlockEntity data.
Prevents permanent griefing across chunk unloads and reloads by verifying that the target chunk is actively
ticking blocks and by querying TransientBlockTracker.getOriginalState(BlockPos) before reading
from the world, ensuring repeated anchor ticks never mistake the transmuted block for the original block.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec<TemporaryTransmuteBlockEffect> MapCodec for serializing and deserializingTemporaryTransmuteBlockEffectdefinitions.static final StringJSON field key for the visual crack decay duration in ticks.static final StringJSON field key for the topological threshold/probability evaluator.static final StringRegistry path identifier for this spell field block effect.static final LevelBasedKeyProviderSupplies the JSON property keys that holdLevelBasedValuedefinitions for data transformation.static final StringJSON field key for the stable lifetime duration in ticks.static final StringJSON field key for the temporary replacement block.static final StringJSON field key for the optional whitelist of eligible target blocks. -
Constructor Summary
ConstructorsConstructorDescriptionTemporaryTransmuteBlockEffect(Optional<net.minecraft.core.HolderSet<net.minecraft.world.level.block.Block>> targetBlocks, net.minecraft.world.level.block.Block replacementBlock, net.minecraft.world.item.enchantment.LevelBasedValue lifetime, net.minecraft.world.item.enchantment.LevelBasedValue decayDuration, TopologyEvaluator evaluator) Creates an instance of aTemporaryTransmuteBlockEffectrecord class.TemporaryTransmuteBlockEffect(net.minecraft.core.HolderSet<net.minecraft.world.level.block.Block> targetBlocks, net.minecraft.world.level.block.Block replacementBlock, net.minecraft.world.item.enchantment.LevelBasedValue lifetime, net.minecraft.world.item.enchantment.LevelBasedValue decayDuration) Constructs aTemporaryTransmuteBlockEffectrestricted to a specific target block set using the defaultTopologyEvaluator.PROBABILISTICevaluator.TemporaryTransmuteBlockEffect(net.minecraft.world.level.block.Block replacementBlock, net.minecraft.world.item.enchantment.LevelBasedValue lifetime, net.minecraft.world.item.enchantment.LevelBasedValue decayDuration) Constructs an unrestrictedTemporaryTransmuteBlockEffectthat can transmute any breakable non-air block using the defaultTopologyEvaluator.PROBABILISTICevaluator. -
Method Summary
Modifier and TypeMethodDescriptionvoidapply(net.minecraft.server.level.ServerLevel level, int enchantmentLevel, net.minecraft.world.item.enchantment.EnchantedItemInUse context, net.minecraft.world.entity.Entity spatialReference, net.minecraft.world.phys.Vec3 epicenter, net.minecraft.core.BlockPos pos, float scalar, Set<net.minecraft.core.BlockPos> modifiedBlocks) Executes the temporary block transmutation at the specified coordinate and schedules restoration withTransientBlockTracker.com.mojang.serialization.MapCodec<? extends SpellFieldBlockEffect> codec()Retrieves theMapCodecresponsible for serializing and deserializing this effect.net.minecraft.world.item.enchantment.LevelBasedValueReturns the value of thedecayDurationrecord component.final booleanIndicates whether some other object is "equal to" this one.Returns the value of theevaluatorrecord component.floatgetPriority(int enchantmentLevel) Returns the execution priority of this block effect based on the evaluator's threshold.final inthashCode()Returns a hash code value for this object.net.minecraft.world.item.enchantment.LevelBasedValuelifetime()Returns the value of thelifetimerecord component.net.minecraft.world.level.block.BlockReturns the value of thereplacementBlockrecord component.Optional<net.minecraft.core.HolderSet<net.minecraft.world.level.block.Block>> Returns the value of thetargetBlocksrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
TARGET_BLOCKS
JSON field key for the optional whitelist of eligible target blocks.- See Also:
-
REPLACEMENT_BLOCK
JSON field key for the temporary replacement block.- See Also:
-
LIFETIME
JSON field key for the stable lifetime duration in ticks.- See Also:
-
DECAY_DURATION
JSON field key for the visual crack decay duration in ticks.- See Also:
-
EVALUATOR
JSON field key for the topological threshold/probability evaluator.- See Also:
-
KEY
Registry path identifier for this spell field block effect.- See Also:
-
KEY_PROVIDER
Supplies the JSON property keys that holdLevelBasedValuedefinitions for data transformation. -
CODEC
MapCodec for serializing and deserializingTemporaryTransmuteBlockEffectdefinitions.
-
-
Constructor Details
-
TemporaryTransmuteBlockEffect
public TemporaryTransmuteBlockEffect(net.minecraft.core.HolderSet<net.minecraft.world.level.block.Block> targetBlocks, net.minecraft.world.level.block.Block replacementBlock, net.minecraft.world.item.enchantment.LevelBasedValue lifetime, net.minecraft.world.item.enchantment.LevelBasedValue decayDuration) Constructs aTemporaryTransmuteBlockEffectrestricted to a specific target block set using the defaultTopologyEvaluator.PROBABILISTICevaluator.- Parameters:
targetBlocks- The whitelist of blocks eligible for transmutation.replacementBlock- The temporary replacement block.lifetime- The stable duration in ticks before decay begins.decayDuration- The crack animation duration in ticks before restoration.
-
TemporaryTransmuteBlockEffect
public TemporaryTransmuteBlockEffect(net.minecraft.world.level.block.Block replacementBlock, net.minecraft.world.item.enchantment.LevelBasedValue lifetime, net.minecraft.world.item.enchantment.LevelBasedValue decayDuration) Constructs an unrestrictedTemporaryTransmuteBlockEffectthat can transmute any breakable non-air block using the defaultTopologyEvaluator.PROBABILISTICevaluator.- Parameters:
replacementBlock- The temporary replacement block.lifetime- The stable duration in ticks before decay begins.decayDuration- The crack animation duration in ticks before restoration.
-
TemporaryTransmuteBlockEffect
public TemporaryTransmuteBlockEffect(Optional<net.minecraft.core.HolderSet<net.minecraft.world.level.block.Block>> targetBlocks, net.minecraft.world.level.block.Block replacementBlock, net.minecraft.world.item.enchantment.LevelBasedValue lifetime, net.minecraft.world.item.enchantment.LevelBasedValue decayDuration, TopologyEvaluator evaluator) Creates an instance of aTemporaryTransmuteBlockEffectrecord class.- Parameters:
targetBlocks- the value for thetargetBlocksrecord componentreplacementBlock- the value for thereplacementBlockrecord componentlifetime- the value for thelifetimerecord componentdecayDuration- the value for thedecayDurationrecord componentevaluator- the value for theevaluatorrecord component
-
-
Method Details
-
getPriority
public float getPriority(int enchantmentLevel) Returns the execution priority of this block effect based on the evaluator's threshold.- Specified by:
getPriorityin interfaceSpellFieldBlockEffect- Parameters:
enchantmentLevel- The active level of the enchantment.- Returns:
- The priority scalar.
-
apply
public void apply(net.minecraft.server.level.ServerLevel level, int enchantmentLevel, net.minecraft.world.item.enchantment.EnchantedItemInUse context, net.minecraft.world.entity.Entity spatialReference, net.minecraft.world.phys.Vec3 epicenter, net.minecraft.core.BlockPos pos, float scalar, Set<net.minecraft.core.BlockPos> modifiedBlocks) Executes the temporary block transmutation at the specified coordinate and schedules restoration withTransientBlockTracker.Skips coordinates in unloaded or non-ticking chunks via
Level.shouldTickBlocksAt(BlockPos). Evaluates target block predicates against the true originalBlockState(retrieved fromTransientBlockTracker.getOriginalState(BlockPos)if already transmuted) so that persistent spell fields can refresh transmutation timers without clobbering the original block state or NBT.- Specified by:
applyin interfaceSpellFieldBlockEffect- Parameters:
level- The executing server level.enchantmentLevel- The level of the spell field enchantment.context- The item usage context triggering the spell field.spatialReference- The anchor entity or focal point of the spell field.epicenter- The exact spatial origin vector of the spell field.pos- The target block coordinate.scalar- The active topological multiplier for the target.modifiedBlocks- A mutable set tracking all block coordinates modified during this execution cycle.
-
codec
Description copied from interface:SpellFieldEffectRetrieves theMapCodecresponsible for serializing and deserializing this effect.- Specified by:
codecin interfaceSpellFieldEffect- Returns:
- The registered
MapCodecinstance.
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
targetBlocks
Returns the value of thetargetBlocksrecord component.- Returns:
- the value of the
targetBlocksrecord component
-
replacementBlock
public net.minecraft.world.level.block.Block replacementBlock()Returns the value of thereplacementBlockrecord component.- Returns:
- the value of the
replacementBlockrecord component
-
lifetime
-
decayDuration
public net.minecraft.world.item.enchantment.LevelBasedValue decayDuration()Returns the value of thedecayDurationrecord component.- Returns:
- the value of the
decayDurationrecord component
-
evaluator
-