Class CapabilityRegistry<C>

java.lang.Object
net.neoforged.neoforge.capabilities.CapabilityRegistry<C>

public class CapabilityRegistry<C> extends Object
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.

  • Field Details

  • Constructor Details

  • Method Details

    • create

      public C create(net.minecraft.resources.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.
      Parameters:
      name - name of the capability
      typeClass - class of the queried object
      contextClass - class of the additional context
      Throws:
      IllegalStateException - if a capability with the same name but different type or context class was already created
    • getAll

      public List<C> getAll()
      Returns an immutable copy of all the currently known capabilities.