Class AnvilCombinationLogic
java.lang.Object
io.artificial.enchantments.internal.anvil.AnvilCombinationLogic
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordResult of an anvil combination operation. -
Constructor Summary
ConstructorsConstructorDescriptionAnvilCombinationLogic(@NotNull ItemStorage itemStorage) Creates a new anvil combination logic instance. -
Method Summary
Modifier and TypeMethodDescriptioncombine(@NotNull org.bukkit.inventory.ItemStack target, @NotNull org.bukkit.inventory.ItemStack sacrifice, int targetPriorWork, int sacrificePriorWork, boolean isTreasureBook) Attempts to combine a target item with a sacrifice (book or item).combineBooks(@NotNull org.bukkit.inventory.ItemStack bookA, @NotNull org.bukkit.inventory.ItemStack bookB, int priorWorkA, int priorWorkB) Attempts to combine two enchanted books.
-
Constructor Details
-
AnvilCombinationLogic
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 modifiedsacrifice- the sacrifice item (book or item providing enchantments)targetPriorWork- prior work penalty of target itemsacrificePriorWork- prior work penalty of sacrifice itemisTreasureBook- 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 bookbookB- second enchanted bookpriorWorkA- prior work of first bookpriorWorkB- prior work of second book- Returns:
- the combination result
- Since:
- 0.2.0
-