geforkt von Mirrors/FastAsyncWorldEdit
Switched //faces and //walls to use visitors.
Dieser Commit ist enthalten in:
Ursprung
6c1ff02df5
Commit
f509a3128e
@ -1006,251 +1006,104 @@ public class EditSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make faces of the region (as if it was a cuboid if it's not).
|
* Make the faces of the given region as if it was a {@link CuboidRegion}.
|
||||||
*
|
*
|
||||||
* @param region
|
* @param region the region
|
||||||
* @param block
|
* @param block the block to place
|
||||||
* @return number of blocks affected
|
* @return number of blocks affected
|
||||||
* @throws MaxChangedBlocksException
|
* @throws MaxChangedBlocksException
|
||||||
*/
|
*/
|
||||||
public int makeCuboidFaces(Region region, BaseBlock block)
|
public int makeCuboidFaces(Region region, BaseBlock block) throws MaxChangedBlocksException {
|
||||||
throws MaxChangedBlocksException {
|
return makeCuboidFaces(region, new SingleBlockPattern(block));
|
||||||
int affected = 0;
|
|
||||||
|
|
||||||
Vector min = region.getMinimumPoint();
|
|
||||||
Vector max = region.getMaximumPoint();
|
|
||||||
|
|
||||||
int minX = min.getBlockX();
|
|
||||||
int minY = min.getBlockY();
|
|
||||||
int minZ = min.getBlockZ();
|
|
||||||
int maxX = max.getBlockX();
|
|
||||||
int maxY = max.getBlockY();
|
|
||||||
int maxZ = max.getBlockZ();
|
|
||||||
|
|
||||||
for (int x = minX; x <= maxX; ++x) {
|
|
||||||
for (int y = minY; y <= maxY; ++y) {
|
|
||||||
if (setBlock(new Vector(x, y, minZ), block)) {
|
|
||||||
++affected;
|
|
||||||
}
|
|
||||||
if (setBlock(new Vector(x, y, maxZ), block)) {
|
|
||||||
++affected;
|
|
||||||
}
|
|
||||||
++affected;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int y = minY; y <= maxY; ++y) {
|
|
||||||
for (int z = minZ; z <= maxZ; ++z) {
|
|
||||||
if (setBlock(new Vector(minX, y, z), block)) {
|
|
||||||
++affected;
|
|
||||||
}
|
|
||||||
if (setBlock(new Vector(maxX, y, z), block)) {
|
|
||||||
++affected;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int z = minZ; z <= maxZ; ++z) {
|
|
||||||
for (int x = minX; x <= maxX; ++x) {
|
|
||||||
if (setBlock(new Vector(x, minY, z), block)) {
|
|
||||||
++affected;
|
|
||||||
}
|
|
||||||
if (setBlock(new Vector(x, maxY, z), block)) {
|
|
||||||
++affected;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return affected;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make faces of the region (as if it was a cuboid if it's not).
|
* Make the faces of the given region as if it was a {@link CuboidRegion}.
|
||||||
*
|
*
|
||||||
* @param region
|
* @param region the region
|
||||||
* @param pattern
|
* @param pattern the pattern to place
|
||||||
* @return number of blocks affected
|
* @return number of blocks affected
|
||||||
* @throws MaxChangedBlocksException
|
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||||
*/
|
*/
|
||||||
public int makeCuboidFaces(Region region, Pattern pattern)
|
public int makeCuboidFaces(Region region, Pattern pattern) throws MaxChangedBlocksException {
|
||||||
throws MaxChangedBlocksException {
|
checkNotNull(region);
|
||||||
int affected = 0;
|
checkNotNull(pattern);
|
||||||
|
|
||||||
Vector min = region.getMinimumPoint();
|
CuboidRegion cuboid = CuboidRegion.makeCuboid(region);
|
||||||
Vector max = region.getMaximumPoint();
|
Region faces = cuboid.getFaces();
|
||||||
|
return setBlocks(faces, pattern);
|
||||||
int minX = min.getBlockX();
|
|
||||||
int minY = min.getBlockY();
|
|
||||||
int minZ = min.getBlockZ();
|
|
||||||
int maxX = max.getBlockX();
|
|
||||||
int maxY = max.getBlockY();
|
|
||||||
int maxZ = max.getBlockZ();
|
|
||||||
|
|
||||||
for (int x = minX; x <= maxX; ++x) {
|
|
||||||
for (int y = minY; y <= maxY; ++y) {
|
|
||||||
Vector minV = new Vector(x, y, minZ);
|
|
||||||
if (setBlock(minV, pattern.next(minV))) {
|
|
||||||
++affected;
|
|
||||||
}
|
|
||||||
Vector maxV = new Vector(x, y, maxZ);
|
|
||||||
if (setBlock(maxV, pattern.next(maxV))) {
|
|
||||||
++affected;
|
|
||||||
}
|
|
||||||
++affected;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int y = minY; y <= maxY; ++y) {
|
|
||||||
for (int z = minZ; z <= maxZ; ++z) {
|
|
||||||
Vector minV = new Vector(minX, y, z);
|
|
||||||
if (setBlock(minV, pattern.next(minV))) {
|
|
||||||
++affected;
|
|
||||||
}
|
|
||||||
Vector maxV = new Vector(maxX, y, z);
|
|
||||||
if (setBlock(maxV, pattern.next(maxV))) {
|
|
||||||
++affected;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int z = minZ; z <= maxZ; ++z) {
|
|
||||||
for (int x = minX; x <= maxX; ++x) {
|
|
||||||
Vector minV = new Vector(x, minY, z);
|
|
||||||
if (setBlock(minV, pattern.next(minV))) {
|
|
||||||
++affected;
|
|
||||||
}
|
|
||||||
Vector maxV = new Vector(x, maxY, z);
|
|
||||||
if (setBlock(maxV, pattern.next(maxV))) {
|
|
||||||
++affected;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return affected;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make faces of the region
|
* Make the faces of the given region. The method by which the faces are found
|
||||||
|
* may be inefficient, because there may not be an efficient implementation supported
|
||||||
|
* for that specific shape.
|
||||||
*
|
*
|
||||||
* @param region
|
* @param region the region
|
||||||
* @param pattern
|
* @param pattern the pattern to place
|
||||||
* @return number of blocks affected
|
* @return number of blocks affected
|
||||||
* @throws MaxChangedBlocksException
|
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||||
*/
|
*/
|
||||||
public int makeFaces(final Region region, Pattern pattern) throws MaxChangedBlocksException {
|
public int makeFaces(final Region region, Pattern pattern) throws MaxChangedBlocksException {
|
||||||
|
checkNotNull(region);
|
||||||
|
checkNotNull(pattern);
|
||||||
|
|
||||||
|
if (region instanceof CuboidRegion) {
|
||||||
|
return makeCuboidFaces(region, pattern);
|
||||||
|
} else {
|
||||||
return new RegionShape(region).generate(this, pattern, true);
|
return new RegionShape(region).generate(this, pattern, true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make walls of the region (as if it was a cuboid if it's not).
|
* Make the walls (all faces but those parallel to the X-Z plane) of the given region
|
||||||
|
* as if it was a {@link CuboidRegion}.
|
||||||
*
|
*
|
||||||
* @param region
|
* @param region the region
|
||||||
* @param block
|
* @param block the block to place
|
||||||
* @return number of blocks affected
|
* @return number of blocks affected
|
||||||
* @throws MaxChangedBlocksException
|
* @throws MaxChangedBlocksException
|
||||||
*/
|
*/
|
||||||
public int makeCuboidWalls(Region region, BaseBlock block)
|
public int makeCuboidWalls(Region region, BaseBlock block) throws MaxChangedBlocksException {
|
||||||
throws MaxChangedBlocksException {
|
return makeCuboidWalls(region, new SingleBlockPattern(block));
|
||||||
int affected = 0;
|
|
||||||
|
|
||||||
Vector min = region.getMinimumPoint();
|
|
||||||
Vector max = region.getMaximumPoint();
|
|
||||||
|
|
||||||
int minX = min.getBlockX();
|
|
||||||
int minY = min.getBlockY();
|
|
||||||
int minZ = min.getBlockZ();
|
|
||||||
int maxX = max.getBlockX();
|
|
||||||
int maxY = max.getBlockY();
|
|
||||||
int maxZ = max.getBlockZ();
|
|
||||||
|
|
||||||
for (int x = minX; x <= maxX; ++x) {
|
|
||||||
for (int y = minY; y <= maxY; ++y) {
|
|
||||||
if (setBlock(new Vector(x, y, minZ), block)) {
|
|
||||||
++affected;
|
|
||||||
}
|
|
||||||
if (setBlock(new Vector(x, y, maxZ), block)) {
|
|
||||||
++affected;
|
|
||||||
}
|
|
||||||
++affected;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int y = minY; y <= maxY; ++y) {
|
|
||||||
for (int z = minZ; z <= maxZ; ++z) {
|
|
||||||
if (setBlock(new Vector(minX, y, z), block)) {
|
|
||||||
++affected;
|
|
||||||
}
|
|
||||||
if (setBlock(new Vector(maxX, y, z), block)) {
|
|
||||||
++affected;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return affected;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make walls of the region (as if it was a cuboid if it's not).
|
* Make the walls (all faces but those parallel to the X-Z plane) of the given region
|
||||||
|
* as if it was a {@link CuboidRegion}.
|
||||||
*
|
*
|
||||||
* @param region
|
* @param region the region
|
||||||
* @param pattern
|
* @param pattern the pattern to place
|
||||||
* @return number of blocks affected
|
* @return number of blocks affected
|
||||||
* @throws MaxChangedBlocksException
|
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||||
*/
|
*/
|
||||||
public int makeCuboidWalls(Region region, Pattern pattern)
|
public int makeCuboidWalls(Region region, Pattern pattern) throws MaxChangedBlocksException {
|
||||||
throws MaxChangedBlocksException {
|
checkNotNull(region);
|
||||||
int affected = 0;
|
checkNotNull(pattern);
|
||||||
|
|
||||||
Vector min = region.getMinimumPoint();
|
CuboidRegion cuboid = CuboidRegion.makeCuboid(region);
|
||||||
Vector max = region.getMaximumPoint();
|
Region faces = cuboid.getWalls();
|
||||||
|
return setBlocks(faces, pattern);
|
||||||
int minX = min.getBlockX();
|
|
||||||
int minY = min.getBlockY();
|
|
||||||
int minZ = min.getBlockZ();
|
|
||||||
int maxX = max.getBlockX();
|
|
||||||
int maxY = max.getBlockY();
|
|
||||||
int maxZ = max.getBlockZ();
|
|
||||||
|
|
||||||
for (int x = minX; x <= maxX; ++x) {
|
|
||||||
for (int y = minY; y <= maxY; ++y) {
|
|
||||||
Vector minV = new Vector(x, y, minZ);
|
|
||||||
if (setBlock(minV, pattern.next(minV))) {
|
|
||||||
++affected;
|
|
||||||
}
|
|
||||||
Vector maxV = new Vector(x, y, maxZ);
|
|
||||||
if (setBlock(maxV, pattern.next(maxV))) {
|
|
||||||
++affected;
|
|
||||||
}
|
|
||||||
++affected;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int y = minY; y <= maxY; ++y) {
|
|
||||||
for (int z = minZ; z <= maxZ; ++z) {
|
|
||||||
Vector minV = new Vector(minX, y, z);
|
|
||||||
if (setBlock(minV, pattern.next(minV))) {
|
|
||||||
++affected;
|
|
||||||
}
|
|
||||||
Vector maxV = new Vector(maxX, y, z);
|
|
||||||
if (setBlock(maxV, pattern.next(maxV))) {
|
|
||||||
++affected;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return affected;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make walls of the region
|
* Make the walls of the given region. The method by which the walls are found
|
||||||
|
* may be inefficient, because there may not be an efficient implementation supported
|
||||||
|
* for that specific shape.
|
||||||
*
|
*
|
||||||
* @param region
|
* @param region the region
|
||||||
* @param pattern
|
* @param pattern the pattern to place
|
||||||
* @return number of blocks affected
|
* @return number of blocks affected
|
||||||
* @throws MaxChangedBlocksException
|
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||||
*/
|
*/
|
||||||
public int makeWalls(final Region region, Pattern pattern) throws MaxChangedBlocksException {
|
public int makeWalls(final Region region, Pattern pattern) throws MaxChangedBlocksException {
|
||||||
|
checkNotNull(region);
|
||||||
|
checkNotNull(pattern);
|
||||||
|
|
||||||
|
if (region instanceof CuboidRegion) {
|
||||||
|
return makeCuboidWalls(region, pattern);
|
||||||
|
} else {
|
||||||
final int minY = region.getMinimumPoint().getBlockY();
|
final int minY = region.getMinimumPoint().getBlockY();
|
||||||
final int maxY = region.getMaximumPoint().getBlockY();
|
final int maxY = region.getMaximumPoint().getBlockY();
|
||||||
final ArbitraryShape shape = new RegionShape(region) {
|
final ArbitraryShape shape = new RegionShape(region) {
|
||||||
@ -1266,6 +1119,7 @@ public class EditSession {
|
|||||||
};
|
};
|
||||||
return shape.generate(this, pattern, true);
|
return shape.generate(this, pattern, true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overlays a layer of blocks over a cuboid area.
|
* Overlays a layer of blocks over a cuboid area.
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren