Record Class TemporaryTransmuteBlockEffect

java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.spellfield.effect.block.TemporaryTransmuteBlockEffect
Record Components:
targetBlocks - An optional HolderSet whitelist of blocks eligible for transmutation.
replacementBlock - The temporary replacement Block to place.
lifetime - The LevelBasedValue duration (in ticks) the transmuted block remains stable before decaying.
decayDuration - The LevelBasedValue duration (in ticks) of the block-breaking crack animation prior to restoration.
evaluator - The TopologyEvaluator governing 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

    Fields
    Modifier and Type
    Field
    Description
    static final com.mojang.serialization.MapCodec<TemporaryTransmuteBlockEffect>
    MapCodec for serializing and deserializing TemporaryTransmuteBlockEffect definitions.
    static final String
    JSON field key for the visual crack decay duration in ticks.
    static final String
    JSON field key for the topological threshold/probability evaluator.
    static final String
    Registry path identifier for this spell field block effect.
    Supplies the JSON property keys that hold LevelBasedValue definitions for data transformation.
    static final String
    JSON field key for the stable lifetime duration in ticks.
    static final String
    JSON field key for the temporary replacement block.
    static final String
    JSON field key for the optional whitelist of eligible target blocks.
  • Constructor Summary

    Constructors
    Constructor
    Description
    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 a TemporaryTransmuteBlockEffect record 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 a TemporaryTransmuteBlockEffect restricted to a specific target block set using the default TopologyEvaluator.PROBABILISTIC evaluator.
    TemporaryTransmuteBlockEffect(net.minecraft.world.level.block.Block replacementBlock, net.minecraft.world.item.enchantment.LevelBasedValue lifetime, net.minecraft.world.item.enchantment.LevelBasedValue decayDuration)
    Constructs an unrestricted TemporaryTransmuteBlockEffect that can transmute any breakable non-air block using the default TopologyEvaluator.PROBABILISTIC evaluator.
  • Method Summary

    Modifier and Type
    Method
    Description
    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 with TransientBlockTracker.
    com.mojang.serialization.MapCodec<? extends SpellFieldBlockEffect>
    Retrieves the MapCodec responsible for serializing and deserializing this effect.
    net.minecraft.world.item.enchantment.LevelBasedValue
    Returns the value of the decayDuration record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    Returns the value of the evaluator record component.
    float
    getPriority(int enchantmentLevel)
    Returns the execution priority of this block effect based on the evaluator's threshold.
    final int
    Returns a hash code value for this object.
    net.minecraft.world.item.enchantment.LevelBasedValue
    Returns the value of the lifetime record component.
    net.minecraft.world.level.block.Block
    Returns the value of the replacementBlock record component.
    Optional<net.minecraft.core.HolderSet<net.minecraft.world.level.block.Block>>
    Returns the value of the targetBlocks record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • TARGET_BLOCKS

      public static final String TARGET_BLOCKS
      JSON field key for the optional whitelist of eligible target blocks.
      See Also:
    • REPLACEMENT_BLOCK

      public static final String REPLACEMENT_BLOCK
      JSON field key for the temporary replacement block.
      See Also:
    • LIFETIME

      public static final String LIFETIME
      JSON field key for the stable lifetime duration in ticks.
      See Also:
    • DECAY_DURATION

      public static final String DECAY_DURATION
      JSON field key for the visual crack decay duration in ticks.
      See Also:
    • EVALUATOR

      public static final String EVALUATOR
      JSON field key for the topological threshold/probability evaluator.
      See Also:
    • KEY

      public static final String KEY
      Registry path identifier for this spell field block effect.
      See Also:
    • KEY_PROVIDER

      public static final LevelBasedKeyProvider KEY_PROVIDER
      Supplies the JSON property keys that hold LevelBasedValue definitions for data transformation.
    • CODEC

      public static final com.mojang.serialization.MapCodec<TemporaryTransmuteBlockEffect> CODEC
      MapCodec for serializing and deserializing TemporaryTransmuteBlockEffect definitions.
  • 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 a TemporaryTransmuteBlockEffect restricted to a specific target block set using the default TopologyEvaluator.PROBABILISTIC evaluator.
      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 unrestricted TemporaryTransmuteBlockEffect that can transmute any breakable non-air block using the default TopologyEvaluator.PROBABILISTIC evaluator.
      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 a TemporaryTransmuteBlockEffect record class.
      Parameters:
      targetBlocks - the value for the targetBlocks record component
      replacementBlock - the value for the replacementBlock record component
      lifetime - the value for the lifetime record component
      decayDuration - the value for the decayDuration record component
      evaluator - the value for the evaluator record 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:
      getPriority in interface SpellFieldBlockEffect
      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 with TransientBlockTracker.

      Skips coordinates in unloaded or non-ticking chunks via Level.shouldTickBlocksAt(BlockPos). Evaluates target block predicates against the true original BlockState (retrieved from TransientBlockTracker.getOriginalState(BlockPos) if already transmuted) so that persistent spell fields can refresh transmutation timers without clobbering the original block state or NBT.

      Specified by:
      apply in interface SpellFieldBlockEffect
      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

      public com.mojang.serialization.MapCodec<? extends SpellFieldBlockEffect> codec()
      Description copied from interface: SpellFieldEffect
      Retrieves the MapCodec responsible for serializing and deserializing this effect.
      Specified by:
      codec in interface SpellFieldEffect
      Returns:
      The registered MapCodec instance.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • targetBlocks

      public Optional<net.minecraft.core.HolderSet<net.minecraft.world.level.block.Block>> targetBlocks()
      Returns the value of the targetBlocks record component.
      Returns:
      the value of the targetBlocks record component
    • replacementBlock

      public net.minecraft.world.level.block.Block replacementBlock()
      Returns the value of the replacementBlock record component.
      Returns:
      the value of the replacementBlock record component
    • lifetime

      public net.minecraft.world.item.enchantment.LevelBasedValue lifetime()
      Returns the value of the lifetime record component.
      Returns:
      the value of the lifetime record component
    • decayDuration

      public net.minecraft.world.item.enchantment.LevelBasedValue decayDuration()
      Returns the value of the decayDuration record component.
      Returns:
      the value of the decayDuration record component
    • evaluator

      public TopologyEvaluator evaluator()
      Returns the value of the evaluator record component.
      Returns:
      the value of the evaluator record component