mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 09:47:38 +00:00
Added a thickness parameter to //hollow.
This commit is contained in:
parent
936aff06b2
commit
633f6643a5
@ -2731,7 +2731,7 @@ public class EditSession {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException
|
||||
*/
|
||||
public int hollowOutRegion(Region region) throws MaxChangedBlocksException {
|
||||
public int hollowOutRegion(Region region, int thickness) throws MaxChangedBlocksException {
|
||||
int affected = 0;
|
||||
|
||||
Set<BlockVector> outside = new HashSet<BlockVector>();
|
||||
@ -2769,6 +2769,23 @@ public class EditSession {
|
||||
|
||||
BaseBlock air = new BaseBlock(BlockID.AIR);
|
||||
|
||||
|
||||
for (int i = 1; i < thickness; ++i) {
|
||||
final Set<BlockVector> newOutside = new HashSet<BlockVector>(outside);
|
||||
outer: for (BlockVector position : region) {
|
||||
for (Vector recurseDirection: recurseDirections) {
|
||||
BlockVector neighbor = position.add(recurseDirection).toBlockVector();
|
||||
|
||||
if (outside.contains(neighbor)) {
|
||||
newOutside.add(position);
|
||||
continue outer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
outside = newOutside;
|
||||
}
|
||||
|
||||
outer: for (BlockVector position : region) {
|
||||
for (Vector recurseDirection: recurseDirections) {
|
||||
BlockVector neighbor = position.add(recurseDirection).toBlockVector();
|
||||
|
@ -394,17 +394,19 @@ public class RegionCommands {
|
||||
|
||||
@Command(
|
||||
aliases = { "/hollow" },
|
||||
usage = "",
|
||||
usage = "[<thickness>]",
|
||||
desc = "Hollows out the object contained in this selection",
|
||||
min = 0,
|
||||
max = 0
|
||||
max = 1
|
||||
)
|
||||
@CommandPermissions("worldedit.region.hollow")
|
||||
@Logging(REGION)
|
||||
public void hollow(CommandContext args, LocalSession session, LocalPlayer player,
|
||||
EditSession editSession) throws WorldEditException {
|
||||
|
||||
int affected = editSession.hollowOutRegion(session.getSelection(player.getWorld()));
|
||||
int thickness = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : 1;
|
||||
|
||||
int affected = editSession.hollowOutRegion(session.getSelection(player.getWorld()), thickness);
|
||||
|
||||
player.print(affected + " block(s) have been changed.");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user