This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
tutorial:modding_imc [2014/10/10 18:10] sangar created |
tutorial:modding_imc [2015/04/23 17:45] (current) sangar |
||
---|---|---|---|
Line 8: | Line 8: | ||
``` | ``` | ||
{ | { | ||
+ | name : `String` // Optional, name of the template, used in logging only. | ||
select : `String` // Name of a static method that's queried to determine whether the template applies to an item stack. | select : `String` // Name of a static method that's queried to determine whether the template applies to an item stack. | ||
validate : `String` // Name of static method to call for checking if assembly may be started. Returns additional lines for the assemble button and text for the status bar. | validate : `String` // Name of static method to call for checking if assembly may be started. Returns additional lines for the assemble button and text for the status bar. | ||
assemble : `String` // Name of a static method that is called to create the resulting ItemStack and energy to consume. | assemble : `String` // Name of a static method that is called to create the resulting ItemStack and energy to consume. | ||
- | hostName : `String` // Name of a class or interface that is the environment or implemented by the environment that will represent the assembled device. Passed to HostAware drivers. | + | hostClass : `String` // Name of a class or interface that is the environment or implemented by the environment that will represent the assembled device. Passed to HostAware drivers. |
componentSlots : `NBTTagList` { | componentSlots : `NBTTagList` { | ||
`NBTTagCompound` { | `NBTTagCompound` { | ||
Line 34: | Line 35: | ||
``` | ``` | ||
- | Callbacks | ||
- | --------- | ||
Signatures for callbacks: | Signatures for callbacks: | ||
- Template selector: `boolean select(ItemStack stack)` | - Template selector: `boolean select(ItemStack stack)` | ||
- Build validator: `Object[] validate(IInventory inventory)` | - Build validator: `Object[] validate(IInventory inventory)` | ||
- | Values in the returned array: a boolean indicating whether the current configuration is valid for assembly, a string to display in the progress bar and a string array of lines to display in the assemble button tooltip. All are optional, defaulting to false, null and empty, respectively. | + | Values in the returned array: a boolean indicating whether the current configuration is valid for assembly, an IChatComponent to display in the progress bar and an IChatComponent array of lines to display in the assemble button tooltip. All are optional, defaulting to false, null and empty, respectively. |
- Assembly callback: `Object[] assemble(IInventory inventory)` | - Assembly callback: `Object[] assemble(IInventory inventory)` | ||
Values in the returned array: the ItemStack to produce and a Double value, indicating the energy to consume (and thus the time it takes to build the object). | Values in the returned array: the ItemStack to produce and a Double value, indicating the energy to consume (and thus the time it takes to build the object). | ||
Line 71: | Line 70: | ||
Tiers are simply numeric, starting with `0` as tier 1 and ending with `2` as tier 3. `Int.MaxInt` / `Integer.MAX_VALUE` indicate "any tier", meaning no tier indicator will be shown in the GUI slot. | Tiers are simply numeric, starting with `0` as tier 1 and ending with `2` as tier 3. `Int.MaxInt` / `Integer.MAX_VALUE` indicate "any tier", meaning no tier indicator will be shown in the GUI slot. | ||
- | Disassembly (Not yet implemented) | + | Disassembly |
----------- | ----------- | ||
- | `registerDisassemblerHandler` takes one String, which is the name of a static function with the following format: | + | `registerDisassemblerTemplate` takes an NBT tag with the following format: |
+ | ``` | ||
+ | { | ||
+ | name : `String` // This is optional, used only in logging. | ||
+ | select : `String` // Name of static method to call for checking if a stack can be disassembled. | ||
+ | disassemble : `String` // Name of static method to call to to get results for a disassembly operation. | ||
+ | } | ||
+ | ``` | ||
+ | |||
+ | Signatures for callbacks: | ||
- | - `ItemStack[] disassemble(ItemStack stack)` | + | - `boolean select(ItemStack stack)` |
- | Return null if the stack is not handled. | + | Gets the stack to check for validity, returns true if the stack can be disassembled. |
+ | - `ItemStack[] disassemble(ItemStack stack, ItemStack[] ingredients)` | ||
+ | Compute the items to output from the disassembler for the specified item stack. The passed list of ingredients is for convenience, and is what OC thinks are the inputs used to craft the passed item stack. The general idea is that you can return that list *plus* additional items, such as stuff that was "in" the passed stack, if the stack has some kind of inventory (e.g. for servers the installed components are also returned). | ||
It will be called whenever *any* item is disassembled, and should only return a list of (additional) ingredients where appropriate. It will also be called to check if an item can be disassembled at all. | It will be called whenever *any* item is disassembled, and should only return a list of (additional) ingredients where appropriate. It will also be called to check if an item can be disassembled at all. | ||
Line 89: | Line 99: | ||
nbt.setString("assemble", "com.example.mod.Callbacks.ocAssemblerAssemble"); | nbt.setString("assemble", "com.example.mod.Callbacks.ocAssemblerAssemble"); | ||
// ... | // ... | ||
- | FMLInterModComms.sendMessage("OpenComputers", "registerAssemblerTemplate", nbt); | + | FMLInterModComms.sendMessage("OpenComputers", "registerDisassemblerTemplate", nbt); |
``` | ``` | ||