Add -p flag to //drain to allow kelp and watergrass to be removed.

properly fixed #464
Dieser Commit ist enthalten in:
dordsor21 2020-07-03 14:01:16 +01:00
Ursprung ea7897934f
Commit 2812841481
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 1E53E88969FFCF0B
2 geänderte Dateien mit 25 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -1623,10 +1623,30 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int drainArea(BlockVector3 origin, double radius, boolean waterlogged) throws MaxChangedBlocksException {
return drainArea(origin, radius, waterlogged, false);
}
/**
* Drain nearby pools of water or lava, optionally removed waterlogged states from blocks.
*
* @param origin the origin to drain from, which will search a 3x3 area
* @param radius the radius of the removal, where a value should be 0 or greater
* @param waterlogged true to make waterlogged blocks non-waterlogged as well
* @param plants true to remove underwater plants
* @return number of blocks affected
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int drainArea(BlockVector3 origin, double radius, boolean waterlogged, boolean plants) throws MaxChangedBlocksException {
checkNotNull(origin);
checkArgument(radius >= 0, "radius >= 0 required");
Mask liquidMask = new BlockTypeMask(this, BlockTypes.LAVA, BlockTypes.WATER);
Mask liquidMask;
if (plants) {
liquidMask = new BlockTypeMask(this, BlockTypes.LAVA, BlockTypes.WATER,
BlockTypes.KELP_PLANT, BlockTypes.KELP, BlockTypes.SEAGRASS, BlockTypes.TALL_SEAGRASS);
} else {
liquidMask = new BlockTypeMask(this, BlockTypes.LAVA, BlockTypes.WATER);
}
if (waterlogged) {
Map<String, String> stateMap = new HashMap<>();
stateMap.put("waterlogged", "true");

Datei anzeigen

@ -326,11 +326,13 @@ public class UtilityCommands {
@Arg(desc = "The radius to drain")
Expression radiusExp,
@Switch(name = 'w', desc = "Also un-waterlog blocks")
boolean waterlogged) throws WorldEditException {
boolean waterlogged,
@Switch(name = 'p', desc = "Also remove water plants")
boolean plants) throws WorldEditException {
double radius = radiusExp.evaluate();
radius = Math.max(0, radius);
we.checkMaxRadius(radius);
int affected = editSession.drainArea(session.getPlacementPosition(actor), radius, waterlogged);
int affected = editSession.drainArea(session.getPlacementPosition(actor), radius, waterlogged, plants);
actor.printInfo(TranslatableComponent.of("worldedit.drain.drained", TextComponent.of(affected)));
return affected;
}