Package appeng.api.parts
Class RegisterPartCapabilitiesEvent
java.lang.Object
net.neoforged.bus.api.Event
appeng.api.parts.RegisterPartCapabilitiesEvent
- All Implemented Interfaces:
net.neoforged.fml.event.IModBusEvent
public class RegisterPartCapabilitiesEvent
extends net.neoforged.bus.api.Event
implements net.neoforged.fml.event.IModBusEvent
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T extends net.minecraft.world.level.block.entity.BlockEntity & IPartHost>
voidaddHostType
(net.minecraft.world.level.block.entity.BlockEntityType<T> hostType) Adds a new type of block entity that will participate in forwarding API lookups to its attached parts.<T,
C, P extends IPart>
voidregister
(net.neoforged.neoforge.capabilities.BlockCapability<T, C> capability, net.neoforged.neoforge.capabilities.ICapabilityProvider<P, C, T> provider, Class<P> partClass) Expose a capability for a part class.<T,
C> void registerContext
(net.neoforged.neoforge.capabilities.BlockCapability<T, C> capability, Function<C, net.minecraft.core.Direction> directionGetter) When using capabilities with a context other thanDirection
, you need to register a mapping function for AE2 to get the side from the context.
-
Constructor Details
-
RegisterPartCapabilitiesEvent
public RegisterPartCapabilitiesEvent()
-
-
Method Details
-
registerContext
public <T,C> void registerContext(net.neoforged.neoforge.capabilities.BlockCapability<T, C> capability, Function<C, net.minecraft.core.Direction> directionGetter) When using capabilities with a context other thanDirection
, you need to register a mapping function for AE2 to get the side from the context. It cannot determine which part on a part host should handle the capability otherwise. -
register
public <T,C, void registerP extends IPart> (net.neoforged.neoforge.capabilities.BlockCapability<T, C> capability, net.neoforged.neoforge.capabilities.ICapabilityProvider<P, C, T> provider, Class<P> partClass) Expose a capability for a part class.When looking for an API instance, providers are queried starting from the class of the part, and then moving up to its superclass, and so on, until a provider returning a nonnull API is found.
If the context of the lookup is not
Direction
, you need to register a mapping function for your custom context! That must be done before this function is called. Currently, the query will fail silently, but IT WILL throw an exception in the future! -
addHostType
public <T extends net.minecraft.world.level.block.entity.BlockEntity & IPartHost> void addHostType(net.minecraft.world.level.block.entity.BlockEntityType<T> hostType) Adds a new type of block entity that will participate in forwarding API lookups to its attached parts.
-