Fix automatic lapis in enchanting tables #1

Merged
NotAlexNoyle merged 1 commits from codex/fix-automatic-lapis-usage-in-enchantments into master 2026-03-23 07:34:55 -04:00
NotAlexNoyle commented 2026-03-23 07:34:09 -04:00 (Migrated from github.com)

Motivation

  • Restore the pre-1.8 behavior where enchanting tables are automatically populated with lapis and players cannot remove it, so enchantments work without consuming lapis and the table never exposes a removable lapis stack.
  • Use the supplied OldCombatMechanics example as the behavioral reference and include the required MPL 2.0 header for the adapted logic.

Description

  • Added an MPL 2.0 license header and new lapis-handling logic in OldEnchantOG.java to synthesize a 64-stack of lapis in the enchanting table secondary slot.
  • Populate the table on InventoryOpenEvent and after an enchant (EnchantItemEvent), and clear it on InventoryCloseEvent using EnchantingInventory.setSecondary(...) so nothing is left behind.
  • Block all common extraction/manipulation paths in the enchanting GUI by cancelling direct clicks on slot 1, double-click collection, MOVE_TO_OTHER_INVENTORY (shift-click), and relevant drag interactions, and schedule a next-tick refill to ensure the lapis stack is restored.
  • Added helper utilities: getLapis(), isLapis(...), fillUpEnchantingTable(...), and refillEnchantingTableNextTick(...), and switched to EnchantingInventory APIs for secondary-slot access.

Testing

  • Attempted ./gradlew spotlessApply compileJava, which failed in this environment because Gradle initially launched on Java 25 and errored with the runtime mismatch; this prevented a full build in the first run. (failed)
  • Retried with JAVA_HOME=/root/.local/share/mise/installs/java/17.0.2 ./gradlew compileJava --stacktrace, which started Gradle on Java 17 but failed dependency resolution because the com.diffplug.spotless plugin could not be resolved from the plugin repository in this environment; compilation could not be completed. (failed)
  • The code changes were validated by static inspection and committed locally; runtime verification on a properly configured development environment or CI (with plugin resolution enabled) is recommended to confirm behavior on a running server.

Codex Task

### Motivation - Restore the pre-1.8 behavior where enchanting tables are automatically populated with lapis and players cannot remove it, so enchantments work without consuming lapis and the table never exposes a removable lapis stack. - Use the supplied OldCombatMechanics example as the behavioral reference and include the required MPL 2.0 header for the adapted logic. ### Description - Added an MPL 2.0 license header and new lapis-handling logic in `OldEnchantOG.java` to synthesize a 64-stack of lapis in the enchanting table secondary slot. - Populate the table on `InventoryOpenEvent` and after an enchant (`EnchantItemEvent`), and clear it on `InventoryCloseEvent` using `EnchantingInventory.setSecondary(...)` so nothing is left behind. - Block all common extraction/manipulation paths in the enchanting GUI by cancelling direct clicks on slot 1, double-click collection, `MOVE_TO_OTHER_INVENTORY` (shift-click), and relevant drag interactions, and schedule a next-tick refill to ensure the lapis stack is restored. - Added helper utilities: `getLapis()`, `isLapis(...)`, `fillUpEnchantingTable(...)`, and `refillEnchantingTableNextTick(...)`, and switched to `EnchantingInventory` APIs for secondary-slot access. ### Testing - Attempted `./gradlew spotlessApply compileJava`, which failed in this environment because Gradle initially launched on Java 25 and errored with the runtime mismatch; this prevented a full build in the first run. (failed) - Retried with `JAVA_HOME=/root/.local/share/mise/installs/java/17.0.2 ./gradlew compileJava --stacktrace`, which started Gradle on Java 17 but failed dependency resolution because the `com.diffplug.spotless` plugin could not be resolved from the plugin repository in this environment; compilation could not be completed. (failed) - The code changes were validated by static inspection and committed locally; runtime verification on a properly configured development environment or CI (with plugin resolution enabled) is recommended to confirm behavior on a running server. ------ [Codex Task](https://chatgpt.com/codex/tasks/task_e_69c1240a2464832f956f4f03133a14c1)
Sign in to join this conversation.