Class EnchantTableConfigurationImpl

java.lang.Object
io.artificial.enchantments.internal.enchanttable.EnchantTableConfigurationImpl
All Implemented Interfaces:
EnchantTableConfiguration

public final class EnchantTableConfigurationImpl extends Object implements EnchantTableConfiguration
Immutable implementation of EnchantTableConfiguration.

This class stores all configuration values for how an enchantment appears and behaves in the enchantment table. All fields are final and set at construction time via the builder.

Configuration Values:

  • weightMultiplier - adjusts selection probability (default: 1.0)
  • minBookshelves - minimum bookshelf count required (default: 0)
  • maxBookshelves - maximum bookshelf count allowed (default: 15)
  • costMultiplier - scales the lapis/level cost (default: 1.0)
  • allowsMultipleOffers - can appear in multiple slots (default: false)
  • tableMinLevel - minimum level offered (default: 1)
  • tableMaxLevel - maximum level offered (default: Integer.MAX_VALUE)
  • treasure - treasure-only enchantment (default: false)
Since:
0.2.0
  • Constructor Details

    • EnchantTableConfigurationImpl

      public EnchantTableConfigurationImpl(double weightMultiplier, int minBookshelves, int maxBookshelves, double costMultiplier, boolean allowsMultipleOffers, int tableMinLevel, int tableMaxLevel, boolean treasure)
      Creates a new immutable configuration.

      This constructor is package-private. Use EnchantTableConfigurationBuilder to create instances.

      Parameters:
      weightMultiplier - the weight multiplier for rarity adjustment
      minBookshelves - the minimum required bookshelves
      maxBookshelves - the maximum allowed bookshelves
      costMultiplier - the cost scaling multiplier
      allowsMultipleOffers - whether multiple offers are allowed
      tableMinLevel - the minimum level that can be offered
      tableMaxLevel - the maximum level that can be offered
      treasure - whether this is a treasure enchantment
      Since:
      0.2.0
  • Method Details

    • getWeightMultiplier

      public double getWeightMultiplier()
      Gets the weight multiplier for this enchantment in the table.

      Base weights are determined by rarity:

      • COMMON: 10
      • UNCOMMON: 5
      • RARE: 2
      • VERY_RARE: 1

      This multiplier is applied to the base weight. A value of 2.0 makes the enchantment twice as likely to appear.

      Specified by:
      getWeightMultiplier in interface EnchantTableConfiguration
      Returns:
      the weight multiplier (default: 1.0)
    • getMinBookshelves

      public int getMinBookshelves()
      Gets the minimum number of bookshelves required for this enchantment.

      The enchantment will not appear in offers if the table has fewer than this many bookshelves. Vanilla enchantments typically require 0-15 bookshelves depending on the enchantment type.

      Specified by:
      getMinBookshelves in interface EnchantTableConfiguration
      Returns:
      minimum bookshelves required (default: 0)
    • getMaxBookshelves

      public int getMaxBookshelves()
      Gets the maximum number of bookshelves for this enchantment.

      The enchantment will not appear in offers if the table has more than this many bookshelves. Use this to restrict high-tier enchantments to lower-power tables.

      Specified by:
      getMaxBookshelves in interface EnchantTableConfiguration
      Returns:
      maximum bookshelves allowed (default: 15)
    • getCostMultiplier

      public double getCostMultiplier()
      Gets the cost multiplier for enchanting with this enchantment.

      This multiplier is applied to the base cost calculated from the enchantment level and power. A value of 0.8 makes the enchantment 20% cheaper. Values above 1.0 make it more expensive.

      Specified by:
      getCostMultiplier in interface EnchantTableConfiguration
      Returns:
      the cost multiplier (default: 1.0)
    • allowsMultipleOffers

      public boolean allowsMultipleOffers()
      Checks if this enchantment can appear multiple times in the same table.

      If false, only one offer slot can contain this enchantment. If true, multiple slots may offer the same enchantment at different levels.

      Specified by:
      allowsMultipleOffers in interface EnchantTableConfiguration
      Returns:
      true if multiple offers allowed (default: false)
    • getTableMinLevel

      public int getTableMinLevel()
      Gets the minimum enchantment level that can appear in the table.

      This is independent of the definition's minLevel. Use this to restrict table offers to higher levels while allowing lower levels through other means (e.g., anvil combinations).

      Specified by:
      getTableMinLevel in interface EnchantTableConfiguration
      Returns:
      minimum level for table offers (default: definition's minLevel)
    • getTableMaxLevel

      public int getTableMaxLevel()
      Gets the maximum enchantment level that can appear in the table.

      This is independent of the definition's maxLevel. Use this to restrict table offers to lower levels while allowing higher levels through other means.

      Specified by:
      getTableMaxLevel in interface EnchantTableConfiguration
      Returns:
      maximum level for table offers (default: definition's maxLevel)
    • isTreasure

      public boolean isTreasure()
      Checks if this enchantment respects vanilla treasure/book restrictions.

      If true, the enchantment will only appear in the table when the item is placed directly (not via book). Treasure enchantments typically only appear this way.

      Specified by:
      isTreasure in interface EnchantTableConfiguration
      Returns:
      true if treasure-like behavior (default: false)