use of org.terasology.engine.world.block.BlockArea in project Terasology by MovingBlocks.
the class BlockAreaTypeHandler method deserialize.
@Override
public Optional<BlockArea> deserialize(PersistedData data) {
if (!data.isNull() && data.isValueMap()) {
PersistedDataMap map = data.getAsValueMap();
PersistedDataArray minDataArr = map.get(MIN_FIELD).getAsArray();
TIntList minArr = minDataArr.getAsIntegerArray();
if (map.has(SIZE_FIELD)) {
PersistedDataArray sizedataArray = map.get(SIZE_FIELD).getAsArray();
TIntList sizeArr = sizedataArray.getAsIntegerArray();
return Optional.of(new BlockArea(minArr.get(0), minArr.get(1)).setSize(sizeArr.get(0), sizeArr.get(1)));
}
PersistedDataArray maxDataArr = map.get(MAX_FIELD).getAsArray();
TIntList maxArr = maxDataArr.getAsIntegerArray();
return Optional.of(new BlockArea(minArr.get(0), minArr.get(1), maxArr.get(0), maxArr.get(1)));
}
return Optional.empty();
}
use of org.terasology.engine.world.block.BlockArea in project Terasology by MovingBlocks.
the class BlockAreaTypeHandlerTest method testGsonSerialization.
@Test
public void testGsonSerialization() throws IOException {
TestObject a = new TestObject();
a.b1 = new BlockArea(-1, -1, 0, 0);
a.b2 = new BlockArea(0, 0, 1, 1);
byte[] data = gsonSerializer.serialize(a, new TypeInfo<TestObject>() {
}).get();
TestObject o = gsonSerializer.deserialize(new TypeInfo<TestObject>() {
}, data).get();
assertEquals(new BlockArea(-1, -1, 0, 0), o.b1);
assertEquals(new BlockArea(0, 0, 1, 1), o.b2);
}
use of org.terasology.engine.world.block.BlockArea in project Terasology by MovingBlocks.
the class BlockAreacTypeHandler method deserialize.
@Override
public Optional<BlockAreac> deserialize(PersistedData data) {
if (!data.isNull() && data.isValueMap()) {
PersistedDataMap map = data.getAsValueMap();
PersistedDataArray minDataArr = map.get(MIN_FIELD).getAsArray();
TIntList minArr = minDataArr.getAsIntegerArray();
if (map.has(SIZE_FIELD)) {
PersistedDataArray sizedataArray = map.get(SIZE_FIELD).getAsArray();
TIntList sizeArr = sizedataArray.getAsIntegerArray();
return Optional.of(new BlockArea(minArr.get(0), minArr.get(1)).setSize(sizeArr.get(0), sizeArr.get(1)));
}
PersistedDataArray maxDataArr = map.get(MAX_FIELD).getAsArray();
TIntList maxArr = maxDataArr.getAsIntegerArray();
return Optional.of(new BlockArea(minArr.get(0), minArr.get(1), maxArr.get(0), maxArr.get(1)));
}
return Optional.empty();
}
use of org.terasology.engine.world.block.BlockArea in project Terasology by MovingBlocks.
the class SubSampledNoise method noise.
public float[] noise(BlockAreac area, float scale) {
BlockArea fullRegion = determineRequiredRegion(area);
float[] keyData = getKeyValues(fullRegion, scale);
float[] fullData = mapExpand(keyData, fullRegion);
return getSubset(fullData, fullRegion, area);
}
Aggregations