use of org.terasology.persistence.typeHandling.PersistedDataArray in project Terasology by MovingBlocks.
the class EntityRefTypeHandler method deserializeCollection.
@Override
public List<EntityRef> deserializeCollection(PersistedData data, DeserializationContext context) {
PersistedDataArray array = data.getAsArray();
List<EntityRef> result = Lists.newArrayListWithCapacity(array.size());
addEntitiesFromLongArray(result, array);
return result;
}
use of org.terasology.persistence.typeHandling.PersistedDataArray in project Terasology by MovingBlocks.
the class NetEntityRefTypeHandler method deserialize.
@Override
public EntityRef deserialize(PersistedData data, DeserializationContext context) {
if (data.isArray()) {
PersistedDataArray array = data.getAsArray();
if (array.isNumberArray() && array.size() == 3) {
TIntList items = data.getAsArray().getAsIntegerArray();
Vector3i pos = new Vector3i(items.get(0), items.get(1), items.get(2));
return blockEntityRegistry.getBlockEntityAt(pos);
}
}
if (data.isNumber()) {
return networkSystem.getEntity(data.getAsInteger());
}
return EntityRef.NULL;
}
use of org.terasology.persistence.typeHandling.PersistedDataArray in project Terasology by MovingBlocks.
the class EnumTypeHandler method deserializeCollection.
@Override
public List<T> deserializeCollection(PersistedData data, DeserializationContext context) {
if (data.isArray()) {
PersistedDataArray array = data.getAsArray();
List<T> result = Lists.newArrayListWithCapacity(array.size());
for (PersistedData item : array) {
result.add(deserialize(item, context));
}
return result;
}
return Lists.newArrayList();
}
Aggregations