Changes

Start rewrite of Capability page
Line 1: Line 1:  +
'''Capabilities''' are a Forge system that allows cross-mod interactions by allowing capability ''providers'' to dynamically respect contracts and provide specialized behavior without requiring the implementation of many interfaces or hard dependencies on mods.
 +
 +
== History ==
 +
In an ideal world, all that would be needed for a mod to provide the equivalent of a capability would be implementing an interface. This is in fact how cross-mod interaction used to work prior to the introduction of capabilities.
 +
 +
The real world, though, is often much more complicated: users wanted to be free to combine mods the way they wanted and saw fit, and developers wanted to be able to declare ''soft'' dependencies on other mods, thus reducing the need of having a huge mod pack just for testing.
 +
 +
The first approach used by Forge was conditional stripping of interfaces and methods, but this proved to be problematic. While the idea works well in theory, in practice the ASM editing of classes relied on complex mechanics and could lead to hard to spot bugs.
 +
 +
For this reason, the entire system was redesigned and the concept of '''capabilities''' was born.
 +
 +
== The Concept ==
 +
A capability allows any capability provider to conditionally expose a certain ability to do something, e.g. accepting power or handling items. A capability provider, moreover, can decide to expose a capability only on certain sides, allowing for easy interactions with hoppers, cables, etc.
 +
 +
Capabilities may also be added and removed dynamically both from the "owner" of the capability provider and other mods, allowing even easier cross-mod interaction. For example, a mod that isn't compatible with
 +
Forge Energy could be converted into one by dynamically attaching the Forge Energy capability and handling the conversion to a third-party energy system without having to alter the original mod.
 +
 +
== Terminology ==
 +
The high flexibility of the system comes with a cost, though, which is terminology. The following section wants to be a dictionary of sorts, defining all the terms that you may come across when dealing with capabilities.
 +
 +
* '''Capability''': the ability to perform something; in-code this is represented by the <code>Capability</code> class.
 +
* '''Capability Provider''':
 +
 +
 +
 +
= OLD SHIT FOLLOWS =
 +
 +
 
Capabilities allow exposing features in a dynamic and flexible way, without having to resort to directly implementing many interfaces.
 
Capabilities allow exposing features in a dynamic and flexible way, without having to resort to directly implementing many interfaces.