Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-03 01:50: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:
Ursprung
f89bc3a648
Commit
026bfeed08
@ -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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(BlockVector3 position, int depth) throws WorldEditException {
|
||||
if (mask.test(position)) {
|
||||
affected++;
|
||||
private BlockState getTargetBlock(int depth) {
|
||||
switch (depth) {
|
||||
case 0:
|
||||
editSession.setBlock(position, BlockTypes.GRASS_BLOCK.getDefaultState());
|
||||
break;
|
||||
return BlockTypes.GRASS_BLOCK.getDefaultState();
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
editSession.setBlock(position, BlockTypes.DIRT.getDefaultState());
|
||||
break;
|
||||
return BlockTypes.DIRT.getDefaultState();
|
||||
default:
|
||||
editSession.setBlock(position, BlockTypes.STONE.getDefaultState());
|
||||
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)) {
|
||||
if (naturalize(position, depth)) {
|
||||
++affected;
|
||||
}
|
||||
}
|
||||
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren