Class RegisterCapabilitiesEvent
java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent
- All Implemented Interfaces:
net.neoforged.fml.event.IModBusEvent
public class RegisterCapabilitiesEvent
extends net.neoforged.bus.api.Event
implements net.neoforged.fml.event.IModBusEvent
Fired to register capability providers at an appropriate time.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
isBlockRegistered
(BlockCapability<?, ?> capability, Block block) Returntrue
if a provider is registered for the given block and capability.boolean
isEntityRegistered
(EntityCapability<?, ?> capability, EntityType<?> entityType) Returntrue
if a provider is registered for the given entity type and capability.boolean
isItemRegistered
(ItemCapability<?, ?> capability, Item item) Returntrue
if a provider is registered for the given item and capability.<T,
C extends @Nullable Object>
voidregisterBlock
(BlockCapability<T, C> capability, IBlockCapabilityProvider<T, C> provider, Block... blocks) Register a capability provider for some blocks.<T,
C extends @Nullable Object, BE extends BlockEntity>
voidregisterBlockEntity
(BlockCapability<T, C> capability, BlockEntityType<BE> blockEntityType, ICapabilityProvider<? super BE, C, T> provider) Register a capability provider for a block entity type.registerEntity
(EntityCapability<T, C> capability, EntityType<E> entityType, ICapabilityProvider<? super E, C, T> provider) Register a capability provider for some entity type.<T,
C extends @Nullable Object>
voidregisterItem
(ItemCapability<T, C> capability, ICapabilityProvider<ItemStack, C, T> provider, ItemLike... items) Register a capability provider for some items.void
setNonProxyable
(BlockCapability<?, ?> capability) Makes a block capability non-proxyable.void
setProxyable
(BlockCapability<?, ?> capability) Makes a block capability proxyable, indicating that it is always safe to forward a request for this capability to another block.
-
Constructor Details
-
RegisterCapabilitiesEvent
RegisterCapabilitiesEvent()
-
-
Method Details
-
registerBlock
public <T,C extends @Nullable Object> void registerBlock(BlockCapability<T, C> capability, IBlockCapabilityProvider<T, C> provider, Block... blocks) Register a capability provider for some blocks.If a previously returned capability is not valid anymore, or if a new capability is available,
ILevelExtension.invalidateCapabilities(BlockPos)
MUST be called to notify the caches. SeeIBlockCapabilityProvider
for details. -
registerBlockEntity
public <T,C extends @Nullable Object, void registerBlockEntityBE extends BlockEntity> (BlockCapability<T, C> capability, BlockEntityType<BE> blockEntityType, ICapabilityProvider<? super BE, C, T> provider) Register a capability provider for a block entity type.If a previously returned capability is not valid anymore, or if a new capability is available,
ILevelExtension.invalidateCapabilities(BlockPos)
MUST be called to notify the caches. SeeIBlockCapabilityProvider
for details. -
isBlockRegistered
Returntrue
if a provider is registered for the given block and capability. -
setProxyable
Makes a block capability proxyable, indicating that it is always safe to forward a request for this capability to another block. (e.g. for "remote access" blocks)This method should only be called by the mod that defines the capability, in the
EventPriority.HIGH
orEventPriority.HIGHEST
phase.- Throws:
IllegalStateException
- if the capability was already marked as non-proxyable- See Also:
-
setNonProxyable
Makes a block capability non-proxyable. This should typically be called when unexpectedly proxying the capability (e.g. to a different block position) would cause crashes, for example because the returned capability is tied to the query position.This method should only be called by the mod that defines the capability, in the
EventPriority.HIGH
orEventPriority.HIGHEST
phase.- Throws:
IllegalStateException
- if the capability was already marked as proxyable- See Also:
-
registerEntity
public <T,C extends @Nullable Object, void registerEntityE extends Entity> (EntityCapability<T, C> capability, EntityType<E> entityType, ICapabilityProvider<? super E, C, T> provider) Register a capability provider for some entity type. -
isEntityRegistered
Returntrue
if a provider is registered for the given entity type and capability. -
registerItem
public <T,C extends @Nullable Object> void registerItem(ItemCapability<T, C> capability, ICapabilityProvider<ItemStack, C, T> provider, ItemLike... items) Register a capability provider for some items. -
isItemRegistered
Returntrue
if a provider is registered for the given item and capability.
-