use of com.sk89q.worldedit.util.Location in project FastAsyncWorldEdit by IntellectualSites.
the class ErodeBrush method erosion.
public void erosion(final EditSession es, int erodeFaces, int erodeRecursion, int fillFaces, int fillRecursion, BlockVector3 target, double size) {
int brushSize = (int) size;
int brushSizeSquared = (int) (size * size);
Location min = new Location(es.getWorld(), target.toVector3().subtract(size, size, size));
Location max = new Location(es.getWorld(), target.toVector3().add(size, size, size));
Region region = new CuboidRegion(es.getWorld(), min.toBlockPoint(), max.toBlockPoint());
Clipboard buffer1 = new CPUOptimizedClipboard(region);
Clipboard buffer2 = new CPUOptimizedClipboard(region);
final int bx = target.getBlockX();
final int by = target.getBlockY();
final int bz = target.getBlockZ();
for (int x = -brushSize, relx = 0; x <= brushSize; x++, relx++) {
int x0 = x + bx;
for (int y = -brushSize, rely = 0; y <= brushSize; y++, rely++) {
int y0 = y + by;
for (int z = -brushSize, relz = 0; z <= brushSize; z++, relz++) {
int z0 = z + bz;
BlockState state = es.getBlock(x0, y0, z0);
buffer1.setBlock(relx, rely, relz, state);
buffer2.setBlock(relx, rely, relz, state);
}
}
}
int swap = 0;
for (int i = 0; i < erodeRecursion; ++i) {
erosionIteration(brushSize, brushSizeSquared, erodeFaces, swap % 2 == 0 ? buffer1 : buffer2, swap % 2 == 1 ? buffer1 : buffer2);
swap++;
}
for (int i = 0; i < fillRecursion; ++i) {
fillIteration(brushSize, brushSizeSquared, fillFaces, swap % 2 == 0 ? buffer1 : buffer2, swap % 2 == 1 ? buffer1 : buffer2);
swap++;
}
Clipboard finalBuffer = swap % 2 == 0 ? buffer1 : buffer2;
for (BlockVector3 pos : finalBuffer) {
BlockState block = pos.getBlock(finalBuffer);
es.setBlock(pos.getX() + bx - brushSize, pos.getY() + by - brushSize, pos.getZ() + bz - brushSize, block);
}
}
use of com.sk89q.worldedit.util.Location in project FastAsyncWorldEdit by IntellectualSites.
the class AbstractPlayerActor method getCardinalDirection.
// FAWE end
@Override
public Direction getCardinalDirection(int yawOffset) {
final Location location = getLocation();
if (location.getPitch() > 67.5) {
return Direction.DOWN;
}
if (location.getPitch() < -67.5) {
return Direction.UP;
}
// From hey0's code
// let's use real yaw now
double rot = (location.getYaw() + yawOffset) % 360;
if (rot < 0) {
rot += 360.0;
}
return getDirection(rot);
}
use of com.sk89q.worldedit.util.Location in project FastAsyncWorldEdit by IntellectualSites.
the class AbstractPlayerActor method ascendUpwards.
@Override
public boolean ascendUpwards(int distance, boolean alwaysGlass) {
final World world = getWorld();
final Location pos = getBlockLocation();
final int x = pos.getBlockX();
final int initialY = Math.max(world.getMinY(), pos.getBlockY());
int y = Math.max(world.getMinY(), pos.getBlockY() + 1);
final int z = pos.getBlockZ();
final int maxY = Math.min(world.getMaxY() + 1, initialY + distance);
// FAWE start - mutable
MutableBlockVector3 mutable = new MutableBlockVector3(x, y, z);
while (y <= world.getMaxY() + 2) {
// FAWE start - mutable
if (world.getBlock(mutable.mutY(y)).getBlockType().getMaterial().isMovementBlocker()) {
// Hit something
break;
} else if (y > maxY + 1) {
break;
} else if (y == maxY + 1) {
floatAt(x, y - 1, z, alwaysGlass);
return true;
}
++y;
}
return false;
}
use of com.sk89q.worldedit.util.Location in project FastAsyncWorldEdit by IntellectualSites.
the class AbstractPlayerActor method descendLevel.
@Override
public boolean descendLevel() {
final World world = getWorld();
final Location pos = getBlockLocation();
final int x = pos.getBlockX();
int y = Math.max(world.getMinY(), pos.getBlockY() - 1);
final int z = pos.getBlockZ();
int yLessSearchHeight = y - WorldEdit.getInstance().getConfiguration().defaultVerticalHeight;
int minY = Math.min(world.getMinY() + 1, yLessSearchHeight);
// FAWE start - mutable
MutableBlockVector3 mutable = new MutableBlockVector3(x, y, z);
while (y >= minY) {
// FAWE start - mutable
if (isLocationGoodForStanding(mutable.mutY(y)) && // FAWE end
trySetPosition(Vector3.at(x + 0.5, y, z + 0.5))) {
return true;
}
--y;
}
return false;
}
use of com.sk89q.worldedit.util.Location in project FastAsyncWorldEdit by IntellectualSites.
the class AbstractPlayerActor method ascendToCeiling.
@Override
public boolean ascendToCeiling(int clearance, boolean alwaysGlass) {
World world = getWorld();
Location pos = getBlockLocation();
int x = pos.getBlockX();
int initialY = Math.max(world.getMinY(), pos.getBlockY());
int y = Math.max(world.getMinY(), pos.getBlockY() + 2);
int z = pos.getBlockZ();
// FAWE start - mutable
MutableBlockVector3 mutable = new MutableBlockVector3(x, y, z);
// No free space above
if (!world.getBlock(mutable).getBlockType().getMaterial().isAir()) {
// FAWE end
return false;
}
int yPlusSearchHeight = y + WorldEdit.getInstance().getConfiguration().defaultVerticalHeight;
int maxY = Math.min(world.getMaxY(), yPlusSearchHeight);
while (y <= maxY) {
// FAWE start - mutable
if (world.getBlock(mutable.mutY(y)).getBlockType().getMaterial().isMovementBlocker()) {
// FAWE end
int platformY = Math.max(initialY, y - 3 - clearance);
if (platformY < initialY) {
// if ==, they already have the given clearance, if <, clearance is too large
return false;
} else if (platformY == initialY) {
return false;
}
floatAt(x, platformY + 1, z, alwaysGlass);
return true;
}
++y;
}
return false;
}
Aggregations