diff --git a/fabric-api-lookup-api-v1/src/main/java/net/fabricmc/fabric/impl/lookup/block/BlockApiLookupImpl.java b/fabric-api-lookup-api-v1/src/main/java/net/fabricmc/fabric/impl/lookup/block/BlockApiLookupImpl.java index c98dc9419..92909d175 100644 --- a/fabric-api-lookup-api-v1/src/main/java/net/fabricmc/fabric/impl/lookup/block/BlockApiLookupImpl.java +++ b/fabric-api-lookup-api-v1/src/main/java/net/fabricmc/fabric/impl/lookup/block/BlockApiLookupImpl.java @@ -153,17 +153,17 @@ public final class BlockApiLookupImpl implements BlockApiLookup { throw new IllegalArgumentException("Must register at least one BlockEntityType instance with a BlockEntityApiProvider."); } - BlockApiProvider nullCheckedProvider = (world, pos, state, blockEntity, context) -> { - if (blockEntity == null) { - return null; - } else { - return provider.find(blockEntity, context); - } - }; - for (BlockEntityType blockEntityType : blockEntityTypes) { Objects.requireNonNull(blockEntityType, "Encountered null block entity type while registering a block entity API provider mapping."); + BlockApiProvider nullCheckedProvider = (world, pos, state, blockEntity, context) -> { + if (blockEntity == null || blockEntity.getType() != blockEntityType) { + return null; + } else { + return provider.find(blockEntity, context); + } + }; + Block[] blocks = ((BlockEntityTypeAccessor) blockEntityType).getBlocks().toArray(new Block[0]); registerForBlocks(nullCheckedProvider, blocks); }