Record Class PlaceBlockEffect
java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.spellfield.effect.block.PlaceBlockEffect
- Record Components:
block- TheBlockwhose default block state is placed.requireAir- Iftrue, placement only occurs at coordinates whereBlockBehaviour.BlockStateBase.canBeReplaced()istrue.evaluator- TheTopologyEvaluatorgoverning deterministic threshold or probabilistic activation.
- All Implemented Interfaces:
SpellFieldBlockEffect, SpellFieldEffect
public record PlaceBlockEffect(net.minecraft.world.level.block.Block block, boolean requireAir, TopologyEvaluator evaluator)
extends Record
implements SpellFieldBlockEffect
A
SpellFieldBlockEffect that permanently places the default state of a configured Block
at evaluated coordinates within a spell field volume.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringJSON field key for the block to place.static final com.mojang.serialization.MapCodec<PlaceBlockEffect> MapCodec for serializing and deserializingPlaceBlockEffectinstances 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 restricting placement to replaceable blocks. -
Constructor Summary
ConstructorsConstructorDescriptionPlaceBlockEffect(net.minecraft.world.level.block.Block block, boolean requireAir) Constructs aPlaceBlockEffectusing the defaultTopologyEvaluator.PROBABILISTICevaluator.PlaceBlockEffect(net.minecraft.world.level.block.Block block, boolean requireAir, TopologyEvaluator evaluator) Creates an instance of aPlaceBlockEffectrecord class. -
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) Places the configured block's default state atposif the coordinate has not yet been modified during this cycle, passes theevaluator(), and satisfiesrequireAir().net.minecraft.world.level.block.Blockblock()Returns the value of theblockrecord component.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.booleanReturns the value of therequireAirrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
BLOCK
-
REQUIRE_AIR
JSON field key for restricting placement to replaceable blocks.- 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 deserializingPlaceBlockEffectinstances from JSON.
-
-
Constructor Details
-
PlaceBlockEffect
public PlaceBlockEffect(net.minecraft.world.level.block.Block block, boolean requireAir) Constructs aPlaceBlockEffectusing the defaultTopologyEvaluator.PROBABILISTICevaluator.- Parameters:
block- The block to place.requireAir- Whether placement requires a replaceable existing block state.
-
PlaceBlockEffect
public PlaceBlockEffect(net.minecraft.world.level.block.Block block, boolean requireAir, TopologyEvaluator evaluator) Creates an instance of aPlaceBlockEffectrecord class.- Parameters:
block- the value for theblockrecord componentrequireAir- the value for therequireAirrecord 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) Places the configured block's default state atposif the coordinate has not yet been modified during this cycle, passes theevaluator(), and satisfiesrequireAir().- 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
-
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
block
-
requireAir
public boolean requireAir()Returns the value of therequireAirrecord component.- Returns:
- the value of the
requireAirrecord component
-
evaluator
-