Record Class AreaGravityDamageEffect

java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.effect.AreaGravityDamageEffect
Record Components:
strength - The LevelBasedValue governing the peak gravitational pull (positive) or push (negative) force.
radius - The LevelBasedValue governing the cubic half-extent of the area of effect in blocks.
damage - The LevelBasedValue governing the flat damage dealt to affected entities.
All Implemented Interfaces:
net.minecraft.world.item.enchantment.effects.EnchantmentEntityEffect, net.minecraft.world.item.enchantment.effects.EnchantmentLocationBasedEffect

public record AreaGravityDamageEffect(net.minecraft.world.item.enchantment.LevelBasedValue strength, net.minecraft.world.item.enchantment.LevelBasedValue radius, net.minecraft.world.item.enchantment.LevelBasedValue damage) extends Record implements net.minecraft.world.item.enchantment.effects.EnchantmentEntityEffect
An EnchantmentEntityEffect that generates a localized gravitational impulse field and inflicts area-of-effect damage around the target entity.

Living entities (excluding the enchantment owner) within radius() are pulled inward (when strength() is positive) or pushed outward (when negative) using a sigmoid distance falloff curve, accompanied by directional particle bursts and sound effects.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final com.mojang.serialization.MapCodec<AreaGravityDamageEffect>
    MapCodec for serializing and deserializing AreaGravityDamageEffect instances from JSON.
    static final String
    JSON field key for the inflicted damage amount.
    static final String
    Registry path identifier for this entity effect.
    Supplies the JSON property keys holding LevelBasedValue definitions for data transformation.
    static final String
    JSON field key for the area-of-effect radius.
    static final String
    JSON field key for the gravitational impulse strength.
  • Constructor Summary

    Constructors
    Constructor
    Description
    AreaGravityDamageEffect(net.minecraft.world.item.enchantment.LevelBasedValue strength, net.minecraft.world.item.enchantment.LevelBasedValue radius, net.minecraft.world.item.enchantment.LevelBasedValue damage)
    Creates an instance of a AreaGravityDamageEffect 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 target, net.minecraft.world.phys.Vec3 origin)
    Applies the gravitational impulse, particle effects, and damage to all valid living entities within the calculated bounding volume around target.
    com.mojang.serialization.MapCodec<? extends net.minecraft.world.item.enchantment.effects.EnchantmentEntityEffect>
     
    net.minecraft.world.item.enchantment.LevelBasedValue
    Returns the value of the damage record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    net.minecraft.world.item.enchantment.LevelBasedValue
    Returns the value of the radius record component.
    net.minecraft.world.item.enchantment.LevelBasedValue
    Returns the value of the strength 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

    Methods inherited from interface net.minecraft.world.item.enchantment.effects.EnchantmentEntityEffect

    onChangedBlock

    Methods inherited from interface net.minecraft.world.item.enchantment.effects.EnchantmentLocationBasedEffect

    onDeactivated
  • Field Details

  • Constructor Details

    • AreaGravityDamageEffect

      public AreaGravityDamageEffect(net.minecraft.world.item.enchantment.LevelBasedValue strength, net.minecraft.world.item.enchantment.LevelBasedValue radius, net.minecraft.world.item.enchantment.LevelBasedValue damage)
      Creates an instance of a AreaGravityDamageEffect record class.
      Parameters:
      strength - the value for the strength record component
      radius - the value for the radius record component
      damage - the value for the damage 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 target, net.minecraft.world.phys.Vec3 origin)
      Applies the gravitational impulse, particle effects, and damage to all valid living entities within the calculated bounding volume around target.
      Specified by:
      apply in interface net.minecraft.world.item.enchantment.effects.EnchantmentEntityEffect
      Parameters:
      level - The server level in which the effect is triggered.
      enchantmentLevel - The level of the source enchantment.
      context - The context of the enchanted item in use, providing the owner entity.
      target - The focal entity at the center of the gravity field.
      origin - The origin position vector of the trigger.
    • codec

      public com.mojang.serialization.MapCodec<? extends net.minecraft.world.item.enchantment.effects.EnchantmentEntityEffect> codec()
      Specified by:
      codec in interface net.minecraft.world.item.enchantment.effects.EnchantmentEntityEffect
      Specified by:
      codec in interface net.minecraft.world.item.enchantment.effects.EnchantmentLocationBasedEffect
    • 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.
    • strength

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

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

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