Following the mantra of “if you break it, break it hard”, I took the opportunity to do some - in my opinion much needed - refactoring in the API. This resulted in a clearer structure (well, at least I think so), but also a lot of moving and renaming, meaning even if you only use a few things from the API, you'll probably have to adapt nonetheless.
The following documents all changes since the API in OC v1.3, in an attempt to make migrating as painless as possible. If you notice any changes that are not documented here, please do let me know, so I can add them, thank you!
These additions are purely incremental, that is they are either completely new interfaces, or new methods on existing interfaces that only serve to provide access to internal structures, meaning you do not implement them yourself. Most of these changes do not require any action on your side.
worksWith. This allows for container aware drivers, which is useful for upgrades that only work in certain hosts (for example, inventory upgrades only make sense for robots, but not for tablets).
name()method on architectures and allows static name lookup. This is used to get the name of architectures without having to instantiate them.
optXYZmethods for easier valdation of optional arguments, as well as a method
toArraywhich converts the argument list to an array and converts byte arrays to strings.
component.host) or a userdata (
Value). The returned map contains the names of all present methods together with their callback annotations.
recomputeMemoryon it manually.
recomputeMemory, call this.
Callbackannotation of a specific method. It is exposed mainly to allow implementation of custom architectures without needing reflection, which is something that was missing in the previous version of the API. Oops.
These changes may require some action on your side. For the most part they resulted from a bit of refactoring, so updating your imports and references suffices in most cases. A few interfaces were renamed and a few methods were added to interfaces that are implemented on the 'using' side, as well as a few signature changes.
li.cil.oc.api.driver.EnvironmentHost. This name better reflects what this interface actually represents. It also clears the name for drivers of type
Container(such as card or upgrade containers, or disk drives), which are used in robots.
li.cil.oc.api.driver.item.Container. This is a more appropriate name, since containers are not exclusive to upgrades, but may also house any other type of component. The new package serves a clearer separation of basic driver interfaces and item driver specializations.
li.cil.oc.api.driver.item.Inventory. The new package serves a clearer separation of basic driver interfaces and item driver specializations.
li.cil.oc.api.driver.item.Memory. The new package serves a clearer separation of basic driver interfaces and item driver specializations.
li.cil.oc.api.driver.item.Processor. The new package serves a clearer separation of basic driver interfaces and item driver specializations.
li.cil.oc.api.event.RobotUsedToolEvent. For consistency.
li.cil.oc.api.machine.Arguments. This is an effort to keep all machine related interfaces (as opposed to network related) in one package, for clarity.
li.cil.oc.api.machine.Callback. This is an effort to keep all machine related interfaces (as opposed to network related) in one package, for clarity.
li.cil.oc.api.machine.Context. This is an effort to keep all machine related interfaces (as opposed to network related) in one package, for clarity.
li.cil.oc.api.machine.MachineHostwhich is more clear.
li.cil.oc.api.internal.Rotatable. This is an effort to keep all interfaces that are or should be implemented by tile entities in one package, for clarity.
li.cil.oc.api.internal.Robot. This is an effort to keep all interfaces that are or should be implemented by tile entities in one package, for clarity.
This is the part with the most breaking changes, which require the most work to adjust to. These changes may require you to update references to methods, change names of implementing methods, change call signatures or implement new methods. Again, sorry for that, but I feel the changes were either necessary or ultimately lead to a clearer API. See the notes on how to adjust for each of these changes for specific pointers where needed.
li.cil.oc.api.FileSystem.asManagedEnvironment(FileSystem, Label, EnvironmentHost)
li.cil.oc.api.FileSystem.asManagedEnvironment(FileSystem, Label, EnvironmentHost, String). Takes additional parameter, name of the sound effect to play when file system is being accessed.
li.cil.oc.api.FileSystem.asManagedEnvironment(FileSystem, String, EnvironmentHost)
li.cil.oc.api.FileSystem.asManagedEnvironment(FileSystem, String, EnvironmentHost, String). Takes additional parameter, name of the sound effect to play when file system is being accessed. How to adjust: pass name of sound effect to play on filesystem access,
Slotenum (which has been removed).
Processorinterface to provide a custom architecture for computers to use based on the CPU item.
api.Machine.LuaArchitectureor your own.
Slotenum (which has been removed).
li.cil.oc.api.machine.Machine.host()to reflect interface name change.
li.cil.oc.api.machine.EnvironmentHostto reduce redundancy, x, y and z getters are gone now, in favor of xPosition, yPosition and zPosition.
MachineHostinterface to allow providing a custom direct call budget for machines, enabling machines that run at different speeds. In OC this value is based on the tier of the installed CPU, with the values being 0.5, 1.0 and 1.5 for the tiers one, two and three, respectively. How to adjust: return desired call budget for machine, 1.0 being equivalent to before.
li.cil.oc.api.machine.MachineHost.markForSavingto clarify difference to EnvironmentHost's markChanged (which usually means the inventory changed).
li.cil.oc.api.Machine.create(MachineHost, Class<? extends Architecture>)
hostClass, a string that is the fully qualified class name of the environment host the generated device will use. This is used to provide said class to drivers to allow them to check whether they wish to work in the environment or not. For now this is used to disable a couple of components for tablets, where they wouldn't work anyway (e.g. inventory upgrade).