Package forgottentowns.mod.api
Interface ModContext
public interface ModContext
Startup registration surface scoped to one manifest and the startup thread.
Registrations close when
GameMod.register(forgottentowns.mod.api.ModContext) returns. Captured settings/tables and published
rule values may be retained; the registration context must not be retained or used asynchronously.-
Method Summary
Modifier and TypeMethodDescriptionReads a manifest-listed, deeply immutable JSON table.voidonRegistriesReady(Consumer<RegistryAccess> callback) Registers this mod's one startup callback for the final validated definition catalog.voidregisterColonyExtension(Supplier<ColonyExtension> factory) Registers one factory for independent, persistent per-world simulation instances.voidregisterEquipmentTransform(String id, EquipmentTransform transform) Registers a pure equipment conversion invoked after reserved inputs are consumed.voidregisterHousingPolicy(HousingPolicy policy) Adds a startup-only housing expansion policy, shared by manual and automatic assignment.default voidregisterKeyboardShortcut(KeyboardShortcut shortcut) Registers a mod-owned, remappable keyboard command.default voidregisterManualTradeReservations(boolean enabled) Selects whether the shared Stock panel offers manual trade reservations.voidregisterParticleShape(String id, ParticleShape shape) Registers a convex particle polygon without exposing graphics state to the mod.voidRegisters one location-map policy and its paid arrival offers.default voidPublishes this mod's shared trading configuration for declared dependents.voidRegisters one settlement trading policy for this mod, including shared UI panels.default voidregisterTradeFilter(Predicate<String> filter) Registers a resource filter applied to merchant and settlement commerce in both directions.default voidregisterWorldInspection(WorldInspection inspection) Enables dedicated viewport inspectors for this mod.default SettlementTradeCorerequireSettlementTradeCore(String modId) Resolves a core already published by a directly declared dependency.settings()Reads this pack's immutable manifest-listed configuration.
-
Method Details
-
registerManualTradeReservations
default void registerManualTradeReservations(boolean enabled) Selects whether the shared Stock panel offers manual trade reservations. Any provider can opt out; native Settlement Trading opts out by default, and a mod cannot override that decision by registering true. When disabled, existing reserved cargo returns to its owning settlement through durable delivery receipts; ordinary stock remains available for direct selling and crafting.- Parameters:
enabled- whether this mod permits manual reservations- Throws:
IllegalArgumentException- if duplicated or the manifest predates API 15IllegalStateException- after startup registration closesUnsupportedOperationException- if the host predates reservation policies
-
registerTradeFilter
Registers a resource filter applied to merchant and settlement commerce in both directions. All registered filters must accept a resource, including the native packed-goods policy. Adding a trade-goods definition participates in that native policy automatically. Capture final registry identities throughonRegistriesReady(java.util.function.Consumer<forgottentowns.mod.api.RegistryAccess>).- Parameters:
filter- predicate receiving a stable resource ID- Throws:
IllegalArgumentException- if null, duplicated, or the manifest predates API 15IllegalStateException- after startup registration closesUnsupportedOperationException- if the host predates resource trade filters
-
registerKeyboardShortcut
Registers a mod-owned, remappable keyboard command. Defaults and legacy preference aliases belong to the pack; the host supplies the editor and dispatch.- Parameters:
shortcut- owned command definition with a localized label- Throws:
IllegalArgumentException- if null, duplicated, not owned, or unsupported by the manifestIllegalStateException- after startup registration closesUnsupportedOperationException- if the host predates shortcut registration
-
registerWorldInspection
Enables dedicated viewport inspectors for this mod.- Parameters:
inspection- supported inspection targets- Throws:
IllegalArgumentException- if null, duplicated, or unsupported by the manifestIllegalStateException- after startup registration closesUnsupportedOperationException- if the host predates inspection support
-
registerSettlementTradeCore
Publishes this mod's shared trading configuration for declared dependents. The provider must validate its production rules throughonRegistriesReady(java.util.function.Consumer<forgottentowns.mod.api.RegistryAccess>).- Parameters:
core- immutable rule sets, also usable by the provider's own policy- Throws:
IllegalArgumentException- if null, duplicated or unsupported by the manifestIllegalStateException- after startup registration closesUnsupportedOperationException- if this host does not support trading cores
-
requireSettlementTradeCore
Resolves a core already published by a directly declared dependency. Dependency order guarantees the provider registers first. No fallback rules are substituted when an older installed dependency lacks the required core. The native game suppliessettlement_tradingbefore optional mods register; a direct dependency on that ID requires no installed copy of the historical pack.- Parameters:
modId- provider ID declared in this mod's manifest dependencies- Returns:
- the exact immutable core published by the provider
- Throws:
IllegalArgumentException- if the provider ID is null, the dependency is undeclared, absent or provides no core, or the manifest does not support this registrationIllegalStateException- after startup registration closesUnsupportedOperationException- if this host does not support trading cores
-
registerSettlementMap
Registers one location-map policy and its paid arrival offers.- Parameters:
rules- pure location and recruitment policy- Throws:
IllegalArgumentException- for a null or duplicate policy or an unsupported manifest declarationIllegalStateException- after startup registration closes
-
dataTable
Reads a manifest-listed, deeply immutable JSON table.- Parameters:
id- nonnull table identifier declared in the manifest's tables object- Returns:
- JSON object, list, scalar or null captured with this mod's gameplay hash
- Throws:
IllegalArgumentException- if the table is absent or the manifest does not support this operationIllegalStateException- if startup registration has closed
-
registerSettlementTrading
Registers one settlement trading policy for this mod, including shared UI panels.- Parameters:
rules- pure policy controlling availability and economic rules- Throws:
IllegalArgumentException- if null, duplicated, or unsupported by the manifestIllegalStateException- if startup registration has closed
-
settings
Reads this pack's immutable manifest-listed configuration.- Returns:
- JSON settings copied from the captured pack, or an empty map
- Throws:
IllegalArgumentException- if the manifest does not support this operationIllegalStateException- if registration has closed
-
registerColonyExtension
Registers one factory for independent, persistent per-world simulation instances. Startup validation also creates disposable instances and exercises empty restore, save, and saved-state restore. Those callbacks must not depend on an active world or external side effects.- Parameters:
factory- factory returning a fresh nonnull extension for each request- Throws:
IllegalArgumentException- if duplicated, null, or unsupported by the manifestIllegalStateException- if registration has closed
-
registerHousingPolicy
Adds a startup-only housing expansion policy, shared by manual and automatic assignment.- Parameters:
policy- bed-limited expansion policy for residential, barracks, guard_post, or tavern zones- Throws:
IllegalArgumentException- if policy is null, contains unsupported home zones, or the manifest does not support this operationIllegalStateException- if registration has closed
-
onRegistriesReady
Registers this mod's one startup callback for the final validated definition catalog. It runs once on the startup thread after all registrations and runtime content validation, before a world/window is created, including during headless validation. The immutable snapshot may be retained. Exceptions fail startup and identify the responsible mod. This callback cannot register further hooks or mutate the catalog.- Parameters:
callback- consumer of frozen definitions, including host-generated trade goods and packing recipes- Throws:
IllegalArgumentException- if callback is null, already registered, or the manifest does not support this callbackIllegalStateException- if registration has closed
-
registerEquipmentTransform
Registers a pure equipment conversion invoked after reserved inputs are consumed.- Parameters:
id- namespaced handler identifier belonging to this modtransform- deterministic conversion, using only the supplied random source- Throws:
IllegalArgumentException- if the identifier or implementation is invalid or duplicatedIllegalStateException- if registration has closed
-
registerParticleShape
Registers a convex particle polygon without exposing graphics state to the mod.- Parameters:
id- namespaced shape identifier belonging to this modshape- normalized, immutable polygon- Throws:
IllegalArgumentException- if the identifier or shape is invalid or duplicatedIllegalStateException- if registration has closed
-