if (oldSelector instanceof Polygonal2DRegionSelector) {
final Polygonal2DRegionSelector polygonal2DRegionSelector = (Polygonal2DRegionSelector) oldSelector;
pos1 = polygonal2DRegionSelector.pos1;
region = new Polygonal2DRegion(polygonal2DRegionSelector.region);
} else {
final Region oldRegion;
try {
oldRegion = oldSelector.getRegion();
} catch (IncompleteRegionException e) {
return;
}
final int minY = oldRegion.getMinimumPoint().getBlockY();
final int maxY = oldRegion.getMaximumPoint().getBlockY();
List<BlockVector2D> points = oldRegion.polygonize(Integer.MAX_VALUE);
pos1 = points.get(0).toVector(minY).toBlockVector();
region = new Polygonal2DRegion(oldRegion.getWorld(), points, minY, maxY);
}
}