Record Class TransmuteBlockEffect
java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.spellfield.effect.block.TransmuteBlockEffect
- Record Components:
targetBlocks- An optionalHolderSetwhitelist restricting which blocks can be transmuted.replacementBlock- TheBlockwhose default state replaces matching target blocks.evaluator- TheTopologyEvaluatorgoverning deterministic threshold or probabilistic activation.
- All Implemented Interfaces:
SpellFieldBlockEffect,SpellFieldEffect
public record TransmuteBlockEffect(Optional<net.minecraft.core.HolderSet<net.minecraft.world.level.block.Block>> targetBlocks, net.minecraft.world.level.block.Block replacementBlock, TopologyEvaluator evaluator)
extends Record
implements SpellFieldBlockEffect
A
SpellFieldBlockEffect that permanently replaces existing breakable non-air blocks with
the default state of a configured replacementBlock().-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec<TransmuteBlockEffect> MapCodec for serializing and deserializingTransmuteBlockEffectinstances from JSON.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 holdingLevelBasedValuedefinitions for data transformation.static final StringJSON field key for the replacement block.static final StringJSON field key for the optional whitelist of eligible target blocks. -
Constructor Summary
ConstructorsConstructorDescriptionTransmuteBlockEffect(Optional<net.minecraft.core.HolderSet<net.minecraft.world.level.block.Block>> targetBlocks, net.minecraft.world.level.block.Block replacementBlock, TopologyEvaluator evaluator) Creates an instance of aTransmuteBlockEffectrecord class.TransmuteBlockEffect(net.minecraft.core.HolderSet<net.minecraft.world.level.block.Block> targetBlocks, net.minecraft.world.level.block.Block replacementBlock) Constructs aTransmuteBlockEffectrestricted to a specific target block set using the defaultTopologyEvaluator.PROBABILISTICevaluator.TransmuteBlockEffect(net.minecraft.world.level.block.Block replacementBlock) Constructs an unrestrictedTransmuteBlockEffectthat transmutes 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) Replaces the block atposwithreplacementBlock()'s default state if the coordinate has not yet been modified during this cycle, passes theevaluator(), is non-air and breakable, and matchestargetBlocks()(if present).com.mojang.serialization.MapCodec<? extends SpellFieldBlockEffect> codec()Retrieves theMapCodecresponsible for serializing and deserializing this effect.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 derived from the evaluator's threshold.final inthashCode()Returns a hash code value for this object.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 replacement block.- 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 holdingLevelBasedValuedefinitions for data transformation. -
CODEC
MapCodec for serializing and deserializingTransmuteBlockEffectinstances from JSON.
-
-
Constructor Details
-
TransmuteBlockEffect
public TransmuteBlockEffect(net.minecraft.core.HolderSet<net.minecraft.world.level.block.Block> targetBlocks, net.minecraft.world.level.block.Block replacementBlock) Constructs aTransmuteBlockEffectrestricted to a specific target block set using the defaultTopologyEvaluator.PROBABILISTICevaluator.- Parameters:
targetBlocks- The whitelist of blocks eligible for transmutation.replacementBlock- The replacement block to place.
-
TransmuteBlockEffect
public TransmuteBlockEffect(net.minecraft.world.level.block.Block replacementBlock) Constructs an unrestrictedTransmuteBlockEffectthat transmutes any breakable non-air block using the defaultTopologyEvaluator.PROBABILISTICevaluator.- Parameters:
replacementBlock- The replacement block to place.
-
TransmuteBlockEffect
public TransmuteBlockEffect(Optional<net.minecraft.core.HolderSet<net.minecraft.world.level.block.Block>> targetBlocks, net.minecraft.world.level.block.Block replacementBlock, TopologyEvaluator evaluator) Creates an instance of aTransmuteBlockEffectrecord class.- Parameters:
targetBlocks- the value for thetargetBlocksrecord componentreplacementBlock- the value for thereplacementBlockrecord componentevaluator- the value for theevaluatorrecord component
-
-
Method Details
-
getPriority
public float getPriority(int enchantmentLevel) Returns the execution priority of this block effect derived from the evaluator's threshold.- Specified by:
getPriorityin interfaceSpellFieldBlockEffect- Parameters:
enchantmentLevel- The active level of the spell field 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) Replaces the block atposwithreplacementBlock()'s default state if the coordinate has not yet been modified during this cycle, passes theevaluator(), is non-air and breakable, and matchestargetBlocks()(if present).- Specified by:
applyin interfaceSpellFieldBlockEffect- Parameters:
level- The executing server level.enchantmentLevel- The active 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 atpos.modifiedBlocks- A mutable set tracking block coordinates modified during this evaluation cycle.
-
codec
Description copied from interface:SpellFieldEffectRetrieves theMapCodecresponsible for serializing and deserializing this effect.- Specified by:
codecin interfaceSpellFieldEffect- Returns:
- The registered
MapCodecinstance.
-
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. -
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. -
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
-
evaluator
Returns the value of theevaluatorrecord component.- Returns:
- the value of the
evaluatorrecord component
-