Техническая документация доступна на английском языке. Имена кода и полей соответствуют текущему Mod API.
МОДИНГОВАЯ ДОКУМЕНТАЦИЯ
Java reference
Search the types, functions and callbacks available to a Java mod. This reference is generated from the SDK Javadocs; each entry links to its full Java documentation.
Find a type or member
60 общедоступные типы · 468 члены · Content API 15
42 соответствующие записи
GameMod.register(ModContext)КрюкRegisters immutable extensions before gameplay registries initialize.
GameMod · Хуки и жизненный цикл
Подпись
void register(ModContext context)Registers immutable extensions before gameplay registries initialize. Implementations must not initialize game registries or retain the context. The host constructs the entry point through a public no-argument constructor and invokes this method on the startup thread. Use the final-registry callback for content-dependent checks.
Реализуйте этот крючок
public void register(ModContext context);The engine calls your implementation; implement this signature in the registered hook.
- Parameters
- context - registrations scoped to this manifest's namespace
mod.registerColonyExtension(factory)МетодRegisters one factory for independent, persistent per-world simulation instances.
ModContext · Хуки и жизненный цикл
Подпись
void registerColonyExtension(Supplier<ColonyExtension> factory)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.
Пример звонка
mod.registerColonyExtension(factory);ModContext mod is supplied to GameMod.register. Registration closes when that callback returns.
- Parameters
- factory - factory returning a fresh nonnull extension for each request
- Throws
- IllegalArgumentException - if duplicated, null, or unsupported by the manifest
- Throws
- IllegalStateException - if registration has closed
mod.registerEquipmentTransform(id, transform)МетодRegisters a pure equipment conversion invoked after reserved inputs are consumed.
ModContext · Хуки и жизненный цикл
Подпись
void registerEquipmentTransform(String id, EquipmentTransform transform)Registers a pure equipment conversion invoked after reserved inputs are consumed.
Пример звонка
mod.registerEquipmentTransform(id, transform);ModContext mod is supplied to GameMod.register. Registration closes when that callback returns.
- Parameters
- id - namespaced handler identifier belonging to this mod
- Parameters
- transform - deterministic conversion, using only the supplied random source
- Throws
- IllegalArgumentException - if the identifier or implementation is invalid or duplicated
- Throws
- IllegalStateException - if registration has closed
mod.registerHousingPolicy(policy)МетодAdds a startup-only housing expansion policy, shared by manual and automatic assignment.
ModContext · Хуки и жизненный цикл
Подпись
void registerHousingPolicy(HousingPolicy policy)Adds a startup-only housing expansion policy, shared by manual and automatic assignment.
Пример звонка
mod.registerHousingPolicy(policy);ModContext mod is supplied to GameMod.register. Registration closes when that callback returns.
- 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 operation
- Throws
- IllegalStateException - if registration has closed
mod.registerKeyboardShortcut(shortcut)МетодRegisters a mod-owned, remappable keyboard command.
ModContext · Хуки и жизненный цикл
Подпись
default void registerKeyboardShortcut(KeyboardShortcut shortcut)Registers a mod-owned, remappable keyboard command. Defaults and legacy preference aliases belong to the pack; the host supplies the editor and dispatch.
Пример звонка
mod.registerKeyboardShortcut(shortcut);ModContext mod is supplied to GameMod.register. Registration closes when that callback returns.
- Parameters
- shortcut - owned command definition with a localized label
- Throws
- IllegalArgumentException - if null, duplicated, not owned, or unsupported by the manifest
- Throws
- IllegalStateException - after startup registration closes
- Throws
- UnsupportedOperationException - if the host predates shortcut registration
mod.registerManualTradeReservations(enabled)МетодSelects whether the shared Stock panel offers manual trade reservations.
ModContext · Хуки и жизненный цикл
Подпись
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.
Пример звонка
mod.registerManualTradeReservations(enabled);ModContext mod is supplied to GameMod.register. Registration closes when that callback returns.
- Parameters
- enabled - whether this mod permits manual reservations
- Throws
- IllegalArgumentException - if duplicated or the manifest predates API 15
- Throws
- IllegalStateException - after startup registration closes
- Throws
- UnsupportedOperationException - if the host predates reservation policies
mod.registerParticleShape(id, shape)МетодRegisters a convex particle polygon without exposing graphics state to the mod.
ModContext · Хуки и жизненный цикл
Подпись
void registerParticleShape(String id, ParticleShape shape)Registers a convex particle polygon without exposing graphics state to the mod.
Пример звонка
mod.registerParticleShape(id, shape);ModContext mod is supplied to GameMod.register. Registration closes when that callback returns.
- Parameters
- id - namespaced shape identifier belonging to this mod
- Parameters
- shape - normalized, immutable polygon
- Throws
- IllegalArgumentException - if the identifier or shape is invalid or duplicated
- Throws
- IllegalStateException - if registration has closed
mod.registerSettlementMap(rules)МетодRegisters one location-map policy and its paid arrival offers.
ModContext · Хуки и жизненный цикл
Подпись
void registerSettlementMap(SettlementMap rules)Registers one location-map policy and its paid arrival offers.
Пример звонка
mod.registerSettlementMap(rules);ModContext mod is supplied to GameMod.register. Registration closes when that callback returns.
- Parameters
- rules - pure location and recruitment policy
- Throws
- IllegalArgumentException - for a null or duplicate policy or an unsupported manifest declaration
- Throws
- IllegalStateException - after startup registration closes
mod.registerSettlementTradeCore(core)МетодPublishes this mod's shared trading configuration for declared dependents.
ModContext · Хуки и жизненный цикл
Подпись
default void registerSettlementTradeCore(SettlementTradeCore core)Publishes this mod's shared trading configuration for declared dependents. The provider must validate its production rules through onRegistriesReady(java.util.function.Consumer<forgottentowns.mod.api.RegistryAccess>).
Пример звонка
mod.registerSettlementTradeCore(core);ModContext mod is supplied to GameMod.register. Registration closes when that callback returns.
- Parameters
- core - immutable rule sets, also usable by the provider's own policy
- Throws
- IllegalArgumentException - if null, duplicated or unsupported by the manifest
- Throws
- IllegalStateException - after startup registration closes
- Throws
- UnsupportedOperationException - if this host does not support trading cores
mod.registerSettlementTrading(rules)МетодRegisters one settlement trading policy for this mod, including shared UI panels.
ModContext · Хуки и жизненный цикл
Подпись
void registerSettlementTrading(SettlementTrading rules)Registers one settlement trading policy for this mod, including shared UI panels.
Пример звонка
mod.registerSettlementTrading(rules);ModContext mod is supplied to GameMod.register. Registration closes when that callback returns.
- Parameters
- rules - pure policy controlling availability and economic rules
- Throws
- IllegalArgumentException - if null, duplicated, or unsupported by the manifest
- Throws
- IllegalStateException - if startup registration has closed
mod.registerTradeFilter(filter)МетодRegisters a resource filter applied to merchant and settlement commerce in both directions.
ModContext · Хуки и жизненный цикл
Подпись
default void registerTradeFilter(Predicate<String> filter)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 through onRegistriesReady(java.util.function.Consumer<forgottentowns.mod.api.RegistryAccess>).
Пример звонка
mod.registerTradeFilter(filter);ModContext mod is supplied to GameMod.register. Registration closes when that callback returns.
- Parameters
- filter - predicate receiving a stable resource ID
- Throws
- IllegalArgumentException - if null, duplicated, or the manifest predates API 15
- Throws
- IllegalStateException - after startup registration closes
- Throws
- UnsupportedOperationException - if the host predates resource trade filters
mod.registerWorldInspection(inspection)МетодEnables dedicated viewport inspectors for this mod.
ModContext · Хуки и жизненный цикл
Подпись
default void registerWorldInspection(WorldInspection inspection)Enables dedicated viewport inspectors for this mod.
Пример звонка
mod.registerWorldInspection(inspection);ModContext mod is supplied to GameMod.register. Registration closes when that callback returns.
- Parameters
- inspection - supported inspection targets
- Throws
- IllegalArgumentException - if null, duplicated, or unsupported by the manifest
- Throws
- IllegalStateException - after startup registration closes
- Throws
- UnsupportedOperationException - if the host predates inspection support
ColonyExtension.update(ColonyContext)КрюкRebuilds derived citizen modifiers on first attachment, after load, and once per game minute.
ColonyExtension · Хуки и жизненный цикл
Подпись
void update(ColonyContext context)Rebuilds derived citizen modifiers on first attachment, after load, and once per game minute. This callback may also run after conversations, committed events, or paused content changes; keep calendar actions idempotent by saved day.
Реализуйте этот крючок
public void update(ColonyContext context);The engine calls your implementation; implement this signature in the registered hook.
- Parameters
- context - current bounded world queries and validated commands
ColonyExtensionТипOne mod-owned simulation instance per world, created through ModContext.registerColonyExtension(java.util.function.Supplier<forgottentowns.mod.api.ColonyExtension>).
ColonyExtension · Хуки и жизненный цикл
Подпись
public interface ColonyExtensionOne mod-owned simulation instance per world, created through ModContext.registerColonyExtension(java.util.function.Supplier<forgottentowns.mod.api.ColonyExtension>). Callbacks execute on the simulation thread. Never retain a context or use engine implementation classes. State is a bounded string map inside the atomic save, so loading never deserializes mod classes. Startup validation creates disposable instances and exercises empty-state restore and save/restore. Constructors and persistence callbacks must therefore be free of external side effects.
ColonyExtension.affinities(ColonyContext.View)КрюкProjects directed citizen feelings into the native roster, after all extensions update.
ColonyExtension · Хуки и жизненный цикл
Подпись
default List<ColonyAffinity> affinities(ColonyContext.View world)Projects directed citizen feelings into the native roster, after all extensions update. Called at simulation refresh boundaries, never during drawing. Return at most 16384 unique directed pairs per extension; different providers remain separate. Neutral values and pairs involving missing, dead, or deserting citizens are omitted. Keep persistent relationship state in this mod's save.
Реализуйте этот крючок
public List<ColonyAffinity> affinities(ColonyContext.View world);The engine calls your implementation; implement this signature in the registered hook.
- Parameters
- world - current read-only colony view, valid only during this callback
- Returns
- nonnull detached list of nonnull directed affinities, or an empty list when this mod supplies none
ColonyExtension.moods(ColonyContext.View, ColonyContext.Person)КрюкSupplies current happiness modifiers after all extensions have updated their citizen modifiers.
ColonyExtension · Хуки и жизненный цикл
Подпись
default List<ColonyContext.Mood> moods(ColonyContext.View world, ColonyContext.Person citizen)Supplies current happiness modifiers after all extensions have updated their citizen modifiers. Effects with the same nonempty stacking key use the greatest absolute value instead of adding. Equal absolute values retain the earlier provider's contribution. Only living, non-deserting recipients are queried; return at most 32 moods for one recipient.
Реализуйте этот крючок
public List<ColonyContext.Mood> moods(ColonyContext.View world, ColonyContext.Person citizen);The engine calls your implementation; implement this signature in the registered hook.
- Parameters
- world - current read-only colony view
- Parameters
- citizen - recipient snapshot
- Returns
- nonnull list of nonnull localized, finite happiness rates per in-game minute
ColonyExtension.onConversation(ColonyContext, int, int)КрюкObserves one newly started social exchange, independent of audio admission, muting or camera position.
ColonyExtension · Хуки и жизненный цикл
Подпись
default void onConversation(ColonyContext context, int first, int second)Observes one newly started social exchange, independent of audio admission, muting or camera position.
Реализуйте этот крючок
public void onConversation(ColonyContext context, int first, int second);The engine calls your implementation; implement this signature in the registered hook.
- Parameters
- context - scoped colony queries and commands
- Parameters
- first - first participant's stable citizen identity
- Parameters
- second - second participant's stable citizen identity
ColonyExtension.onEvent(ColonyContext, ColonyEvent)КрюкObserves a committed native change, after native accounting finishes.
ColonyExtension · Хуки и жизненный цикл
Подпись
default void onEvent(ColonyContext context, ColonyEvent event)Observes a committed native change, after native accounting finishes. Events generated by a callback wait until the next delivery boundary. Pending events and their effects are drained before saving; notifications are not replayed after loading. Ignore event types the mod does not use. No callback can cancel the native change.
Реализуйте этот крючок
public void onEvent(ColonyContext context, ColonyEvent event);The engine calls your implementation; implement this signature in the registered hook.
- Parameters
- context - scoped colony services
- Parameters
- event - detached typed event
ColonyExtension.onPanelAction(ColonyContext, String, String)КрюкHandles an enabled button from this extension's latest panel projection.
ColonyExtension · Хуки и жизненный цикл
Подпись
default void onPanelAction(ColonyContext context, String panelId, String actionId)Handles an enabled button from this extension's latest panel projection. Recheck gameplay prerequisites through the scoped services; other mods may have changed the world. Keep durable action outcomes in the ordinary extension save map. Drawing never calls this method.
Реализуйте этот крючок
public void onPanelAction(ColonyContext context, String panelId, String actionId);The engine calls your implementation; implement this signature in the registered hook.
- Parameters
- context - scoped world queries and commands, with the usual shared command budget
- Parameters
- panelId - stable mod-local panel identity
- Parameters
- actionId - stable mod-local action identity
ColonyExtension.onWorkFinished(ColonyContext, ColonyWork.Job)КрюкObserves completed or cancelled settlement work, including player-created jobs.
ColonyExtension · Хуки и жизненный цикл
Подпись
default void onWorkFinished(ColonyContext context, ColonyWork.Job job)Observes completed or cancelled settlement work, including player-created jobs. Delivery occurs after a simulation tick, before the next refresh, or before any save data is captured. Native mutation and resource accounting have finished before this callback. Events are not replayed after load; save owned job IDs and any handled outcome in this extension's state. Events caused by callbacks are delivered at the next boundary.
Реализуйте этот крючок
public void onWorkFinished(ColonyContext context, ColonyWork.Job job);The engine calls your implementation; implement this signature in the registered hook.
- Parameters
- context - scoped colony services
- Parameters
- job - immutable terminal job snapshot
ColonyExtension.panels(ColonyContext.View)КрюкProjects up to eight localized native information/action panels.
ColonyExtension · Хуки и жизненный цикл
Подпись
default List<ColonyPanel> panels(ColonyContext.View world)Projects up to eight localized native information/action panels. Called at simulation refresh boundaries and immediately before a panel action, never while drawing. This query must not change persistent state. Return an empty list to hide this mod's panels.
Реализуйте этот крючок
public List<ColonyPanel> panels(ColonyContext.View world);The engine calls your implementation; implement this signature in the registered hook.
- Parameters
- world - current callback-scoped read-only view
- Returns
- nonnull list of at most eight nonnull panel descriptions with unique mod-local identities; the host copies the list
ColonyExtension.providesAffinities()КрюкDeclares that this extension supplies affinity presentation, even before relationships exist.
ColonyExtension · Хуки и жизненный цикл
Подпись
default boolean providesAffinities()Declares that this extension supplies affinity presentation, even before relationships exist. The host snapshots this capability at simulation refresh boundaries and never calls it while drawing. The default leaves the panel hidden unless the extension returns affinity data, allowing data-only providers.
Реализуйте этот крючок
public boolean providesAffinities();The engine calls your implementation; implement this signature in the registered hook.
- Returns
- whether this world should expose the affinity panel while this extension is active
ColonyExtension.restore(Map<String, String>)КрюкRestores this mod's state before its first refresh.
ColonyExtension · Хуки и жизненный цикл
Подпись
default void restore(Map<String,String> state)Restores this mod's state before its first refresh. An empty map is supplied for a newly enabled mod and may also be a prior intentionally empty save.
Реализуйте этот крючок
public void restore(Map<String,String> state);The engine calls your implementation; implement this signature in the registered hook.
- Parameters
- state - detached, immutable, mod-owned save values
- Throws
- IllegalArgumentException - if a stored schema cannot be restored
ColonyExtension.save()КрюкCaptures persistent values; include a schema version when publishing persistent behavior.
ColonyExtension · Хуки и жизненный цикл
Подпись
default Map<String,String> save()Captures persistent values; include a schema version when publishing persistent behavior.
Реализуйте этот крючок
public Map<String,String> save();The engine calls your implementation; implement this signature in the registered hook.
- Returns
- nonnull string map with no null entries, at most 16384 entries and one MiB of UTF-8 key/value data; the host makes an immutable copy
context.inventory().transfer(source, destination, resourceId, amount)МетодImmediately transfers an exact quantity between two concrete stores.
ColonyInventory · Инвентарь и работа
Подпись
boolean transfer(String source, String destination, String resourceId, int amount)Immediately transfers an exact quantity between two concrete stores. This is a scripted inventory operation, not a hauling order. Filters, aggregate stack-size capacity, and integer overflow are checked before mutation; stack metadata and age buckets are preserved. Capacity estimation does not distinguish individual copies' metadata. A rejected transfer changes neither store.
Пример звонка
context.inventory().transfer(source, destination, resourceId, amount);Obtain this service from the active ColonyContext; it shares the callback lifetime and command budget.
- Parameters
- source - existing source key
- Parameters
- destination - existing destination key, distinct from source
- Parameters
- resourceId - registered resource identity
- Parameters
- amount - quantity from 1 through 4096
- Returns
- whether the full quantity moved
- Throws
- IllegalArgumentException - if amount is outside its bounds
- Throws
- IllegalStateException - outside the callback/thread or after its shared 128-command budget
Read an entry
- Method: a function your mod calls on the supplied service or value.
- Hook: a callback the game calls on your registered implementation.
- Constructor: creates an API value.
- Constant: a fixed value, such as a facing or work queue.
Expand an entry for its signature, parameters, return value, exceptions and call shape. Call shapes show the real parameter names as placeholders; supply values of the declared types. Read the lifetime and ownership rules before retaining an object or issuing a command.
Java setup · Registration and lifecycle · Task guides · Full generated Javadocs
