java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.spellfield.effect.entity.DisarmEffect
Record Components:
dropChance - The LevelBasedValue base probability (0.0 to 1.0) of disarming each slot before topological scaling.
slots - The list of EquipmentSlots evaluated for disarming.
entityFilter - Optional ContextAwarePredicate restricting which entities can be disarmed.
All Implemented Interfaces:
SpellFieldEffect, SpellFieldEntityEffect

public record DisarmEffect(net.minecraft.world.item.enchantment.LevelBasedValue dropChance, List<net.minecraft.world.entity.EquipmentSlot> slots, Optional<net.minecraft.advancements.criterion.ContextAwarePredicate> entityFilter) extends Record implements SpellFieldEntityEffect
A SpellFieldEntityEffect that probabilistically forces targeted LivingEntity instances to drop items equipped in specified EquipmentSlots into the world with a 40-tick pickup delay and a randomized outward scatter impulse.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final com.mojang.serialization.MapCodec<DisarmEffect>
    MapCodec for serializing and deserializing DisarmEffect instances from JSON.
    static final String
    JSON field key for the base disarm probability.
    static final String
    JSON field key for the optional entity filter predicate.
    static final String
    Registry path identifier for this spell field entity effect.
    Supplies the JSON property keys holding LevelBasedValue definitions for data transformation.
    static final String
    JSON field key for the list of targeted equipment slots.
  • Constructor Summary

    Constructors
    Constructor
    Description
    DisarmEffect(net.minecraft.world.item.enchantment.LevelBasedValue dropChance)
    Constructs a DisarmEffect with an initially empty slot list for fluent builder-style configuration.
    DisarmEffect(net.minecraft.world.item.enchantment.LevelBasedValue dropChance, List<net.minecraft.world.entity.EquipmentSlot> slots, Optional<net.minecraft.advancements.criterion.ContextAwarePredicate> entityFilter)
    Creates an instance of a DisarmEffect record class.
    DisarmEffect(net.minecraft.world.item.enchantment.LevelBasedValue dropChance, net.minecraft.world.entity.EquipmentSlot slots)
    Constructs an unfiltered DisarmEffect targeting a single equipment slot.
    DisarmEffect(net.minecraft.world.item.enchantment.LevelBasedValue dropChance, net.minecraft.world.entity.EquipmentSlot slots, net.minecraft.advancements.criterion.ContextAwarePredicate entityFilter)
    Constructs a DisarmEffect targeting a single equipment slot and restricted by an entity filter.
  • Method Summary

    Modifier and Type
    Method
    Description
    addSlot(net.minecraft.world.entity.EquipmentSlot... slot)
    Returns a copy of this effect with the specified EquipmentSlots appended to the target list.
    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.world.entity.Entity victim, float volumeScalar)
    Evaluates the scaled disarm probability ($\text{dropChance} \cdot \text{volumeScalar}$) for each populated slot in slots() on victim, spawning an ItemEntity and clearing the slot whenever the roll succeeds.
    com.mojang.serialization.MapCodec<? extends SpellFieldEntityEffect>
    Retrieves the MapCodec responsible for serializing and deserializing this effect.
    net.minecraft.world.item.enchantment.LevelBasedValue
    Returns the value of the dropChance record component.
    Optional<net.minecraft.advancements.criterion.ContextAwarePredicate>
    Returns the value of the entityFilter record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    List<net.minecraft.world.entity.EquipmentSlot>
    Returns the value of the slots 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

    • DROP_CHANCE

      public static final String DROP_CHANCE
      JSON field key for the base disarm probability.
      See Also:
    • SLOTS

      public static final String SLOTS
      JSON field key for the list of targeted equipment slots.
      See Also:
    • ENTITY_FILTER

      public static final String ENTITY_FILTER
      JSON field key for the optional entity filter predicate.
      See Also:
    • KEY

      public static final String KEY
      Registry path identifier for this spell field entity 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<DisarmEffect> CODEC
      MapCodec for serializing and deserializing DisarmEffect instances from JSON.
  • Constructor Details

    • DisarmEffect

      public DisarmEffect(net.minecraft.world.item.enchantment.LevelBasedValue dropChance, net.minecraft.world.entity.EquipmentSlot slots)
      Constructs an unfiltered DisarmEffect targeting a single equipment slot.
      Parameters:
      dropChance - The LevelBasedValue disarm probability.
      slots - The single EquipmentSlot to target.
    • DisarmEffect

      public DisarmEffect(net.minecraft.world.item.enchantment.LevelBasedValue dropChance, net.minecraft.world.entity.EquipmentSlot slots, net.minecraft.advancements.criterion.ContextAwarePredicate entityFilter)
      Constructs a DisarmEffect targeting a single equipment slot and restricted by an entity filter.
      Parameters:
      dropChance - The LevelBasedValue disarm probability.
      slots - The single EquipmentSlot to target.
      entityFilter - The predicate filter to match against candidate entities.
    • DisarmEffect

      public DisarmEffect(net.minecraft.world.item.enchantment.LevelBasedValue dropChance)
      Constructs a DisarmEffect with an initially empty slot list for fluent builder-style configuration.
      Parameters:
      dropChance - The LevelBasedValue disarm probability.
    • DisarmEffect

      public DisarmEffect(net.minecraft.world.item.enchantment.LevelBasedValue dropChance, List<net.minecraft.world.entity.EquipmentSlot> slots, Optional<net.minecraft.advancements.criterion.ContextAwarePredicate> entityFilter)
      Creates an instance of a DisarmEffect record class.
      Parameters:
      dropChance - the value for the dropChance record component
      slots - the value for the slots record component
      entityFilter - the value for the entityFilter record component
  • Method Details

    • 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.world.entity.Entity victim, float volumeScalar)
      Evaluates the scaled disarm probability ($\text{dropChance} \cdot \text{volumeScalar}$) for each populated slot in slots() on victim, spawning an ItemEntity and clearing the slot whenever the roll succeeds.
      Specified by:
      apply in interface SpellFieldEntityEffect
      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.
      victim - The target entity intersecting the spell field.
      volumeScalar - The active topological multiplier for victim.
    • codec

      public com.mojang.serialization.MapCodec<? extends SpellFieldEntityEffect> 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.
    • addSlot

      public DisarmEffect addSlot(net.minecraft.world.entity.EquipmentSlot... slot)
      Returns a copy of this effect with the specified EquipmentSlots appended to the target list.
      Parameters:
      slot - One or more EquipmentSlots to append.
      Returns:
      A new DisarmEffect instance containing the combined slot list.
    • 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.
    • dropChance

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

      public List<net.minecraft.world.entity.EquipmentSlot> slots()
      Returns the value of the slots record component.
      Returns:
      the value of the slots record component
    • entityFilter

      public Optional<net.minecraft.advancements.criterion.ContextAwarePredicate> entityFilter()
      Returns the value of the entityFilter record component.
      Returns:
      the value of the entityFilter record component