Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-12 14:10:07 +01:00
Added pattern support to //overlay.
Dieser Commit ist enthalten in:
Ursprung
fa59eb29b5
Commit
a7b457c35c
@ -1124,6 +1124,48 @@ public class EditSession {
|
||||
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.
|
||||
*
|
||||
|
@ -106,10 +106,16 @@ public class RegionCommands {
|
||||
LocalSession session, LocalPlayer player, EditSession editSession)
|
||||
throws WorldEditException {
|
||||
|
||||
BaseBlock block = we.getBlock(player, args.getString(0));
|
||||
Pattern pat = we.getBlockPattern(player, args.getString(0));
|
||||
|
||||
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.");
|
||||
}
|
||||
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren