技术文档有英文版本。代码和字段名称遵循当前的 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
528 匹配条目
homeChanged.equals(o)方法Indicates whether some other object is "equal to" this one.
ColonyEvent.HomeChanged · 活动和小组讨论
签名
public final boolean equals(Object o)Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
调用示例
homeChanged.equals(o);ColonyEvent.HomeChanged homeChanged is an instance of this supported API type.
- Specified by
- equals in class Record
- Parameters
- o - the object with which to compare
- Returns
- true if this object is the same as the o argument; false otherwise.
homeChanged.hashCode()方法Returns a hash code value for this object.
ColonyEvent.HomeChanged · 活动和小组讨论
签名
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
调用示例
homeChanged.hashCode();ColonyEvent.HomeChanged homeChanged is an instance of this supported API type.
- Specified by
- hashCode in class Record
- Returns
- a hash code value for this object
homeChanged.homeId()方法Returns new zone identity, or zero when unassigned.
ColonyEvent.HomeChanged · 活动和小组讨论
签名
public long homeId()Returns new zone identity, or zero when unassigned.
调用示例
homeChanged.homeId();ColonyEvent.HomeChanged homeChanged is an instance of this supported API type.
- Returns
- new zone identity, or zero when unassigned
homeChanged.position()方法Returns first tile of the new home, or of the former home when unassigned; null for a zone with an empty footprint.
ColonyEvent.HomeChanged · 活动和小组讨论
签名
public ColonyContext.Position position()Returns first tile of the new home, or of the former home when unassigned; null for a zone with an empty footprint.
调用示例
homeChanged.position();ColonyEvent.HomeChanged homeChanged is an instance of this supported API type.
- Returns
- first tile of the new home, or of the former home when unassigned; null for a zone with an empty footprint
homeChanged.previousHomeId()方法Returns former zone identity, or zero when unassigned.
ColonyEvent.HomeChanged · 活动和小组讨论
签名
public long previousHomeId()Returns former zone identity, or zero when unassigned.
调用示例
homeChanged.previousHomeId();ColonyEvent.HomeChanged homeChanged is an instance of this supported API type.
- Returns
- former zone identity, or zero when unassigned
homeChanged.toString()方法Returns a string representation of this record class.
ColonyEvent.HomeChanged · 活动和小组讨论
签名
public final String toString()Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
调用示例
homeChanged.toString();ColonyEvent.HomeChanged homeChanged is an instance of this supported API type.
- Specified by
- toString in class Record
- Returns
- a string representation of this object
ColonyEvent.PlaceableRemoved类型A placed object left the world, including demolition, destruction, replacement and cleanup.
ColonyEvent.PlaceableRemoved · 活动和小组讨论
签名
public static record ColonyEvent.PlaceableRemoved(long id, String definitionId, ColonyContext.Position position, boolean settlementOwned, int day) extends Record implements ColonyEventA placed object left the world, including demolition, destruction, replacement and cleanup. This notification alone does not establish combat damage or a resource refund.
- Record Components
- id - removed placeable identity
- Record Components
- definitionId - removed definition identity
- Record Components
- position - removed object's anchor and support layer
- Record Components
- settlementOwned - whether the object belonged to the settlement
- Record Components
- day - monotonic game day
new ColonyEvent.PlaceableRemoved构造函数Creates an instance of a PlaceableRemoved record class.
ColonyEvent.PlaceableRemoved · 活动和小组讨论
签名
public PlaceableRemoved(long id, String definitionId, ColonyContext.Position position, boolean settlementOwned, int day)Creates an instance of a PlaceableRemoved record class.
调用示例
new ColonyEvent.PlaceableRemoved(id, definitionId, position, settlementOwned, day);Use the public API type shown; import forgottentowns.mod.api.*.
- Parameters
- id - removed placeable identity
- Parameters
- definitionId - removed definition identity
- Parameters
- position - removed object's anchor and support layer
- Parameters
- settlementOwned - whether the object belonged to the settlement
- Parameters
- day - monotonic game day
placeableRemoved.day()方法Returns monotonic game day.
ColonyEvent.PlaceableRemoved · 活动和小组讨论
签名
public int day()Returns monotonic game day.
调用示例
placeableRemoved.day();ColonyEvent.PlaceableRemoved placeableRemoved is an instance of this supported API type.
- Specified by
- day in interface ColonyEvent
- Returns
- monotonic game day
placeableRemoved.definitionId()方法Returns removed definition identity.
ColonyEvent.PlaceableRemoved · 活动和小组讨论
签名
public String definitionId()Returns removed definition identity.
调用示例
placeableRemoved.definitionId();ColonyEvent.PlaceableRemoved placeableRemoved is an instance of this supported API type.
- Returns
- removed definition identity
placeableRemoved.equals(o)方法Indicates whether some other object is "equal to" this one.
ColonyEvent.PlaceableRemoved · 活动和小组讨论
签名
public final boolean equals(Object o)Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
调用示例
placeableRemoved.equals(o);ColonyEvent.PlaceableRemoved placeableRemoved is an instance of this supported API type.
- Specified by
- equals in class Record
- Parameters
- o - the object with which to compare
- Returns
- true if this object is the same as the o argument; false otherwise.
placeableRemoved.hashCode()方法Returns a hash code value for this object.
ColonyEvent.PlaceableRemoved · 活动和小组讨论
签名
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
调用示例
placeableRemoved.hashCode();ColonyEvent.PlaceableRemoved placeableRemoved is an instance of this supported API type.
- Specified by
- hashCode in class Record
- Returns
- a hash code value for this object
placeableRemoved.id()方法Returns removed placeable identity.
ColonyEvent.PlaceableRemoved · 活动和小组讨论
签名
public long id()Returns removed placeable identity.
调用示例
placeableRemoved.id();ColonyEvent.PlaceableRemoved placeableRemoved is an instance of this supported API type.
- Returns
- removed placeable identity
placeableRemoved.position()方法Returns removed object's anchor and support layer.
ColonyEvent.PlaceableRemoved · 活动和小组讨论
签名
public ColonyContext.Position position()Returns removed object's anchor and support layer.
调用示例
placeableRemoved.position();ColonyEvent.PlaceableRemoved placeableRemoved is an instance of this supported API type.
- Returns
- removed object's anchor and support layer
placeableRemoved.settlementOwned()方法Returns whether the object belonged to the settlement.
ColonyEvent.PlaceableRemoved · 活动和小组讨论
签名
public boolean settlementOwned()Returns whether the object belonged to the settlement.
调用示例
placeableRemoved.settlementOwned();ColonyEvent.PlaceableRemoved placeableRemoved is an instance of this supported API type.
- Returns
- whether the object belonged to the settlement
placeableRemoved.toString()方法Returns a string representation of this record class.
ColonyEvent.PlaceableRemoved · 活动和小组讨论
签名
public final String toString()Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
调用示例
placeableRemoved.toString();ColonyEvent.PlaceableRemoved placeableRemoved is an instance of this supported API type.
- Specified by
- toString in class Record
- Returns
- a string representation of this object
colonyEvent.day()方法Returns the monotonic game day when the change occurred.
ColonyEvent · 活动和小组讨论
签名
int day()Returns the monotonic game day when the change occurred.
调用示例
colonyEvent.day();ColonyEvent colonyEvent is an instance of this supported API type.
- Returns
- game day starting at one
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
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
