java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.spellfield.effect.block.PlaceBlockEffect
Record Components:
block - The Block whose default block state is placed.
requireAir - If true, placement only occurs at coordinates where BlockBehaviour.BlockStateBase.canBeReplaced() is true.
evaluator - The TopologyEvaluator governing 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

    Fields
    Modifier and Type
    Field
    Description
    static final String
    JSON field key for the block to place.
    static final com.mojang.serialization.MapCodec<PlaceBlockEffect>
    MapCodec for serializing and deserializing PlaceBlockEffect instances from JSON.
    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 holding LevelBasedValue definitions for data transformation.
    static final String
    JSON field key for restricting placement to replaceable blocks.
  • Constructor Summary

    Constructors
    Constructor
    Description
    PlaceBlockEffect(net.minecraft.world.level.block.Block block, boolean requireAir)
    Constructs a PlaceBlockEffect using the default TopologyEvaluator.PROBABILISTIC evaluator.
    PlaceBlockEffect(net.minecraft.world.level.block.Block block, boolean requireAir, TopologyEvaluator evaluator)
    Creates an instance of a PlaceBlockEffect record class.
  • 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)
    Places the configured block's default state at pos if the coordinate has not yet been modified during this cycle, passes the evaluator(), and satisfies requireAir().
    net.minecraft.world.level.block.Block
    Returns the value of the block record component.
    com.mojang.serialization.MapCodec<? extends SpellFieldBlockEffect>
    Retrieves the MapCodec responsible for serializing and deserializing this effect.
    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 derived from the evaluator's threshold.
    final int
    Returns a hash code value for this object.
    boolean
    Returns the value of the requireAir 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

    • BLOCK

      public static final String BLOCK
      JSON field key for the block to place.
      See Also:
    • REQUIRE_AIR

      public static final String REQUIRE_AIR
      JSON field key for restricting placement to replaceable blocks.
      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 holding LevelBasedValue definitions for data transformation.
    • CODEC

      public static final com.mojang.serialization.MapCodec<PlaceBlockEffect> CODEC
      MapCodec for serializing and deserializing PlaceBlockEffect instances from JSON.
  • Constructor Details

    • PlaceBlockEffect

      public PlaceBlockEffect(net.minecraft.world.level.block.Block block, boolean requireAir)
      Constructs a PlaceBlockEffect using the default TopologyEvaluator.PROBABILISTIC evaluator.
      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 a PlaceBlockEffect record class.
      Parameters:
      block - the value for the block record component
      requireAir - the value for the requireAir 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 derived from the evaluator's threshold.
      Specified by:
      getPriority in interface SpellFieldBlockEffect
      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 at pos if the coordinate has not yet been modified during this cycle, passes the evaluator(), and satisfies requireAir().
      Specified by:
      apply in interface SpellFieldBlockEffect
      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 at pos.
      modifiedBlocks - A mutable set tracking block coordinates modified during this evaluation 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      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.
    • block

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

      public boolean requireAir()
      Returns the value of the requireAir record component.
      Returns:
      the value of the requireAir record component
    • evaluator

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