Record Class ApplyMobEffect

java.lang.Object
java.lang.Record
net.minecraft.world.item.enchantment.effects.ApplyMobEffect
All Implemented Interfaces:
EnchantmentEntityEffect, EnchantmentLocationBasedEffect

public record ApplyMobEffect(HolderSet<MobEffect> toApply, LevelBasedValue minDuration, LevelBasedValue maxDuration, LevelBasedValue minAmplifier, LevelBasedValue maxAmplifier) extends Record implements EnchantmentEntityEffect
  • Field Details

    • toApply

      private final HolderSet<MobEffect> toApply
      The field for the toApply record component.
    • minDuration

      private final LevelBasedValue minDuration
      The field for the minDuration record component.
    • maxDuration

      private final LevelBasedValue maxDuration
      The field for the maxDuration record component.
    • minAmplifier

      private final LevelBasedValue minAmplifier
      The field for the minAmplifier record component.
    • maxAmplifier

      private final LevelBasedValue maxAmplifier
      The field for the maxAmplifier record component.
    • CODEC

      public static final com.mojang.serialization.MapCodec<ApplyMobEffect> CODEC
  • Constructor Details

    • ApplyMobEffect

      public ApplyMobEffect(HolderSet<MobEffect> toApply, LevelBasedValue minDuration, LevelBasedValue maxDuration, LevelBasedValue minAmplifier, LevelBasedValue maxAmplifier)
      Creates an instance of a ApplyMobEffect record class.
      Parameters:
      toApply - the value for the toApply record component
      minDuration - the value for the minDuration record component
      maxDuration - the value for the maxDuration record component
      minAmplifier - the value for the minAmplifier record component
      maxAmplifier - the value for the maxAmplifier record component
  • Method Details

    • apply

      public void apply(ServerLevel p_345355_, int p_346112_, EnchantedItemInUse p_344766_, Entity p_345996_, Vec3 p_345315_)
      Specified by:
      apply in interface EnchantmentEntityEffect
    • codec

      public com.mojang.serialization.MapCodec<ApplyMobEffect> codec()
      Specified by:
      codec in interface EnchantmentEntityEffect
      Specified by:
      codec in interface 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.
    • toApply

      public HolderSet<MobEffect> toApply()
      Returns the value of the toApply record component.
      Returns:
      the value of the toApply record component
    • minDuration

      public LevelBasedValue minDuration()
      Returns the value of the minDuration record component.
      Returns:
      the value of the minDuration record component
    • maxDuration

      public LevelBasedValue maxDuration()
      Returns the value of the maxDuration record component.
      Returns:
      the value of the maxDuration record component
    • minAmplifier

      public LevelBasedValue minAmplifier()
      Returns the value of the minAmplifier record component.
      Returns:
      the value of the minAmplifier record component
    • maxAmplifier

      public LevelBasedValue maxAmplifier()
      Returns the value of the maxAmplifier record component.
      Returns:
      the value of the maxAmplifier record component