Record Class AddIfBlockStateBonus

java.lang.Object
java.lang.Record
johnsmith.enchantingoverhauled.api.enchantment.theme.power.bonus.AddIfBlockStateBonus
Record Components:
property - The name of the Property to check on the block state (e.g., "lit" or "has_book").
value - The expected string representation of the property's value for the bonus to apply (e.g., "true").
bonus - The flat integer amount of enchanting power to add if the condition is met.
All Implemented Interfaces:
PowerBonus

public record AddIfBlockStateBonus(String property, String value, int bonus) extends Record implements PowerBonus
A data-driven PowerBonus implementation that adds a fixed bonus amount to the enchanting power if a specific block state property on the power-providing block matches a designated string value.

Useful for conditional power, such as granting a bonus only if a candle is lit (lit = "true").

  • Field Summary

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

    Constructors
    Constructor
    Description
    AddIfBlockStateBonus(String property, String value, int bonus)
    Creates an instance of a AddIfBlockStateBonus record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the value of the bonus record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    com.mojang.serialization.MapCodec<? extends PowerBonus>
    Retrieves the MapCodec responsible for encoding and decoding this specific bonus implementation.
    Retrieves the unique identifier string associated with this specific bonus implementation.
    final int
    Returns a hash code value for this object.
    Returns the value of the property record component.
    final String
    Returns a string representation of this record class.
    Returns the value of the value record component.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • CODEC

      public static final com.mojang.serialization.MapCodec<AddIfBlockStateBonus> CODEC
      The codec responsible for serializing and deserializing instances of this record from JSON.
  • Constructor Details

    • AddIfBlockStateBonus

      public AddIfBlockStateBonus(String property, String value, int bonus)
      Creates an instance of a AddIfBlockStateBonus record class.
      Parameters:
      property - the value for the property record component
      value - the value for the value record component
      bonus - the value for the bonus record component
  • Method Details

    • getTypeId

      public String getTypeId()
      Retrieves the unique identifier string associated with this specific bonus implementation.
      Specified by:
      getTypeId in interface PowerBonus
      Returns:
      The constant ID string for this bonus type: "add_if_block_state".
    • getCodec

      public com.mojang.serialization.MapCodec<? extends PowerBonus> getCodec()
      Retrieves the MapCodec responsible for encoding and decoding this specific bonus implementation.
      Specified by:
      getCodec in interface PowerBonus
      Returns:
      The MapCodec for this bonus type.
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      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.
    • property

      public String property()
      Returns the value of the property record component.
      Returns:
      the value of the property record component
    • value

      public String value()
      Returns the value of the value record component.
      Returns:
      the value of the value record component
    • bonus

      public int bonus()
      Returns the value of the bonus record component.
      Returns:
      the value of the bonus record component