use of com.sk89q.worldedit.math.Vector2 in project FastAsyncWorldEdit by IntellectualSites.
the class YAMLNode method prepareSerialization.
/**
* Prepare a value for serialization, in case it's not a native type
* (and we don't want to serialize objects as YAML objects).
*
* @param value the value to serialize
* @return the new object
*/
private Object prepareSerialization(Object value) {
if (value instanceof Vector3) {
Map<String, Double> out = new LinkedHashMap<>();
Vector3 vec = (Vector3) value;
out.put("x", vec.getX());
out.put("y", vec.getY());
out.put("z", vec.getZ());
return out;
} else if (value instanceof BlockVector3) {
Map<String, Integer> out = new LinkedHashMap<>();
BlockVector3 vec = (BlockVector3) value;
out.put("x", vec.getBlockX());
out.put("y", vec.getBlockY());
out.put("z", vec.getBlockZ());
return out;
} else if (value instanceof Vector2) {
Map<String, Double> out = new LinkedHashMap<>();
Vector2 vec = (Vector2) value;
out.put("x", vec.getX());
out.put("z", vec.getZ());
return out;
} else if (value instanceof BlockVector2) {
Map<String, Integer> out = new LinkedHashMap<>();
BlockVector2 vec = (BlockVector2) value;
out.put("x", vec.getBlockX());
out.put("z", vec.getBlockZ());
return out;
}
return value;
}
use of com.sk89q.worldedit.math.Vector2 in project FastAsyncWorldEdit by IntellectualSites.
the class CylinderRegion method contract.
/**
* Contract the region.
*
* @param changes array/arguments with multiple related changes
*/
@Override
public void contract(BlockVector3... changes) throws RegionOperationException {
center = center.subtract(calculateDiff2D(changes));
Vector2 newRadius = radius.subtract(calculateChanges2D(changes).toVector2());
radius = Vector2.at(1.5, 1.5).getMaximum(newRadius);
this.radiusInverse = Vector2.ONE.divide(radius);
for (BlockVector3 change : changes) {
int height = maxY - minY;
int changeY = change.getBlockY();
if (changeY > 0) {
minY += Math.min(height, changeY);
} else {
maxY += Math.max(-height, changeY);
}
}
}
Aggregations