Class AnvilCombinationLogic

java.lang.Object
io.artificial.enchantments.internal.anvil.AnvilCombinationLogic

public final class AnvilCombinationLogic extends Object
Logic for combining enchantments in an anvil.

Handles book+item and book+book combinations with conflict detection, level merging, and cost calculation.

Since:
0.2.0
  • Constructor Details

    • AnvilCombinationLogic

      public AnvilCombinationLogic(@NotNull @NotNull ItemStorage itemStorage)
      Creates a new anvil combination logic instance.
      Parameters:
      itemStorage - the item storage for enchantment operations
  • Method Details

    • combine

      @NotNull public @NotNull AnvilCombinationLogic.CombinationResult combine(@NotNull @NotNull org.bukkit.inventory.ItemStack target, @NotNull @NotNull org.bukkit.inventory.ItemStack sacrifice, int targetPriorWork, int sacrificePriorWork, boolean isTreasureBook)
      Attempts to combine a target item with a sacrifice (book or item).

      This handles all anvil combination logic:

      • Conflict detection between enchantments
      • Level merging (taking max level when both have same enchant)
      • Cost calculation
      • Too expensive detection
      Parameters:
      target - the target item being modified
      sacrifice - the sacrifice item (book or item providing enchantments)
      targetPriorWork - prior work penalty of target item
      sacrificePriorWork - prior work penalty of sacrifice item
      isTreasureBook - whether sacrifice is a treasure book
      Returns:
      the combination result
      Since:
      0.2.0
    • combineBooks

      @NotNull public @NotNull AnvilCombinationLogic.CombinationResult combineBooks(@NotNull @NotNull org.bukkit.inventory.ItemStack bookA, @NotNull @NotNull org.bukkit.inventory.ItemStack bookB, int priorWorkA, int priorWorkB)
      Attempts to combine two enchanted books.

      Book+book combination allows merging enchantments from both books, taking the maximum level for each enchantment. Unlike item+book, books can hold incompatible enchantments.

      Parameters:
      bookA - first enchanted book
      bookB - second enchanted book
      priorWorkA - prior work of first book
      priorWorkB - prior work of second book
      Returns:
      the combination result
      Since:
      0.2.0