use of org.terasology.physics.shapes.BoxShape in project Terasology by MovingBlocks.
the class ItemPickupAuthoritySystem method updateExtentsOnBlockItemBoxShape.
@ReceiveEvent
public void updateExtentsOnBlockItemBoxShape(OnAddedComponent event, EntityRef itemEntity, BlockItemComponent blockItemComponent, BoxShapeComponent boxShapeComponent) {
BlockFamily blockFamily = blockItemComponent.blockFamily;
if (blockFamily == null) {
LOGGER.warn("Prefab " + itemEntity.getParentPrefab().getName() + " does not have a block family");
return;
}
if (blockFamily.getArchetypeBlock().getCollisionShape() instanceof BoxShape) {
BoxShape collisionShape = (BoxShape) blockFamily.getArchetypeBlock().getCollisionShape();
Vector3f extents = collisionShape.getHalfExtentsWithoutMargin();
extents.scale(2.0f);
extents.x = Math.max(extents.x, 0.5f);
extents.y = Math.max(extents.y, 0.5f);
extents.z = Math.max(extents.z, 0.5f);
boxShapeComponent.extents.set(extents);
itemEntity.saveComponent(boxShapeComponent);
}
}
Aggregations