Record Class VanishingCurseEffect

java.lang.Object
java.lang.Record
johnsmith.enchantingoverhauled.api.enchantment.effect.VanishingCurseEffect
Record Components:
chance - A LevelBasedValue that calculates the probability (0.0 to 1.0) that the cursed item will vanish when the player dies.

public record VanishingCurseEffect(net.minecraft.world.item.enchantment.LevelBasedValue chance) extends Record
A data-driven record defining the parameters for the Vanishing Curse enchantment effect component.

This effect introduces a probabilistic chance that an item cursed with Vanishing will vanish and be destroyed upon the player's death, overriding the vanilla behavior where the item is guaranteed to be destroyed 100% of the time.

See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final com.mojang.serialization.Codec<VanishingCurseEffect>
    The codec responsible for serializing and deserializing instances of this record from JSON.
  • Constructor Summary

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

    Modifier and Type
    Method
    Description
    net.minecraft.world.item.enchantment.LevelBasedValue
    Returns the value of the chance record component.
    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
  • Field Details

    • CODEC

      public static final com.mojang.serialization.Codec<VanishingCurseEffect> CODEC
      The codec responsible for serializing and deserializing instances of this record from JSON. Maps the single "chance" field to a LevelBasedValue.
  • Constructor Details

    • VanishingCurseEffect

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

    • 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.
    • chance

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