mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-06 20:56:41 +00:00
Added a /green command, which greens the surrounding landscape.
This commit is contained in:
@ -2045,6 +2045,51 @@ public class EditSession {
|
||||
return affected;
|
||||
}
|
||||
|
||||
/**
|
||||
* Green.
|
||||
*
|
||||
* @param pos
|
||||
* @param radius
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException
|
||||
*/
|
||||
public int green(Vector pos, double radius)
|
||||
throws MaxChangedBlocksException {
|
||||
int affected = 0;
|
||||
double radiusSq = radius*radius;
|
||||
|
||||
int ox = pos.getBlockX();
|
||||
int oy = pos.getBlockY();
|
||||
int oz = pos.getBlockZ();
|
||||
|
||||
BaseBlock grass = new BaseBlock(BlockID.GRASS);
|
||||
|
||||
int ceilRadius = (int) Math.ceil(radius);
|
||||
for (int x = ox - ceilRadius; x <= ox + ceilRadius; ++x) {
|
||||
for (int z = oz - ceilRadius; z <= oz + ceilRadius; ++z) {
|
||||
if ((new Vector(x, oy, z)).distanceSq(pos) > radiusSq) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int y = 127; y >= 1; --y) {
|
||||
Vector pt = new Vector(x, y, z);
|
||||
int id = getBlockType(pt);
|
||||
|
||||
if (id == 0)
|
||||
continue;
|
||||
|
||||
if (id == BlockID.DIRT) {
|
||||
if (setBlock(pt, grass)) {
|
||||
++affected;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return affected;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a block by chance.
|
||||
*
|
||||
|
Reference in New Issue
Block a user