Class EnchantTableConfigurationImpl
- All Implemented Interfaces:
EnchantTableConfiguration
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
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.artificial.enchantments.api.enchanttable.EnchantTableConfiguration
EnchantTableConfiguration.Builder -
Constructor Summary
ConstructorsConstructorDescriptionEnchantTableConfigurationImpl(double weightMultiplier, int minBookshelves, int maxBookshelves, double costMultiplier, boolean allowsMultipleOffers, int tableMinLevel, int tableMaxLevel, boolean treasure) Creates a new immutable configuration. -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks if this enchantment can appear multiple times in the same table.doubleGets the cost multiplier for enchanting with this enchantment.intGets the maximum number of bookshelves for this enchantment.intGets the minimum number of bookshelves required for this enchantment.intGets the maximum enchantment level that can appear in the table.intGets the minimum enchantment level that can appear in the table.doubleGets the weight multiplier for this enchantment in the table.booleanChecks if this enchantment respects vanilla treasure/book restrictions.
-
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
EnchantTableConfigurationBuilderto create instances.- Parameters:
weightMultiplier- the weight multiplier for rarity adjustmentminBookshelves- the minimum required bookshelvesmaxBookshelves- the maximum allowed bookshelvescostMultiplier- the cost scaling multiplierallowsMultipleOffers- whether multiple offers are allowedtableMinLevel- the minimum level that can be offeredtableMaxLevel- the maximum level that can be offeredtreasure- 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:
getWeightMultiplierin interfaceEnchantTableConfiguration- 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:
getMinBookshelvesin interfaceEnchantTableConfiguration- 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:
getMaxBookshelvesin interfaceEnchantTableConfiguration- 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:
getCostMultiplierin interfaceEnchantTableConfiguration- 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:
allowsMultipleOffersin interfaceEnchantTableConfiguration- 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:
getTableMinLevelin interfaceEnchantTableConfiguration- 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:
getTableMaxLevelin interfaceEnchantTableConfiguration- 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:
isTreasurein interfaceEnchantTableConfiguration- Returns:
- true if treasure-like behavior (default: false)
-