The /green command no longer affects permadirt and podzol.

This behaviour can be overridden with -f.
This commit is contained in:
TomyLobo 2013-12-29 18:28:42 +01:00
parent 85035a2a24
commit 61905527f8
2 changed files with 24 additions and 2 deletions

View File

@ -2504,9 +2504,25 @@ public class EditSession {
* @param radius * @param radius
* @return number of blocks affected * @return number of blocks affected
* @throws MaxChangedBlocksException * @throws MaxChangedBlocksException
* @deprecated Use {@link #green(Vector, double, boolean)}.
*/ */
@Deprecated
public int green(Vector pos, double radius) public int green(Vector pos, double radius)
throws MaxChangedBlocksException { throws MaxChangedBlocksException {
return green(pos, radius, true);
}
/**
* Green.
*
* @param pos
* @param radius
* @param onlyNormalDirt only affect normal dirt (data value 0)
* @return number of blocks affected
* @throws MaxChangedBlocksException
*/
public int green(Vector pos, double radius, boolean onlyNormalDirt)
throws MaxChangedBlocksException {
int affected = 0; int affected = 0;
final double radiusSq = radius * radius; final double radiusSq = radius * radius;
@ -2530,6 +2546,10 @@ public class EditSession {
switch (id) { switch (id) {
case BlockID.DIRT: case BlockID.DIRT:
if (onlyNormalDirt && data != 0) {
break loop;
}
if (setBlock(pt, grass)) { if (setBlock(pt, grass)) {
++affected; ++affected;
} }

View File

@ -316,6 +316,7 @@ public class UtilityCommands {
aliases = { "/green", "green" }, aliases = { "/green", "green" },
usage = "[radius]", usage = "[radius]",
desc = "Greens the area", desc = "Greens the area",
flags = "f",
min = 0, min = 0,
max = 1 max = 1
) )
@ -324,9 +325,10 @@ public class UtilityCommands {
public void green(CommandContext args, LocalSession session, LocalPlayer player, public void green(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException { EditSession editSession) throws WorldEditException {
double size = args.argsLength() > 0 ? Math.max(1, args.getDouble(0)) : 10; final double size = args.argsLength() > 0 ? Math.max(1, args.getDouble(0)) : 10;
final boolean onlyNormalDirt = !args.hasFlag('f');
int affected = editSession.green(session.getPlacementPosition(player), size); final int affected = editSession.green(session.getPlacementPosition(player), size, onlyNormalDirt);
player.print(affected + " surfaces greened."); player.print(affected + " surfaces greened.");
} }