Class PartApiLookup

java.lang.Object
appeng.api.inventories.PartApiLookup

public final class PartApiLookup extends Object
Exposes Block APIs for parts. This allows parts to answer to API queries made via BlockApiLookup.find(net.minecraft.world.level.Level, net.minecraft.core.BlockPos, C) on AE2's multipart blocks.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <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.
    static <A, C> A
    find(net.fabricmc.fabric.api.lookup.v1.block.BlockApiLookup<A,C> lookup, C context, IPart part)
     
    static <C> net.minecraft.core.Direction
    mapContext(net.fabricmc.fabric.api.lookup.v1.block.BlockApiLookup<?,C> lookup, C context)
     
    static <A, C, P extends IPart>
    void
    register(net.fabricmc.fabric.api.lookup.v1.block.BlockApiLookup<A,C> lookup, PartApiLookup.PartApiProvider<A,C,P> provider, Class<P> partClass)
    Expose an API for a part class.
    static <A, C> void
    registerCustomContext(net.fabricmc.fabric.api.lookup.v1.block.BlockApiLookup<A,C> lookup, Function<C,net.minecraft.core.Direction> mappingFunction)
    Register a function mapping the context of the passed lookup to Direction.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • registerCustomContext

      public static <A, C> void registerCustomContext(net.fabricmc.fabric.api.lookup.v1.block.BlockApiLookup<A,C> lookup, Function<C,net.minecraft.core.Direction> mappingFunction)
      Register a function mapping the context of the passed lookup to Direction. This is necessary when the context is not Direction.

      The location is only used to resolve which part the query targets; the api provider will receive the original context. If the mapping function returns null, no API will be returned for the query.

      If multiple mapping functions are registered for a given lookup, it is the first that will be used.

    • register

      public static <A, C, P extends IPart> void register(net.fabricmc.fabric.api.lookup.v1.block.BlockApiLookup<A,C> lookup, PartApiLookup.PartApiProvider<A,C,P> provider, Class<P> partClass)
      Expose an API 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 static <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.
    • mapContext

      @Nullable public static <C> net.minecraft.core.Direction mapContext(net.fabricmc.fabric.api.lookup.v1.block.BlockApiLookup<?,C> lookup, C context)
    • find

      @Nullable public static <A, C> A find(net.fabricmc.fabric.api.lookup.v1.block.BlockApiLookup<A,C> lookup, C context, IPart part)