java.lang.Object
java.lang.Record
johnsmith.enchantingoverhauled.api.enchantment.theme.power.PowerProvider
Record Components:
blocks - A HolderSet representing the block(s) or block tag that provide power for the theme.
power - The base integer amount of enchanting power this provider grants.
bonuses - A list of optional PowerBonus rules that apply conditional or dynamic modifications to the base power value.

public record PowerProvider(net.minecraft.core.HolderSet<net.minecraft.world.level.block.Block> blocks, int power, List<PowerBonus> bonuses) extends Record
A data-driven record that defines a rule for how a specific block or group of blocks contributes enchanting power toward an EnchantmentTheme (e.g., a Bookshelf contributing 1 power to the Common theme).

This is the core data unit used by the Enchanting Altar logic to determine available thematic and agnostic power.

  • Field Summary

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

    Constructors
    Constructor
    Description
    PowerProvider(net.minecraft.core.HolderSet<net.minecraft.world.level.block.Block> blocks, int power, List<PowerBonus> bonuses)
    Creates an instance of a PowerProvider record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    net.minecraft.core.HolderSet<net.minecraft.world.level.block.Block>
    Returns the value of the blocks record component.
    Returns the value of the bonuses record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    int
    Returns the value of the power record component.
    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<PowerProvider> CODEC
      The codec responsible for serializing and deserializing instances of this record from JSON.

      Uses RegistryCodecs.homogeneousList(net.minecraft.resources.ResourceKey<? extends net.minecraft.core.Registry<E>>, com.mojang.serialization.Codec<E>) to handle the HolderSet of blocks. The bonuses field defaults to an empty list if omitted.

  • Constructor Details

    • PowerProvider

      public PowerProvider(net.minecraft.core.HolderSet<net.minecraft.world.level.block.Block> blocks, int power, List<PowerBonus> bonuses)
      Creates an instance of a PowerProvider record class.
      Parameters:
      blocks - the value for the blocks record component
      power - the value for the power record component
      bonuses - the value for the bonuses 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. 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.
    • blocks

      public net.minecraft.core.HolderSet<net.minecraft.world.level.block.Block> blocks()
      Returns the value of the blocks record component.
      Returns:
      the value of the blocks record component
    • power

      public int power()
      Returns the value of the power record component.
      Returns:
      the value of the power record component
    • bonuses

      public List<PowerBonus> bonuses()
      Returns the value of the bonuses record component.
      Returns:
      the value of the bonuses record component