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
  • Nested Class Summary

    Nested classes/interfaces inherited from class net.neoforged.bus.api.Event

    net.neoforged.bus.api.Event.HasResult, net.neoforged.bus.api.Event.Result
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    <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.
    <T, C, P extends IPart>
    void
    register(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 than Direction, you need to register a mapping function for AE2 to get the side from the context.

    Methods inherited from class net.neoforged.bus.api.Event

    getResult, hasResult, setResult

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 than Direction, 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, P extends IPart> void register(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.