geforkt von Mirrors/FastAsyncWorldEdit
Added a block/pattern parameter to //hollow.
Also made a few variables final and optimized the thickness algo a bit.
Dieser Commit ist enthalten in:
Ursprung
633f6643a5
Commit
09a92fa76c
@ -2724,27 +2724,29 @@ public class EditSession {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hollows out the region (It's treated as if it was a cuboid if it's not).
|
* Hollows out the region (Semi-well-defined for non-cuboid selections).
|
||||||
|
*
|
||||||
|
* @param region the region to hollow out.
|
||||||
|
* @param thickness the thickness of the shell to leave (manhattan distance)
|
||||||
|
* @param patternThe block pattern to use
|
||||||
*
|
*
|
||||||
* @param region
|
|
||||||
* @param block
|
|
||||||
* @return number of blocks affected
|
* @return number of blocks affected
|
||||||
* @throws MaxChangedBlocksException
|
* @throws MaxChangedBlocksException
|
||||||
*/
|
*/
|
||||||
public int hollowOutRegion(Region region, int thickness) throws MaxChangedBlocksException {
|
public int hollowOutRegion(Region region, int thickness, Pattern pattern) throws MaxChangedBlocksException {
|
||||||
int affected = 0;
|
int affected = 0;
|
||||||
|
|
||||||
Set<BlockVector> outside = new HashSet<BlockVector>();
|
final Set<BlockVector> outside = new HashSet<BlockVector>();
|
||||||
|
|
||||||
Vector min = region.getMinimumPoint();
|
final Vector min = region.getMinimumPoint();
|
||||||
Vector max = region.getMaximumPoint();
|
final Vector max = region.getMaximumPoint();
|
||||||
|
|
||||||
int minX = min.getBlockX();
|
final int minX = min.getBlockX();
|
||||||
int minY = min.getBlockY();
|
final int minY = min.getBlockY();
|
||||||
int minZ = min.getBlockZ();
|
final int minZ = min.getBlockZ();
|
||||||
int maxX = max.getBlockX();
|
final int maxX = max.getBlockX();
|
||||||
int maxY = max.getBlockY();
|
final int maxY = max.getBlockY();
|
||||||
int maxZ = max.getBlockZ();
|
final int maxZ = max.getBlockZ();
|
||||||
|
|
||||||
for (int x = minX; x <= maxX; ++x) {
|
for (int x = minX; x <= maxX; ++x) {
|
||||||
for (int y = minY; y <= maxY; ++y) {
|
for (int y = minY; y <= maxY; ++y) {
|
||||||
@ -2767,11 +2769,8 @@ public class EditSession {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseBlock air = new BaseBlock(BlockID.AIR);
|
|
||||||
|
|
||||||
|
|
||||||
for (int i = 1; i < thickness; ++i) {
|
for (int i = 1; i < thickness; ++i) {
|
||||||
final Set<BlockVector> newOutside = new HashSet<BlockVector>(outside);
|
final Set<BlockVector> newOutside = new HashSet<BlockVector>();
|
||||||
outer: for (BlockVector position : region) {
|
outer: for (BlockVector position : region) {
|
||||||
for (Vector recurseDirection: recurseDirections) {
|
for (Vector recurseDirection: recurseDirections) {
|
||||||
BlockVector neighbor = position.add(recurseDirection).toBlockVector();
|
BlockVector neighbor = position.add(recurseDirection).toBlockVector();
|
||||||
@ -2783,7 +2782,7 @@ public class EditSession {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
outside = newOutside;
|
outside.addAll(newOutside);
|
||||||
}
|
}
|
||||||
|
|
||||||
outer: for (BlockVector position : region) {
|
outer: for (BlockVector position : region) {
|
||||||
@ -2795,7 +2794,7 @@ public class EditSession {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setBlock(position, air)) {
|
if (setBlock(position, pattern.next(position))) {
|
||||||
++affected;
|
++affected;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -394,19 +394,24 @@ public class RegionCommands {
|
|||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "/hollow" },
|
aliases = { "/hollow" },
|
||||||
usage = "[<thickness>]",
|
usage = "[<thickness>[ <block>]]",
|
||||||
desc = "Hollows out the object contained in this selection",
|
desc = "Hollows out the object contained in this selection",
|
||||||
|
help =
|
||||||
|
"Hollows out the object contained in this selection.\n" +
|
||||||
|
"Optionally fills the hollowed out part with the given block.\n" +
|
||||||
|
"Thickness is measured in manhattan distance.",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 1
|
max = 2
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.region.hollow")
|
@CommandPermissions("worldedit.region.hollow")
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
public void hollow(CommandContext args, LocalSession session, LocalPlayer player,
|
public void hollow(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
int thickness = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : 1;
|
final int thickness = args.argsLength() >= 1 ? Math.max(1, args.getInteger(0)) : 1;
|
||||||
|
final Pattern pattern = args.argsLength() >= 2 ? we.getBlockPattern(player, args.getString(1)) : new SingleBlockPattern(new BaseBlock(BlockID.AIR));
|
||||||
|
|
||||||
int affected = editSession.hollowOutRegion(session.getSelection(player.getWorld()), thickness);
|
final int affected = editSession.hollowOutRegion(session.getSelection(player.getWorld()), thickness, pattern);
|
||||||
|
|
||||||
player.print(affected + " block(s) have been changed.");
|
player.print(affected + " block(s) have been changed.");
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren