mirror of
https://github.com/EngineHub/WorldEdit.git
synced 2024-12-27 05:00:08 +08:00
Added a /green command, which greens the surrounding landscape.
This commit is contained in:
parent
6c5d1236c7
commit
151b4c0fa1
@ -2045,6 +2045,51 @@ public int simulateSnow(Vector pos, double radius)
|
|||||||
return affected;
|
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.
|
* Set a block by chance.
|
||||||
*
|
*
|
||||||
|
@ -294,7 +294,26 @@ public static void thaw(CommandContext args, WorldEdit we,
|
|||||||
int affected = editSession.thaw(session.getPlacementPosition(player), size);
|
int affected = editSession.thaw(session.getPlacementPosition(player), size);
|
||||||
player.print(affected + " surfaces thawed.");
|
player.print(affected + " surfaces thawed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
aliases = {"green"},
|
||||||
|
usage = "[radius]",
|
||||||
|
desc = "Greens the area",
|
||||||
|
min = 0,
|
||||||
|
max = 1
|
||||||
|
)
|
||||||
|
@CommandPermissions({"worldedit.green"})
|
||||||
|
@Logging(PLACEMENT)
|
||||||
|
public static void green(CommandContext args, WorldEdit we,
|
||||||
|
LocalSession session, LocalPlayer player, EditSession editSession)
|
||||||
|
throws WorldEditException {
|
||||||
|
|
||||||
|
double size = args.argsLength() > 0 ? Math.max(1, args.getDouble(0)) : 10;
|
||||||
|
|
||||||
|
int affected = editSession.green(session.getPlacementPosition(player), size);
|
||||||
|
player.print(affected + " surfaces greened.");
|
||||||
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = {"ex", "ext", "extinguish"},
|
aliases = {"ex", "ext", "extinguish"},
|
||||||
usage = "[radius]",
|
usage = "[radius]",
|
||||||
|
Loading…
Reference in New Issue
Block a user