3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-25 02:20:07 +01:00

Improved usage of the naturalize command over large areas

This change fixes the block count report, and also makes
naturalize act more like a "//replace dirt grass" where
we only attempt block changes if the block is not already
what we're looking for.
Dieser Commit ist enthalten in:
Wyatt Childers 2019-06-10 23:24:53 -04:00 committet von wizjany
Ursprung f89bc3a648
Commit 026bfeed08

Datei anzeigen

@ -27,6 +27,7 @@ import com.sk89q.worldedit.function.LayerFunction;
import com.sk89q.worldedit.function.mask.BlockTypeMask;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypes;
/**
@ -65,21 +66,35 @@ public class Naturalizer implements LayerFunction {
return mask.test(position);
}
private BlockState getTargetBlock(int depth) {
switch (depth) {
case 0:
return BlockTypes.GRASS_BLOCK.getDefaultState();
case 1:
case 2:
case 3:
return BlockTypes.DIRT.getDefaultState();
default:
return BlockTypes.STONE.getDefaultState();
}
}
private boolean naturalize(BlockVector3 position, int depth) throws WorldEditException {
BlockState block = editSession.getBlock(position);
BlockState targetBlock = getTargetBlock(depth);
if (block.equalsFuzzy(targetBlock)) {
return false;
}
return editSession.setBlock(position, targetBlock);
}
@Override
public boolean apply(BlockVector3 position, int depth) throws WorldEditException {
if (mask.test(position)) {
affected++;
switch (depth) {
case 0:
editSession.setBlock(position, BlockTypes.GRASS_BLOCK.getDefaultState());
break;
case 1:
case 2:
case 3:
editSession.setBlock(position, BlockTypes.DIRT.getDefaultState());
break;
default:
editSession.setBlock(position, BlockTypes.STONE.getDefaultState());
if (naturalize(position, depth)) {
++affected;
}
}