Record Class SilkTouchEffect

java.lang.Object
java.lang.Record
johnsmith.enchantingoverhauled.api.enchantment.effect.SilkTouchEffect
Record Components:
chance - A LevelBasedValue that calculates the probability (0.0 to 1.0) that the Silk Touch effect will activate successfully at a specific enchantment level.

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

This effect introduces a probabilistic chance for the Silk Touch enchantment to succeed based on its enchantment level, overriding the default vanilla 100% success rate. The outcome determines whether a mined block drops itself or drops its normal loot.

See Also:
  • Field Summary

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

    Constructors
    Constructor
    Description
    SilkTouchEffect(net.minecraft.world.item.enchantment.LevelBasedValue chance)
    Creates an instance of a SilkTouchEffect 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<SilkTouchEffect> CODEC
      The codec responsible for serializing and deserializing instances of this record from JSON. Maps the single "chance" field to a LevelBasedValue.
  • Constructor Details

    • SilkTouchEffect

      public SilkTouchEffect(net.minecraft.world.item.enchantment.LevelBasedValue chance)
      Creates an instance of a SilkTouchEffect 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