private void writeComponentTypeTable(EntityData.World.Builder world) {
   for (ComponentMetadata<?> componentMetadata : componentLibrary) {
     int index = componentIdTable.size();
     componentIdTable.put(index, componentMetadata.getType());
     world.addComponentClass(ComponentUtil.getComponentClassName(componentMetadata.getType()));
   }
 }
  @Override
  public EntityData.World serializeWorld() {
    final EntityData.World.Builder world = EntityData.World.newBuilder();
    writeIdInfo(world);

    if (isUsingLookupTables()) {
      writeComponentTypeTable(world);
    }

    for (Prefab prefab : prefabManager.listPrefabs()) {
      world.addPrefab(serializePrefab(prefab));
    }

    for (EntityRef entity : entityManager.iteratorEntities()) {
      world.addEntity(serializeEntity(entity));
    }
    return world.build();
  }
 private void writeIdInfo(final EntityData.World.Builder world) {
   world.setNextEntityId(entityManager.getNextId());
   entityManager
       .getFreedIds()
       .forEach(
           new TIntProcedure() {
             public boolean execute(int i) {
               world.addFreedEntityId(i);
               return true;
             }
           });
 }