Class Capability<T>
java.lang.Object
net.minecraftforge.common.capabilities.Capability<T>
This is the core holder object Capabilities.
Each capability will have ONE instance of this class,
and it will the the one passed into the ICapabilityProvider functions.
The CapabilityManager is in charge of creating this class.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddListener
(Consumer<Capability<T>> listener) Adds a listener to be called when someone registers this capability.getName()
boolean
(package private) void
<R> LazyOptional<R>
orEmpty
(Capability<R> toCheck, LazyOptional<T> inst)
-
Field Details
-
name
-
listeners
List<Consumer<Capability<T>>> listeners
-
-
Constructor Details
-
Capability
Capability(String name)
-
-
Method Details
-
getName
- Returns:
- The unique name of this capability, typically this is the fully qualified class name for the target interface.
-
orEmpty
-
isRegistered
public boolean isRegistered()- Returns:
- true if something has registered this capability to the Manager. This is a marker that the class for this capability exists, and can be used.
-
addListener
Adds a listener to be called when someone registers this capability. May be called instantly if this is already registered.- Parameters:
listener
- Function to fire when capability is registered.- Returns:
- self, in case people want to use builder pattern.
-
onRegister
void onRegister()
-