技术文档有英文版本。代码和字段名称遵循当前的 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
1 匹配条目 · 浏览所有条目
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
