Package appeng.api.inventories
Class PartApiLookup
java.lang.Object
appeng.api.inventories.PartApiLookup
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 ClassesModifier and TypeClassDescriptionstatic interfacePartApiLookup.PartApiProvider<A,C, P extends IPart> -
Method Summary
Modifier and TypeMethodDescriptionstatic <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.static <A,C> A static <C> @Nullable net.minecraft.core.DirectionmapContext(net.fabricmc.fabric.api.lookup.v1.block.BlockApiLookup<?, C> lookup, C context) static <A,C, P extends IPart>
voidregister(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 toDirection.
-
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 toDirection. This is necessary when the context is notDirection.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, void registerP extends IPart> (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> @Nullable 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)
-