mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-01-22 15:10:05 +00:00
Added pattern support to //overlay.
This commit is contained in:
parent
fa59eb29b5
commit
a7b457c35c
@ -1124,6 +1124,48 @@ public class EditSession {
|
|||||||
return affected;
|
return affected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overlays a layer of blocks over a cuboid area.
|
||||||
|
*
|
||||||
|
* @param region
|
||||||
|
* @param pattern
|
||||||
|
* @return number of blocks affected
|
||||||
|
* @throws MaxChangedBlocksException
|
||||||
|
*/
|
||||||
|
public int overlayCuboidBlocks(Region region, Pattern pattern)
|
||||||
|
throws MaxChangedBlocksException {
|
||||||
|
Vector min = region.getMinimumPoint();
|
||||||
|
Vector max = region.getMaximumPoint();
|
||||||
|
|
||||||
|
int upperY = Math.min(127, max.getBlockY() + 1);
|
||||||
|
int lowerY = Math.max(0, min.getBlockY() - 1);
|
||||||
|
|
||||||
|
int affected = 0;
|
||||||
|
|
||||||
|
int minX = min.getBlockX();
|
||||||
|
int minZ = min.getBlockZ();
|
||||||
|
int maxX = max.getBlockX();
|
||||||
|
int maxZ = max.getBlockZ();
|
||||||
|
|
||||||
|
for (int x = minX; x <= maxX; x++) {
|
||||||
|
for (int z = minZ; z <= maxZ; z++) {
|
||||||
|
for (int y = upperY; y >= lowerY; y--) {
|
||||||
|
Vector above = new Vector(x, y + 1, z);
|
||||||
|
|
||||||
|
if (y + 1 <= 127 && !getBlock(new Vector(x, y, z)).isAir()
|
||||||
|
&& getBlock(above).isAir()) {
|
||||||
|
if (setBlock(above, pattern.next(above))) {
|
||||||
|
affected++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return affected;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stack a cuboid region.
|
* Stack a cuboid region.
|
||||||
*
|
*
|
||||||
|
@ -106,10 +106,16 @@ public class RegionCommands {
|
|||||||
LocalSession session, LocalPlayer player, EditSession editSession)
|
LocalSession session, LocalPlayer player, EditSession editSession)
|
||||||
throws WorldEditException {
|
throws WorldEditException {
|
||||||
|
|
||||||
BaseBlock block = we.getBlock(player, args.getString(0));
|
Pattern pat = we.getBlockPattern(player, args.getString(0));
|
||||||
|
|
||||||
Region region = session.getRegion();
|
Region region = session.getRegion();
|
||||||
int affected = editSession.overlayCuboidBlocks(region, block);
|
int affected = 0;
|
||||||
|
if (pat instanceof SingleBlockPattern) {
|
||||||
|
affected = editSession.overlayCuboidBlocks(region,
|
||||||
|
((SingleBlockPattern)pat).getBlock());
|
||||||
|
} else {
|
||||||
|
affected = editSession.overlayCuboidBlocks(region, pat);
|
||||||
|
}
|
||||||
player.print(affected + " block(s) have been overlayed.");
|
player.print(affected + " block(s) have been overlayed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user