use of org.spongepowered.common.world.schematic.SpongeArchetypeVolume in project SpongeCommon by SpongePowered.
the class DefaultedExtent method createArchetypeVolume.
@Override
default ArchetypeVolume createArchetypeVolume(Vector3i min, Vector3i max, Vector3i origin) {
Vector3i tmin = min.min(max);
Vector3i tmax = max.max(min);
min = tmin;
max = tmax;
Extent volume = getExtentView(min, max);
BimapPalette palette = new BimapPalette();
volume.getBlockWorker().iterate((v, x, y, z) -> {
palette.getOrAssign(v.getBlock(x, y, z));
});
int ox = origin.getX();
int oy = origin.getY();
int oz = origin.getZ();
final MutableBlockVolume backing = new ArrayMutableBlockBuffer(min.sub(origin), max.sub(min).add(1, 1, 1));
Map<Vector3i, TileEntityArchetype> tiles = Maps.newHashMap();
volume.getBlockWorker().iterate((extent, x, y, z) -> {
BlockState state = extent.getBlock(x, y, z);
backing.setBlock(x - ox, y - oy, z - oz, state);
Optional<TileEntity> tile = extent.getTileEntity(x, y, z);
if (tile.isPresent()) {
tiles.put(new Vector3i(x - ox, y - oy, z - oz), tile.get().createArchetype());
}
});
return new SpongeArchetypeVolume(backing, tiles);
}
Aggregations