Fabric API

Fabric API

108M Downloads

Add `BlockApiLookup#registerForBlockEntity` that casts to the correct block entity type internally.

Technici4n opened this issue ยท 0 comments

commented

Instead of

LOOKUP.registerForBlockEntities((world, be) -> ((MyBlockEntity) be).getApi(), MY_BLOCK_ENTITY_TYPE);

it would allow

LOOKUP.registerForBlockEntity((world, be) -> be.getApi(), MY_BLOCK_ENTITY_TYPE);

assuming MY_BLOCK_ENTITY_TYPE is BlockEntityType<MyBlockEntity>.

The cast isn't possible with a vararg due to how generics interact with arrays, so the new function would only allow a single block entity type per function call.

(suggested by @shartte).