@Override public BlockFamily deserialize(EntityData.Value value) { if (value.getStringCount() > 0) { return blockManager.getBlockFamily(value.getString(0)); } return null; }
@Override public List<BlockFamily> deserializeCollection(EntityData.Value value) { List<BlockFamily> result = Lists.newArrayListWithCapacity(value.getStringCount()); for (String item : value.getStringList()) { result.add(blockManager.getBlockFamily(item)); } return result; }
@Override public T deserialize(EntityData.Value value) { if (value.getStringCount() > 0) { Asset asset = Assets.resolve(type, value.getString(0)); if (asset != null && assetClass.isAssignableFrom(asset.getClass())) { return assetClass.cast(asset); } } return null; }
@Override public List<T> deserializeCollection(EntityData.Value value) { List<T> result = Lists.newArrayListWithCapacity(value.getStringCount()); for (String item : value.getStringList()) { Asset asset = Assets.resolve(type, item); if (asset != null && assetClass.isAssignableFrom(asset.getClass())) { result.add(assetClass.cast(asset)); } } return result; }
public EntityData.Value serialize(Vector3i value) { return EntityData.Value.newBuilder() .addInteger(value.x) .addInteger(value.y) .addInteger(value.z) .build(); }
@Override public EntityData.Value serialize(T value) { if (value != null && value.getURI() != null) { return EntityData.Value.newBuilder().addString(value.getURI().toSimpleString()).build(); } return null; }
@Override public EntityData.Value serializeCollection(Iterable<T> value) { EntityData.Value.Builder result = EntityData.Value.newBuilder(); for (T item : value) { result.addString(item.getURI().toSimpleString()); } return result.build(); }
public Vector3i deserialize(EntityData.Value value) { if (value.getIntegerCount() > 2) { return new Vector3i(value.getInteger(0), value.getInteger(1), value.getInteger(2)); } return null; }
@Override public EntityData.Value serialize(BlockFamily value) { return EntityData.Value.newBuilder().addString(value.getURI().toString()).build(); }
public Vector2f deserialize(EntityData.Value value) { if (value.getFloatCount() > 1) { return new Vector2f(value.getFloat(0), value.getFloat(1)); } return null; }
public EntityData.Value serialize(Vector2f value) { return EntityData.Value.newBuilder().addFloat(value.x).addFloat(value.y).build(); }