Skip to content
LlaGuiTo edited this page Nov 25, 2026 · 1 revision

API

Home

Enchanter's Bench exposes three events in the com.skd.enchantersbench.api.event package and a set of public helper classes. Events are posted on the NeoForge event bus (NeoForge.EVENT_BUS), not on the mod event bus.

Events

AvailableEnchantmentsEvent

Fired on the client and the server after the table builds its list of valid enchantments for the current item. Use it to add or remove entries.

Member Description
getStack() The item being enchanted.
getEnchantments() The mutable list of enchantment holders.
setEnchantments(List<Holder<Enchantment>>) Replaces the list.

EnchantmentCostEvent

Fired on the client and the server whenever the cost of one enchantment at a given number of levels is calculated. The modified cost is used by the table.

Member Description
getEnchantment() The enchantment holder.
getLevel() The number of levels the cost is being calculated for.
getCost() The current cost.
setCost(int) Changes the cost.
getOriginalCost() The cost before any listener changed it.

InfoBoxEvent

Client only. Fired when the info panel to the left of the advanced table screen is rendered. The info list can be modified in place to add or remove lines.

Member Description
getGui() The AdvancedTableScreen being rendered.
getInfo() The mutable list of Component lines.

Blacklist

com.skd.enchantersbench.Blacklist provides static helpers:

  • blacklistItem(ResourceLocation)
  • blacklistEnchantment(ResourceLocation)
  • isItemBlacklisted(ItemStack) / isItemBlacklisted(Item)
  • isEnchantmentBlacklisted(ResourceLocation)

The config-based entries are loaded into the same sets.

Enchantment logic

com.skd.enchantersbench.EnchantmentLogic contains the shared rules used by the table, including:

  • calculateNewEnchCost(Holder<Enchantment>, int) — the per-enchantment cost formula.
  • getValidEnchantments(ItemStack, Level, BlockPos) — builds and filters the available enchantment list.
  • isCurse(Level, Holder<Enchantment>), isWikedNight(Level) and isTreasuresAvailable(Level, BlockPos, BlockPos) — the availability rules for curses and treasure enchantments.
  • getExperience(Player), addExperience(Player, int), removeExperience(Player, int), getExperienceForLevels(int) and getLevelForExperience(int) — experience point helpers.
  • getEnchantingPower(Level, BlockPos) — bookshelf power calculation.
  • preventsArmorChange(ItemStack) — checks the prevent-armor-change enchantment effect.
  • TEST_ENCHANTABILITY — the predicate used by the enchanting slot.

Configuration

com.skd.enchantersbench.EnchantersConfig exposes static accessors for the current config values: baseCost(), costFactor(), treasureFactor(), curseFactor(), floatingBookPower(), blacklistedItems() and blacklistedEnchantments().

Network

The mod registers two client-to-server payloads:

  • enchanters_bench:enchant — applies the selected enchantments.
  • enchanters_bench:slider_update — updates the level selected for one enchantment.

These are implementation details; normal integrations should use the events above.

Clone this wiki locally