Class CapabilityConstructorRegistry

java.lang.Object
org.cyclops.cyclopscore.modcompat.capabilities.CapabilityConstructorRegistry

public class CapabilityConstructorRegistry extends Object
Registry for capabilities created by this mod.
  • Field Details

    • mod

      protected final ModBase mod
    • baked

      protected boolean baked
    • registeredTileEventListener

      protected boolean registeredTileEventListener
    • registeredEntityEventListener

      protected boolean registeredEntityEventListener
    • registeredItemStackEventListener

      protected boolean registeredItemStackEventListener
  • Constructor Details

    • CapabilityConstructorRegistry

      public CapabilityConstructorRegistry(ModBase mod)
  • Method Details

    • getMod

      protected ModBase getMod()
    • checkNotBaked

      protected void checkNotBaked()
    • registerTile

      public <T extends net.minecraft.world.level.block.entity.BlockEntity> void registerTile(Class<T> clazz, ICapabilityConstructor<?,T,T> constructor)
      Register a tile capability constructor.
      Type Parameters:
      T - The tile type.
      Parameters:
      clazz - The tile class.
      constructor - The capability constructor.
    • registerEntity

      public <T extends net.minecraft.world.entity.Entity> void registerEntity(Class<T> clazz, ICapabilityConstructor<?,T,T> constructor)
      Register an entity capability constructor.
      Type Parameters:
      T - The entity type.
      Parameters:
      clazz - The entity class.
      constructor - The capability constructor.
    • registerItem

      public <T extends net.minecraft.world.item.Item> void registerItem(Class<T> clazz, ICapabilityConstructor<?,T,net.minecraft.world.item.ItemStack> constructor)
      Register an item capability constructor.
      Type Parameters:
      T - The item type.
      Parameters:
      clazz - The item class.
      constructor - The capability constructor.
    • registerInheritableTile

      public <K, V> void registerInheritableTile(Class<K> clazz, ICapabilityConstructor<?,V,V> constructor)
      Register a tile capability constructor with subtype checking. Only call this when absolutely required, this will is less efficient than its non-inheritable counterpart.
      Type Parameters:
      K - The capability type.
      V - The tile type.
      Parameters:
      clazz - The tile class, all subtypes will be checked.
      constructor - The capability constructor.
    • registerInheritableEntity

      public <K, V> void registerInheritableEntity(Class<K> clazz, ICapabilityConstructor<?,V,V> constructor)
      Register an entity capability constructor with subtype checking. Only call this when absolutely required, this will is less efficient than its non-inheritable counterpart.
      Type Parameters:
      K - The capability type.
      V - The entity type.
      Parameters:
      clazz - The tile class, all subtypes will be checked.
      constructor - The capability constructor.
    • registerInheritableItem

      public <T> void registerInheritableItem(Class<T> clazz, ICapabilityConstructor<?,?,? extends net.minecraft.world.item.ItemStack> constructor)
      Register an item capability constructor with subtype checking. Only call this when absolutely required, this will is less efficient than its non-inheritable counterpart.
      Type Parameters:
      T - The tile type.
      Parameters:
      clazz - The tile class, all subtypes will be checked.
      constructor - The capability constructor.
    • registerItem

      public <T extends net.minecraft.world.item.Item> void registerItem(Supplier<T> itemSupplier, ICapabilityConstructor<?,T,net.minecraft.world.item.ItemStack> constructor)
      Register an item capability constructor for the given item instance.
      Type Parameters:
      T - The tile type.
      Parameters:
      itemSupplier - An item supplier.
      constructor - The capability constructor.
    • registerItemsEffective

      protected void registerItemsEffective()
    • registerItemEffective

      protected <T extends net.minecraft.world.item.Item> void registerItemEffective(Supplier<T> itemSupplier, ICapabilityConstructor<?,T,net.minecraft.world.item.ItemStack> constructor)
    • createProvider

      protected <K, KE, H, HE> net.minecraftforge.common.capabilities.ICapabilityProvider createProvider(KE hostType, HE host, ICapabilityConstructor<?,K,H> capabilityConstructor)
    • onLoad

      protected <T> void onLoad(Map<Class<? extends T>,List<ICapabilityConstructor<?,? extends T,? extends T>>> allConstructors, Collection<org.apache.commons.lang3.tuple.Pair<Class<?>,ICapabilityConstructor<?,?,?>>> allInheritableConstructors, @Nullable Map<? extends T,List<ICapabilityConstructor<?,? extends T,? extends T>>> allInstanceConstructors, T object, net.minecraftforge.event.AttachCapabilitiesEvent<?> event, Class<? extends T> baseClass)
    • onLoad

      protected <K, V> void onLoad(Map<Class<? extends K>,List<ICapabilityConstructor<?,? extends K,? extends V>>> allConstructors, Collection<org.apache.commons.lang3.tuple.Pair<Class<?>,ICapabilityConstructor<?,?,?>>> allInheritableConstructors, @Nullable Map<? extends K,List<ICapabilityConstructor<?,? extends K,? extends V>>> allInstanceConstructors, K keyObject, V valueObject, net.minecraftforge.event.AttachCapabilitiesEvent<?> event, Class<? extends K> baseClass)
    • addLoadedCapabilityProvider

      protected <K, V> void addLoadedCapabilityProvider(net.minecraftforge.event.AttachCapabilitiesEvent<?> event, K keyObject, V valueObject, ICapabilityConstructor<?,?,?> constructor)
    • removeNullCapabilities

      protected <K, V> void removeNullCapabilities(Map<Class<? extends K>,List<ICapabilityConstructor<?,? extends K,? extends V>>> allConstructors, Collection<org.apache.commons.lang3.tuple.Pair<Class<?>,ICapabilityConstructor<?,?,?>>> allInheritableConstructors, @Nullable Map<? extends K,List<ICapabilityConstructor<?,? extends K,? extends V>>> allInstanceConstructors)
    • bake

      public void bake()
      Bakes the registry so that it becomes immutable.