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:
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.BlockTypeMask;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -65,21 +66,35 @@ public class Naturalizer implements LayerFunction {
|
|||||||
return mask.test(position);
|
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
|
@Override
|
||||||
public boolean apply(BlockVector3 position, int depth) throws WorldEditException {
|
public boolean apply(BlockVector3 position, int depth) throws WorldEditException {
|
||||||
if (mask.test(position)) {
|
if (mask.test(position)) {
|
||||||
affected++;
|
if (naturalize(position, depth)) {
|
||||||
switch (depth) {
|
++affected;
|
||||||
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());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren