Skip to content

Add custom block support via BentoBox hooks (ItemsAdder, CraftEngine, Oraxen, Nexo)#165

Merged
tastybento merged 3 commits into
developfrom
feature/custom-block-support
Jul 11, 2026
Merged

Add custom block support via BentoBox hooks (ItemsAdder, CraftEngine, Oraxen, Nexo)#165
tastybento merged 3 commits into
developfrom
feature/custom-block-support

Conversation

@tastybento

Copy link
Copy Markdown
Member

Summary

Adds plugin-agnostic custom block support to generators, addressing #103. Generator tiers can now produce blocks from ItemsAdder, CraftEngine, Oraxen and Nexo, with all plugin access routed through BentoBox core hooks so the addon never depends on the plugins directly.

How it works

  • Block entries are stored as string block IDs: vanilla material names (COBBLESTONE) or provider-prefixed custom IDs (itemsadder:namespace:id, craftengine:namespace:id, oraxen:id, nexo:id). Existing databases load unchanged — GSON already serialized Material values as their names.
  • The new utils/CustomBlocks helper parses provider prefixes and dispatches place/validate/icon/display-name calls through ItemsAdderHook / CraftEngineHook / OraxenHook.
  • Listeners set vanilla blocks immediately; custom blocks are placed via their hook one tick later, because hook APIs set blocks directly rather than through the event's BlockState.
  • MagicGenerator validates the picked ID at generation time; unavailable custom blocks degrade gracefully to the vanilla block with a /why report.

Provider status

Provider Status
ItemsAdder ✅ works (core hook supports placement)
CraftEngine ✅ works (core hook supports placement)
Oraxen ⏳ accepted, generates once BentoBoxWorld/BentoBox#3020 lands
Nexo ⏳ accepted, generates once BentoBoxWorld/BentoBox#3025 lands

Other changes

  • Panels render custom blocks with the provider item's texture and display name; admin edit panel gains an Add Custom Block button (chat input, validated against the hook registry).
  • generatorTemplate.yml accepts quoted prefixed keys; unregistered custom blocks import with a warning so templates stay portable across servers.
  • BentoBox dependency bumped 3.14.0-SNAPSHOT → 3.18.1 (CraftEngineHook shipped in 3.15.0).
  • Fixes a pre-existing admin panel bug: editing a treasure's chance wrote the block list into the deprecated treasureChanceMap instead of updating treasureItemChanceMap.

Testing

  • All 165 tests pass (mvn test); new coverage for ID parsing, hook-absent rejection, and the Oraxen/Nexo placement gate in CustomBlocksTest and MagicGeneratorTest.
  • Not yet smoke-tested on a live server with ItemsAdder/CraftEngine installed — recommended before release.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Q63R7wAXARZD2Rpg3oun6m

tastybento and others added 3 commits July 11, 2026 11:19
… Oraxen, Nexo)

Generator block entries are now stored as string block IDs instead of
Material: vanilla material names (COBBLESTONE) or provider-prefixed
custom block IDs (itemsadder:namespace:id, craftengine:namespace:id,
oraxen:id, nexo:id). Existing databases load unchanged because GSON
already serialized Material values as their names.

All third-party plugin access is routed through BentoBox core hooks via
the new CustomBlocks utility, so the addon never depends on the plugins
directly. ItemsAdder and CraftEngine blocks generate out of the box;
Oraxen and Nexo IDs are accepted but degrade gracefully to the vanilla
block until core hooks support placing them (BentoBoxWorld/BentoBox#3020,
BentoBoxWorld/BentoBox#3025).

- MagicGenerator validates picked IDs against the hooks and reports
  failures via /why
- Listeners set vanilla blocks immediately; custom blocks are placed via
  their hook one tick later, since hook APIs set blocks directly
- Panels render custom blocks with the provider item's texture and
  display name; the admin edit panel gains an Add Custom Block button
  with chat input validated against the hook registry
- generatorTemplate.yml accepts quoted prefixed keys; unregistered
  custom blocks import with a warning so templates stay portable
- BentoBox dependency bumped to 3.18.1 (CraftEngineHook needs 3.15.0+)

Also fixes a pre-existing admin panel bug where editing a treasure's
chance wrote the block list into the deprecated treasureChanceMap
instead of updating treasureItemChanceMap.

Addresses #103

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Q63R7wAXARZD2Rpg3oun6m
CI failed with "class file has wrong version 69.0, should be 65.0" on
every BentoBox class: the published 3.18.1 jar is compiled for Java 25,
which the Java 21 toolchain used by this project (and its CI) cannot
read. 3.17.0 is the newest Java 21-compatible release and contains all
hook APIs used by the custom block support (CraftEngineHook.getItemStack
landed in 3.16.0).

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Q63R7wAXARZD2Rpg3oun6m
- S1319: expose NavigableMap instead of TreeMap in GeneratorTierObject
  block-chance and material-height getters/setters (defensive copy on set)
- S1192: extract duplicated template-context literal into a constant in
  StoneGeneratorImportManager
- S3776/S6541: split MagicGenerator.processBlockReplacement into
  selectBlockId/isPlaceable/processTreasureDrop to cut cognitive complexity
  and Brain Method metrics
- S3776: extract click-handler and min/max height buttons in
  GeneratorEditPanel to reduce cognitive complexity

Updated call sites (MagicGenerator, CommonPanel) to the interface type.
Full test suite: 165 tests, 0 failures.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Q63R7wAXARZD2Rpg3oun6m
@sonarqubecloud

Copy link
Copy Markdown

@tastybento tastybento merged commit 7c34fdd into develop Jul 11, 2026
4 checks passed
@tastybento tastybento deleted the feature/custom-block-support branch July 11, 2026 18:47
@tastybento tastybento mentioned this pull request Jul 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant