FORGOTTEN TOWNS

FORGOTTEN TOWNS / DOCUMENTATION DE MODDING

Wiki de modding ↗

Référence de l’API Java (Javadoc)

MOD API 15

Parcourir le wiki

Documentation actuelle de l’API de modding.

La documentation technique est disponible en anglais. Le code et les noms de champs suivent l’API de modding actuelle.

DOCUMENTATION DE MODDING

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 types publics · 468 membres · Content API 15

Réinitialiser

528 entrées correspondantes

homeChanged.equals(o)MéthodeIndicates whether some other object is "equal to" this one.

ColonyEvent.HomeChanged · Événements et panneaux

Signature

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 '=='.

Exemple d’appel

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()MéthodeReturns a hash code value for this object.

ColonyEvent.HomeChanged · Événements et panneaux

Signature

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.

Exemple d’appel

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()MéthodeReturns new zone identity, or zero when unassigned.

ColonyEvent.HomeChanged · Événements et panneaux

Signature

public long homeId()

Returns new zone identity, or zero when unassigned.

Exemple d’appel

homeChanged.homeId();

ColonyEvent.HomeChanged homeChanged is an instance of this supported API type.

Returns
new zone identity, or zero when unassigned
homeChanged.position()MéthodeReturns first tile of the new home, or of the former home when unassigned; null for a zone with an empty footprint.

ColonyEvent.HomeChanged · Événements et panneaux

Signature

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.

Exemple d’appel

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()MéthodeReturns former zone identity, or zero when unassigned.

ColonyEvent.HomeChanged · Événements et panneaux

Signature

public long previousHomeId()

Returns former zone identity, or zero when unassigned.

Exemple d’appel

homeChanged.previousHomeId();

ColonyEvent.HomeChanged homeChanged is an instance of this supported API type.

Returns
former zone identity, or zero when unassigned
homeChanged.toString()MéthodeReturns a string representation of this record class.

ColonyEvent.HomeChanged · Événements et panneaux

Signature

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.

Exemple d’appel

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.PlaceableRemovedTypeA placed object left the world, including demolition, destruction, replacement and cleanup.

ColonyEvent.PlaceableRemoved · Événements et panneaux

Signature

public static record ColonyEvent.PlaceableRemoved(long id, String definitionId, ColonyContext.Position position, boolean settlementOwned, int day) extends Record implements ColonyEvent

A 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.PlaceableRemovedConstructeurCreates an instance of a PlaceableRemoved record class.

ColonyEvent.PlaceableRemoved · Événements et panneaux

Signature

public PlaceableRemoved(long id, String definitionId, ColonyContext.Position position, boolean settlementOwned, int day)

Creates an instance of a PlaceableRemoved record class.

Exemple d’appel

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()MéthodeReturns monotonic game day.

ColonyEvent.PlaceableRemoved · Événements et panneaux

Signature

public int day()

Returns monotonic game day.

Exemple d’appel

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()MéthodeReturns removed definition identity.

ColonyEvent.PlaceableRemoved · Événements et panneaux

Signature

public String definitionId()

Returns removed definition identity.

Exemple d’appel

placeableRemoved.definitionId();

ColonyEvent.PlaceableRemoved placeableRemoved is an instance of this supported API type.

Returns
removed definition identity
placeableRemoved.equals(o)MéthodeIndicates whether some other object is "equal to" this one.

ColonyEvent.PlaceableRemoved · Événements et panneaux

Signature

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 '=='.

Exemple d’appel

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()MéthodeReturns a hash code value for this object.

ColonyEvent.PlaceableRemoved · Événements et panneaux

Signature

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.

Exemple d’appel

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()MéthodeReturns removed placeable identity.

ColonyEvent.PlaceableRemoved · Événements et panneaux

Signature

public long id()

Returns removed placeable identity.

Exemple d’appel

placeableRemoved.id();

ColonyEvent.PlaceableRemoved placeableRemoved is an instance of this supported API type.

Returns
removed placeable identity
placeableRemoved.position()MéthodeReturns removed object's anchor and support layer.

ColonyEvent.PlaceableRemoved · Événements et panneaux

Signature

public ColonyContext.Position position()

Returns removed object's anchor and support layer.

Exemple d’appel

placeableRemoved.position();

ColonyEvent.PlaceableRemoved placeableRemoved is an instance of this supported API type.

Returns
removed object's anchor and support layer
placeableRemoved.settlementOwned()MéthodeReturns whether the object belonged to the settlement.

ColonyEvent.PlaceableRemoved · Événements et panneaux

Signature

public boolean settlementOwned()

Returns whether the object belonged to the settlement.

Exemple d’appel

placeableRemoved.settlementOwned();

ColonyEvent.PlaceableRemoved placeableRemoved is an instance of this supported API type.

Returns
whether the object belonged to the settlement
placeableRemoved.toString()MéthodeReturns a string representation of this record class.

ColonyEvent.PlaceableRemoved · Événements et panneaux

Signature

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.

Exemple d’appel

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()MéthodeReturns the monotonic game day when the change occurred.

ColonyEvent · Événements et panneaux

Signature

int day()

Returns the monotonic game day when the change occurred.

Exemple d’appel

colonyEvent.day();

ColonyEvent colonyEvent is an instance of this supported API type.

Returns
game day starting at one
ColonyExtensionTypeOne mod-owned simulation instance per world, created through ModContext.registerColonyExtension(java.util.function.Supplier<forgottentowns.mod.api.ColonyExtension>).

ColonyExtension · Points d’extension et cycle de vie

Signature

public interface ColonyExtension

One 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)Point d’extensionProjects directed citizen feelings into the native roster, after all extensions update.

ColonyExtension · Points d’extension et cycle de vie

Signature

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.

Implémenter ce point d’extension

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)Point d’extensionSupplies current happiness modifiers after all extensions have updated their citizen modifiers.

ColonyExtension · Points d’extension et cycle de vie

Signature

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.

Implémenter ce point d’extension

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)Point d’extensionObserves one newly started social exchange, independent of audio admission, muting or camera position.

ColonyExtension · Points d’extension et cycle de vie

Signature

default void onConversation(ColonyContext context, int first, int second)

Observes one newly started social exchange, independent of audio admission, muting or camera position.

Implémenter ce point d’extension

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)Point d’extensionObserves a committed native change, after native accounting finishes.

ColonyExtension · Points d’extension et cycle de vie

Signature

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.

Implémenter ce point d’extension

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)Point d’extensionHandles an enabled button from this extension's latest panel projection.

ColonyExtension · Points d’extension et cycle de vie

Signature

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.

Implémenter ce point d’extension

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)Point d’extensionObserves completed or cancelled settlement work, including player-created jobs.

ColonyExtension · Points d’extension et cycle de vie

Signature

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.

Implémenter ce point d’extension

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)Point d’extensionProjects up to eight localized native information/action panels.

ColonyExtension · Points d’extension et cycle de vie

Signature

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.

Implémenter ce point d’extension

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