Class CapabilityRegistry<C>
java.lang.Object
net.neoforged.neoforge.capabilities.CapabilityRegistry<C>
Helper class to manage registering capabilities.
You only need this if you are creating your own type (block, entity, item...) of capabilities!
Look at the source code of BlockCapability
, EntityCapability
, ... for an example.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
private static final record
-
Field Summary
Modifier and TypeFieldDescriptionprivate final ConcurrentMap
<ResourceLocation, CapabilityRegistry.StoredCap<C>> private final CapabilityRegistry.CapabilityConstructor
<C> -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncreate
(ResourceLocation name, Class<?> typeClass, Class<?> contextClass) Creates a new capability with the given name, type class and context class, or returns an existing one if it was already created.getAll()
Returns an immutable copy of all the currently known capabilities.
-
Field Details
-
caps
-
constructor
-
-
Constructor Details
-
CapabilityRegistry
-
-
Method Details
-
create
Creates a new capability with the given name, type class and context class, or returns an existing one if it was already created.- Parameters:
name
- name of the capabilitytypeClass
- class of the queried objectcontextClass
- class of the additional context- Throws:
IllegalStateException
- if a capability with the same name but different type or context class was already created
-
getAll
Returns an immutable copy of all the currently known capabilities.
-