Record Class InvulnerabilityFrameModifierEffect

java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.effect.InvulnerabilityFrameModifierEffect
Record Components:
amount - The LevelBasedValue specifying the number of ticks to add to (or subtract from) the target's invulnerableTime.
All Implemented Interfaces:
net.minecraft.world.item.enchantment.effects.EnchantmentEntityEffect, net.minecraft.world.item.enchantment.effects.EnchantmentLocationBasedEffect

public record InvulnerabilityFrameModifierEffect(net.minecraft.world.item.enchantment.LevelBasedValue amount) extends Record implements net.minecraft.world.item.enchantment.effects.EnchantmentEntityEffect
An EnchantmentEntityEffect that modifies a target entity's post-hit invulnerability timer (Entity.invulnerableTime), clamping the resulting value to a minimum of 0 ticks.

Negative values reduce invulnerability frames (allowing rapid consecutive hits), while positive values extend invulnerability duration.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    JSON field key for the invulnerability tick offset.
    static final com.mojang.serialization.MapCodec<InvulnerabilityFrameModifierEffect>
    MapCodec for serializing and deserializing InvulnerabilityFrameModifierEffect instances from JSON.
    static final String
    Registry path identifier for this entity effect.
    Supplies the JSON property keys holding LevelBasedValue definitions for data transformation.
  • Constructor Summary

    Constructors
    Constructor
    Description
    InvulnerabilityFrameModifierEffect(net.minecraft.world.item.enchantment.LevelBasedValue amount)
    Creates an instance of a InvulnerabilityFrameModifierEffect record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    net.minecraft.world.item.enchantment.LevelBasedValue
    Returns the value of the amount record component.
    void
    apply(net.minecraft.server.level.ServerLevel level, int enchantmentLevel, net.minecraft.world.item.enchantment.EnchantedItemInUse itemInUse, net.minecraft.world.entity.Entity target, net.minecraft.world.phys.Vec3 origin)
    Adjusts the target entity's Entity.invulnerableTime by the evaluated tick delta.
    com.mojang.serialization.MapCodec<? extends net.minecraft.world.item.enchantment.effects.EnchantmentEntityEffect>
     
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    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

    • InvulnerabilityFrameModifierEffect

      public InvulnerabilityFrameModifierEffect(net.minecraft.world.item.enchantment.LevelBasedValue amount)
      Creates an instance of a InvulnerabilityFrameModifierEffect record class.
      Parameters:
      amount - the value for the amount record component
  • Method Details

    • apply

      public void apply(net.minecraft.server.level.ServerLevel level, int enchantmentLevel, net.minecraft.world.item.enchantment.EnchantedItemInUse itemInUse, net.minecraft.world.entity.Entity target, net.minecraft.world.phys.Vec3 origin)
      Adjusts the target entity's Entity.invulnerableTime by the evaluated tick delta.
      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.
      itemInUse - The context of the enchanted item in use.
      target - The entity whose invulnerability timer is modified.
      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.
    • amount

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