@ReceiveEvent
public void onBlockItemDropped(ItemDroppedEvent event, EntityRef itemEntity, BlockItemComponent blockItemComponent) {
EntityBuilder builder = event.getPickup();
BlockFamily blockFamily = blockItemComponent.blockFamily;
if (builder.hasComponent(MeshComponent.class)) {
MeshComponent mesh = builder.getComponent(MeshComponent.class);
mesh.mesh = blockFamily.getArchetypeBlock().getMesh();
mesh.material = Assets.getMaterial("engine:terrain");
}
if (blockFamily.getArchetypeBlock().getCollisionShape() instanceof BoxShape && builder.hasComponent(BoxShapeComponent.class)) {
Vector3f extents = ((BoxShape) blockFamily.getArchetypeBlock().getCollisionShape()).getHalfExtentsWithoutMargin(new Vector3f());