* @param type The new type of the block
*/
private void updateBlockEntityComponents(EntityRef blockEntity, Block oldType, Block type, Set<Class<? extends Component>> retainComponents) {
BlockComponent blockComponent = blockEntity.getComponent(BlockComponent.class);
Prefab oldPrefab = Assets.getPrefab(oldType.getPrefab());
EntityBuilder oldEntityBuilder = entityManager.newBuilder(oldPrefab);
oldEntityBuilder.addComponent(new BlockComponent(oldType, new Vector3i(blockComponent.getPosition())));
BeforeEntityCreated oldEntityEvent = new BeforeEntityCreated(oldPrefab, oldEntityBuilder.iterateComponents());
blockEntity.send(oldEntityEvent);
for (Component comp : oldEntityEvent.getResultComponents()) {
oldEntityBuilder.addComponent(comp);
}
Prefab newPrefab = Assets.getPrefab(type.getPrefab());
EntityBuilder newEntityBuilder = entityManager.newBuilder(newPrefab);
newEntityBuilder.addComponent(new BlockComponent(type, new Vector3i(blockComponent.getPosition())));
BeforeEntityCreated newEntityEvent = new BeforeEntityCreated(newPrefab, newEntityBuilder.iterateComponents());
blockEntity.send(newEntityEvent);
for (Component comp : newEntityEvent.getResultComponents()) {