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.
li.cil.oc.api.driver.EnvironmentAware
li.cil.oc.api.driver.item.HostAware
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).
@li.cil.oc.api.machine.Architecture.Name
name()
method on architectures and allows static name lookup. This is used to get the name of architectures without having to instantiate them.
li.cil.oc.api.internal.Case
li.cil.oc.api.internal.Colored
li.cil.oc.api.internal.ServerRack
li.cil.oc.api.internal.Server
li.cil.oc.api.internal.Tablet
li.cil.oc.api.machine.Arguments
optXYZ
methods for easier valdation of optional arguments, as well as a method toArray
which converts the argument list to an array and converts byte arrays to strings.
li.cil.oc.api.machine.Callback.getter()/setter()
li.cil.oc.api.machine.Machine.methods(Object)
component.host
) or a userdata (Value
). The returned map contains the names of all present methods together with their callback annotations.Machine.documentation
.
li.cil.oc.api.machine.Machine.onHostChanged()
recomputeMemory
on it manually.recomputeMemory
, call this.
li.cil.oc.api.network.Component.annotation(String)
Callback
annotation 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.Container
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.UpgradeContainer
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.Inventory
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.Memory
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.Processor
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.RobotUsedTool
li.cil.oc.api.event.RobotUsedToolEvent
. For consistency.li.cil.oc.api.network.Arguments
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.network.Callback
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.network.Context
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.Owner
li.cil.oc.api.machine.MachineHost
which is more clear.li.cil.oc.api.Rotatable
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.machine.Robot
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.null
otherwise.
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.null
otherwise.
li.cil.oc.api.driver.Item.slot(ItemStack)
Slot
enum (which has been removed).li.cil.oc.api.driver.item.Slot
.
li.cil.oc.api.driver.NamedBlock.priority()
li.cil.oc.api.driver.Processor.architecture(ItemStack)
Processor
interface to provide a custom architecture for computers to use based on the CPU item.api.Machine.LuaArchitecture
or your own.
li.cil.oc.api.driver.item.Container.providedSlot(ItemStack)
Slot
enum (which has been removed).li.cil.oc.api.driver.item.Slot
.
li.cil.oc.api.machine.Machine.owner()
li.cil.oc.api.machine.Machine.host()
to reflect interface name change.li.cil.oc.api.machine.MachineHost
li.cil.oc.api.machine.EnvironmentHost
to reduce redundancy, x, y and z getters are gone now, in favor of xPosition, yPosition and zPosition.li.cil.oc.api.machine.MachineHost.callBudget()
MachineHost
interface 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.li.cil.oc.api.machine.MachineHost.markAsChanged()
li.cil.oc.api.machine.MachineHost.markForSaving
to clarify difference to EnvironmentHost's markChanged (which usually means the inventory changed).li.cil.oc.api.network.WirelessEndpoint.receivePacket(Packet packet, double distance)
receivePacket(Packet packet, WirelessEndpoint sender)
, which is much more versatile.li.cil.oc.api.prefab.ManagedEnvironment.node
node()
.node()
to access, use setNode(Node)
to set.li.cil.oc.api.Machine.create(MachineHost, Class<? extends Architecture>)
li.cil.oc.api.driver.Slot
li.cil.oc.api.driver.item.Slot
.li.cil.oc.api.machine.Architecture.name()
Architecture.Name
annotation.
li.cil.oc.api.machine.Machine.documentation(String, String)
methods
function.machine.methods(componentWithAddress.host)(methodName)
instead.
li.cil.oc.api.machine.Machine.documentation(Value)
methods
function.machine.methods(componentWithAddress.host)(methodName)
instead.registerAssemblerTemplate
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).Tutorials | Mod Specific | Basic Computer - Writing Code - Hard Drives - Autorun and Startup scripts | |
---|---|---|---|
Modding | Custom Architectures - IMC Messages - API changes in OC 1.3 - API changes in OC 1.4 - Build and Run master-MC1.7.10 from source | ||
Programs | OPPM - install | ||
Others | Custom Operating Systems |