Immersive Brewing: Java & Modder API
On this page (8)
API version 1 (ImmersiveBrewingAPI.VERSION), package com.otectus.immersivebrewing.api. Only classes in com.otectus.immersivebrewing.api and com.otectus.immersivebrewing.api.event form the public contract; everything else in the mod is internal and subject to change.
Every API query, callback, and event executes on the logical server thread unless explicitly noted.
Registration
Register adapters and effect handlers during FMLCommonSetupEvent, or send Forge IMC messages to "immersive_brewing" before IMC processing finishes. Adapters freeze once InterModProcessEvent runs; subsequent registerAdapter calls return false and log a warning.
// Option 1: During InterModEnqueueEvent
InterModComms.sendTo("immersive_brewing", ImmersiveBrewingAPI.IMC_ADAPTER, () -> new MyBrewingAdapter());
InterModComms.sendTo("immersive_brewing", ImmersiveBrewingAPI.IMC_EFFECT_HANDLER, () -> new MyEffectHandler());
// Option 2: Directly during FMLCommonSetupEvent
ImmersiveBrewingAPI.registerAdapter(new MyBrewingAdapter()); // returns false if id already registered
ImmersiveBrewingAPI.registerEffectHandler(new MyEffectHandler());
| IMC Method | Constant | Payload |
|---|---|---|
"register_adapter" |
ImmersiveBrewingAPI.IMC_ADAPTER |
A BrewingAdapter (or Supplier<BrewingAdapter>) |
"register_effect_handler" |
ImmersiveBrewingAPI.IMC_EFFECT_HANDLER |
An IEffectQualityHandler (or Supplier<IEffectQualityHandler>) |
BrewingAdapter
A BrewingAdapter lets the Brewer’s Kettle delegate a transformation step to an external brewing registry or machine system. Your adapter determines the output; Immersive Brewing handles material reservation, the hands-on workshop process, and quality recording.
| Method | Contract |
|---|---|
ResourceLocation id() |
Unique adapter ID, persisted in job ledgers. |
int version() |
Contract version stored with every job; changing it holds sealed jobs for recovery rather than resuming under mismatched rules. |
int priority() |
Higher priority runs first when multiple adapters match; ties break by ID order. |
boolean applies(ItemStack input, ItemStack ingredient) |
Fast eligibility check with no heavy allocation. |
Preview preview(ItemStack input, ItemStack ingredient) |
Returns Preview.of(output) for 1 serving, or Preview.unsupported(reason). Must operate on copies and never mutate or reroll state. |
BatchPolicy batchPolicy(ItemStack input, ItemStack ingredient) |
BatchPolicy(servingsPerReagent, maxServings, reagentsPerApplication, sharedReaction). Consumes ceil(servings / servingsPerReagent) * reagentsPerApplication reagents and ceil(servings / servingsPerReagent) fuel charges. |
ItemStack commit(ItemStack input, ItemStack ingredient) |
Performs the step once for 1 serving. Must return an output matching preview(...) for identical inputs—otherwise the job is held for recovery with materials intact. |
ContentsPolicy contentsPolicy(ItemStack output) |
EFFECTS (quality scales effect durations via effect policies and drink time; vanilla potion items only) or METADATA_ONLY (quality recorded/displayed; effects left native). |
Inputs passed to adapters are canonical (immersive_brewing NBT compound stripped) count-1 ItemStacks.
The built-in adapter is immersive_brewing:forge_registry (version = 1, priority = 0), delegating to BrewingRecipeRegistry.getOutput (3 servings per reagent, max 6 servings, 1 reagent per application). Adapters can be disabled via datapack exclusions (see Pack Author Guide).
IEffectQualityHandler
Allows third-party mods with custom potion-like item classes (items other than minecraft:potion, splash_potion, lingering_potion, and tipped_arrow) to resolve quality-scaled effects.
| Method | Contract |
|---|---|
boolean handles(ItemStack stack) |
Returns true if this handler resolves stack. |
EnumSet<Path> paths() |
Supported delivery paths: DRINK, SPLASH, LINGERING, ARROW. |
List<MobEffectInstance> resolve(ItemStack stack, int quality) |
Returns fresh, idempotent MobEffectInstance objects for quality (0–100). Must never mutate stack or shared lists. |
[!NOTE] API v1 Path Limitation: Handlers are consulted on
DRINK(finishingPotionItemuse) andSPLASH(impact of non-lingeringThrowablePotionItem) only. Because lingering clouds and arrows store onlyPotionIDs rather than full item stacks,LINGERINGandARROWremain metadata-only for custom item classes in API v1. Untouched stacks (Q = 50) are never passed to handlers; exceptions are logged and fall back to native effects.
Queries & Stack Metadata
All plan and catalog queries run on the logical server thread (ImmersiveBrewingAPI throws IllegalStateException if catalog or resolve is called off-thread).
| Method | Returns / Behavior |
|---|---|
metadata(ItemStack stack) |
Optional<BrewingMetadataView> exposing extraction, control, quality, grade (CRUDE–MASTERWORK), lineage, purifications, brewerId, brewerName, refinerName, label, note. Empty for ordinary ungraded potions. |
quality(ItemStack stack) |
Recorded quality ( 0–100), or 50 if ordinary. |
canonical(ItemStack stack) |
A copy with the immersive_brewing NBT compound removed (used for recipe matching and fingerprinting). |
plans(MinecraftServer server, ItemStack input, int servings) |
Legacy API-v1 bounded list ( <= 512 plans from input), returning List<PlanQuery>. Retained for backwards compatibility; prefer catalog(...) for discovery. |
catalog(MinecraftServer server, ItemStack input, int servings, String search, int page, int workBudget) |
Advances cached incremental graph search ( workBudget clamped to 0..64 operations per call), filters matches (search.length() <= 128), and returns one 24-route CatalogPage (servings 1–6, page 0–4096). Callers should schedule repeated per-tick advances rather than spinning synchronously. |
resolve(MinecraftServer server, String key, ItemStack input, List<ItemStack> tray, int servings) |
Revalidates one stable PlanKey string against active recipes, adapters, and up to 8 explicit tray stacks (independent of catalog pages). |
CatalogPage & PlanQuery
CatalogPagerecord:generation(definition generation),plans(up to24PlanQueryentries),knownMatches,incomplete,budgetLimited,omittedAlternatives. Never claim a search result is complete unless!incomplete && !budgetLimited && omittedAlternatives == 0.PlanQueryrecord:key(stable serializedPlanKey),input,output,reagents,reagentCounts,fuelCharges,remainders,contextual. Passkeytoresolve(...)before executing a saved selection.
NBT Compound Schema Reference
Prefer ImmersiveBrewingAPI.metadata(stack) over raw NBT access. Internally, metadata lives under root tag immersive_brewing (schema: 1):
- Bytes:
E(extraction),C(control),Q(quality), optionalpurified(purification count) - Long: optional
lineage - UUID: optional
brewer - Strings: optional
brewerName,refiner,label(max48),note(max120) - Newer unknown schema compounds are preserved untouched without rewriting.
Forge Events
All events post on MinecraftForge.EVENT_BUS on the server thread:
| Event | Timing | Cancel / Modify Behavior |
|---|---|---|
BrewPlanEvent |
preview() == true: per plan offered at a Kettle.preview() == false: when a player commits a plan before inventory reservation. |
Cancelable. Canceling during preview hides the plan; canceling at commit refuses reservation cleanly. |
BrewResultEvent.Pre |
After Kettle chemistry finishes and every step replays through its adapter, before outputs materialize. |
Cancelable. Canceling holds the batch for recovery ( vetoed) with all materials intact. Call narrowQuality(q) to lower quality (never raises it). |
BrewResultEvent.Post |
Once when outputs finalize (at chemical completion before spout bottling for hands-on batches; after rack placement for 1.1 batches). output() holds final metadata. |
Not cancelable. Ideal for custom progression/rewards. |
ReagentPreparedEvent |
Once when an Apothecary’s Mortar places prepared kits onto its kit shelf. |
Not cancelable. |
BatchRefinedEvent |
Once when an Alembic finishes purification ( purified() == true, with qualityBefore/qualityAfter) or reclamation (purified() == false). |
Not cancelable. |
- Listeners must never mutate station inventories directly.
Postevents fire exactly once per committed batch, regardless of how many assistants helped or how often it sealed. In hands-on batches,player()is the online completer (falling back to the brewer, ornullif offline).
Stable Presentation Identifiers
Within 1.x, the following asset/book IDs remain stable for modpacks and companion integrations (the underlying client.presentation, client.guide, and client.compat.ponder classes remain internal):
- Patchouli Book:
immersive_brewing:brewers_notebook(PatchouliAPI.get().openBookEntry(...)supported for allimmersive_brewing:<category>/<entry>IDs). - Ponder Lessons:
immersive_brewing:<lesson>(with hidden tagsimmersive_brewing:lesson/<lesson>) and 5 topics (brewing,preparation,distillation,storage,workshop). - GeckoLib Rigs:
kettle_apparatus,mortar_tools,mortar_station,alembic_apparatus,apothecary_rack. - playerAnimator Layer:
immersive_brewing:work(priority1100).