Merge boy0001/FastAsyncWorldEdit

This commit is contained in:
Jesse Boyd
2018-09-14 02:42:55 +10:00
parent e3172e08b8
commit 8ed67f66ad
9 changed files with 109 additions and 47 deletions

View File

@ -23,7 +23,7 @@ public class Settings extends Config {
@Final
public String PLATFORM; // These values are set from FAWE before loading
@Comment({"Options: de, ru, tr",
@Comment({"Options: de, es, fr, nl, ru, tr",
"Create a PR to contribute a translation: https://github.com/boy0001/FastAsyncWorldedit/new/master/core/src/main/resources",})
public String LANGUAGE = "";
@Comment({"Enable or disable automatic updates",

View File

@ -1785,21 +1785,16 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
if (region instanceof CuboidRegion) {
return this.makeCuboidWalls(region, pattern);
} else {
final int minY = region.getMinimumPoint().getBlockY();
final int maxY = region.getMaximumPoint().getBlockY();
final ArbitraryShape shape = new RegionShape(region) {
@Override
public BlockStateHolder getMaterial(final int x, final int y, final int z, final BlockStateHolder defaultMaterial) {
if ((y > maxY) || (y < minY)) {
// Put holes into the floor and ceiling by telling ArbitraryShape that the shape goes on outside the region
return defaultMaterial;
}
return super.getMaterial(x, y, z, defaultMaterial);
for (BlockVector position : region) {
int x = position.getBlockX();
int y = position.getBlockY();
int z = position.getBlockZ();
if (!region.contains(x, z + 1) || !region.contains(x, z - 1) || !region.contains(x + 1, z) || !region.contains(x - 1, z)) {
setBlock(position, pattern);
}
};
return shape.generate(this, pattern, true);
}
}
return changes;
}
/**

View File

@ -293,6 +293,54 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
recalculate();
}
@Override
public boolean contains(int targetX, int targetZ) {
boolean inside = false;
int npoints = points.size();
int xNew, zNew;
int xOld, zOld;
int x1, z1;
int x2, z2;
long crossproduct;
int i;
xOld = points.get(npoints - 1).getBlockX();
zOld = points.get(npoints - 1).getBlockZ();
for (i = 0; i < npoints; ++i) {
xNew = points.get(i).getBlockX();
zNew = points.get(i).getBlockZ();
//Check for corner
if (xNew == targetX && zNew == targetZ) {
return true;
}
if (xNew > xOld) {
x1 = xOld;
x2 = xNew;
z1 = zOld;
z2 = zNew;
} else {
x1 = xNew;
x2 = xOld;
z1 = zNew;
z2 = zOld;
}
if (x1 <= targetX && targetX <= x2) {
crossproduct = ((long) targetZ - (long) z1) * (long) (x2 - x1)
- ((long) z2 - (long) z1) * (long) (targetX - x1);
if (crossproduct == 0) {
if ((z1 <= targetZ) == (targetZ <= z2)) return true; //on edge
} else if (crossproduct < 0 && (x1 != targetX)) {
inside = !inside;
}
}
xOld = xNew;
zOld = zNew;
}
return inside;
}
@Override
public boolean contains(Vector position) {
return contains(points, minY, maxY, position);

View File

@ -64,7 +64,7 @@ public class FlatRegionIterator implements Iterator<Vector2D> {
}
private void forward() {
while (hasNext() && !region.contains(new Vector(nextX, y, nextZ))) {
while (hasNext() && !region.contains(nextX, y, nextZ)) {
forwardOne();
}
}

View File

@ -339,11 +339,6 @@ public class Location extends Vector {
@Override
public int hashCode() {
int result = extent.hashCode();
result = 31 * result + this.hashCode();
result = 31 * result + Float.floatToIntBits(this.pitch);
result = 31 * result + Float.floatToIntBits(this.yaw);
return result;
return super.hashCode();
}
}