Added //naturalize.

This commit is contained in:
sk89q 2011-08-02 15:46:11 -07:00
parent 9343b3d1a8
commit 8bb0629d79
3 changed files with 197 additions and 103 deletions

View File

@ -1,6 +1,6 @@
name: WorldEdit name: WorldEdit
main: com.sk89q.worldedit.bukkit.WorldEditPlugin main: com.sk89q.worldedit.bukkit.WorldEditPlugin
version: "${project.version}" version: ${project.version}
commands: commands:
chunkinfo: chunkinfo:
description: Get information about the chunk that you are inside description: Get information about the chunk that you are inside
@ -14,10 +14,6 @@ commands:
description: Delete chunks that your selection includes description: Delete chunks that your selection includes
usage: /<command> usage: /<command>
permissions: 'worldedit.delchunks' permissions: 'worldedit.delchunks'
clearclipboard:
description: Clear your clipboard
usage: /<command>
permissions: 'worldedit.clipboard.clear'
/load: /load:
description: Load a schematic into your clipboard description: Load a schematic into your clipboard
usage: /<command> <filename> usage: /<command> <filename>
@ -46,6 +42,19 @@ commands:
description: Paste the clipboard's contents description: Paste the clipboard's contents
usage: /<command> [-ao] usage: /<command> [-ao]
permissions: 'worldedit.clipboard.paste' permissions: 'worldedit.clipboard.paste'
clearclipboard:
description: Clear your clipboard
usage: /<command>
permissions: 'worldedit.clipboard.clear'
/limit:
description: Modify block change limit
usage: /<command> <limit>
permissions: 'worldedit.limit'
/gmask:
description: Set the global mask
usage: /<command> [mask]
aliases: ['gmask']
permissions: 'worldedit.global-mask'
we: we:
description: WorldEdit commands description: WorldEdit commands
usage: /<command> usage: /<command>
@ -61,15 +70,6 @@ commands:
description: Search for an item description: Search for an item
usage: /<command> [-bi] <query> usage: /<command> [-bi] <query>
aliases: ['/l', 'search'] aliases: ['/l', 'search']
/limit:
description: Modify block change limit
usage: /<command> <limit>
permissions: 'worldedit.limit'
/gmask:
description: Set the global mask
usage: /<command> [mask]
aliases: ['gmask']
permissions: 'worldedit.global-mask'
/hcyl: /hcyl:
description: Generate a hollow cylinder description: Generate a hollow cylinder
usage: /<command> <block> <radius> [height] usage: /<command> <block> <radius> [height]
@ -94,32 +94,36 @@ commands:
description: Generate pumpkin patches description: Generate pumpkin patches
usage: /<command> [size] usage: /<command> [size]
permissions: 'worldedit.generation.pumpkins' permissions: 'worldedit.generation.pumpkins'
clearhistory:
description: Clear your history
usage: /<command>
permissions: 'worldedit.history.clear'
/redo:
description: Redoes the last action (from history)
usage: /<command> [times]
aliases: ['redo']
permissions: 'worldedit.history.redo'
/undo: /undo:
description: Undoes the last action description: Undoes the last action
usage: /<command> [times] usage: /<command> [times]
aliases: ['undo'] aliases: ['undo']
permissions: 'worldedit.history.undo' permissions: 'worldedit.history.undo'
/redo:
description: Redoes the last action (from history)
usage: /<command> [times]
aliases: ['redo']
permissions: 'worldedit.history.redo'
clearhistory:
description: Clear your history
usage: /<command>
permissions: 'worldedit.history.clear'
unstuck: unstuck:
description: Escape from being stuck inside a block description: Escape from being stuck inside a block
usage: /<command> usage: /<command>
permissions: 'worldedit.navigation.unstuck' permissions: 'worldedit.navigation.unstuck'
ascend: ascend:
description: Go up a floor description: Go up a floor
usage: /<command> usage: /<command> [# of levels]
permissions: 'worldedit.navigation.ascend' permissions: 'worldedit.navigation.ascend'
descend: descend:
description: Go down a floor description: Go down a floor
usage: /<command> usage: /<command> [# of floors]
permissions: 'worldedit.navigation.descend' permissions: 'worldedit.navigation.descend'
ceil:
description: Go to the celing
usage: /<command> [clearance]
permissions: 'worldedit.navigation.ceiling'
thru: thru:
description: Passthrough walls description: Passthrough walls
usage: /<command> usage: /<command>
@ -128,18 +132,30 @@ commands:
description: Teleport to a location description: Teleport to a location
usage: /<command> usage: /<command>
permissions: 'worldedit.navigation.jumpto' permissions: 'worldedit.navigation.jumpto'
ceil:
description: Go to the celing
usage: /<command> [clearance]
permissions: 'worldedit.navigation.ceiling'
up: up:
description: Go upwards some distance description: Go upwards some distance
usage: /<command> <block> usage: /<command> <block>
permissions: 'worldedit.navigation.up' permissions: 'worldedit.navigation.up'
/replace:
description: Replace all blocks in the selection with another
usage: /<command> [from-block] <to-block>
permissions: 'worldedit.region.replace'
/stack:
description: Repeat the contents of the selection
usage: /<command> [-sa] [count] [direction]
permissions: 'worldedit.region.stack'
/set:
description: Set all the blocks inside the selection to a block
usage: /<command> <block>
permissions: 'worldedit.region.set'
/overlay: /overlay:
description: Set a block on top of blocks in the region description: Set a block on top of blocks in the region
usage: /<command> <block> usage: /<command> <block>
permissions: 'worldedit.region.overlay' permissions: 'worldedit.region.overlay'
/naturalize:
description: 3 layers of dirt on top then rock below
usage: /<command>
permissions: 'worldedit.region.naturalize'
/walls: /walls:
description: Build the four sides of the selection description: Build the four sides of the selection
usage: /<command> <block> usage: /<command> <block>
@ -153,38 +169,46 @@ commands:
description: Smooth the elevation in the selection description: Smooth the elevation in the selection
usage: /<command> [iterations] usage: /<command> [iterations]
permissions: 'worldedit.region.smooth' permissions: 'worldedit.region.smooth'
/regen:
description: Regenerates the contents of the selection
usage: /<command>
permissions: 'worldedit.regen'
/replace:
description: Replace all blocks in the selection with another
usage: /<command> [from-block] <to-block>
permissions: 'worldedit.region.replace'
/stack:
description: Repeat the contents of the selection
usage: /<command> [-sa] [count] [direction]
permissions: 'worldedit.region.stack'
/set:
description: Set all the blocks inside the selection to a block
usage: /<command> <block>
permissions: 'worldedit.region.set'
/move: /move:
description: Move the contents of the selection description: Move the contents of the selection
usage: /<command> [-s] [count] [direction] [leave-id] usage: /<command> [-s] [count] [direction] [leave-id]
permissions: 'worldedit.region.move' permissions: 'worldedit.region.move'
.s: /regen:
description: Execute last CraftScript description: Regenerates the contents of the selection
usage: /<command> [args...] usage: /<command>
permissions: 'worldedit.scripting.execute' permissions: 'worldedit.regen'
cs: cs:
description: Execute a CraftScript description: Execute a CraftScript
usage: /<command> <filename> [args...] usage: /<command> <filename> [args...]
permissions: 'worldedit.scripting.execute' permissions: 'worldedit.scripting.execute'
.s:
description: Execute last CraftScript
usage: /<command> [args...]
permissions: 'worldedit.scripting.execute'
/count:
description: Counts the number of a certain type of block
usage: /<command> <block>
permissions: 'worldedit.analysis.count'
/size:
description: Get information about the selection
usage: /<command>
permissions: 'worldedit.selection.size'
/shift:
description: Shift the selection area
usage: /<command> <amount> [direction]
permissions: 'worldedit.selection.shift'
/sel:
description: Choose a region selector
usage: /<command> [type]
aliases: [',']
/chunk: /chunk:
description: Set the selection to your current chunk description: Set the selection to your current chunk
usage: /<command> usage: /<command>
permissions: 'worldedit.selection.chunk' permissions: 'worldedit.selection.chunk'
/expand:
description: Expand the selection area
usage: /<command> <amount> [reverse-amount] <direction>
permissions: 'worldedit.selection.expand'
/contract: /contract:
description: Contract the selection area description: Contract the selection area
usage: /<command> <amount> [reverse-amount] [direction] usage: /<command> <amount> [reverse-amount] [direction]
@ -217,34 +241,14 @@ commands:
description: Outset the selection area description: Outset the selection area
usage: /<command> [-hv] <amount> usage: /<command> [-hv] <amount>
permissions: 'worldedit.selection.outset' permissions: 'worldedit.selection.outset'
/distr:
description: Get the distribution of blocks in the selection
usage: /<command> [-c]
permissions: 'worldedit.analysis.distr'
/count:
description: Counts the number of a certain type of block
usage: /<command> <block>
permissions: 'worldedit.analysis.count'
/size:
description: Get information about the selection
usage: /<command>
permissions: 'worldedit.selection.size'
/shift:
description: Shift the selection area
usage: /<command> <amount> [direction]
permissions: 'worldedit.selection.shift'
/expand:
description: Expand the selection area
usage: /<command> <amount> [reverse-amount] <direction>
permissions: 'worldedit.selection.expand'
/sel:
description: Choose a region selector
usage: /<command> [type]
aliases: [',']
/inset: /inset:
description: Inset the selection area description: Inset the selection area
usage: /<command> [-hv] <amount> usage: /<command> [-hv] <amount>
permissions: 'worldedit.selection.inset' permissions: 'worldedit.selection.inset'
/distr:
description: Get the distribution of blocks in the selection
usage: /<command> [-c]
permissions: 'worldedit.analysis.distr'
snapshot: snapshot:
description: Snapshot commands description: Snapshot commands
usage: /<command> usage: /<command>
@ -254,6 +258,14 @@ commands:
usage: /<command> [snapshot] usage: /<command> [snapshot]
aliases: ['/restore'] aliases: ['/restore']
permissions: 'worldedit.snapshots.restore' permissions: 'worldedit.snapshots.restore'
size:
description: Set the brush size
usage: /<command> [pattern]
permissions: 'worldedit.brush.options.size'
mask:
description: Set the brush mask
usage: /<command> [mask]
permissions: 'worldedit.brush.options.mask'
/: /:
description: Toggle the super pickaxe pickaxe function description: Toggle the super pickaxe pickaxe function
usage: /<command> usage: /<command>
@ -271,21 +283,21 @@ commands:
usage: /<command> [pattern] usage: /<command> [pattern]
aliases: ['material', 'fill'] aliases: ['material', 'fill']
permissions: 'worldedit.brush.options.material' permissions: 'worldedit.brush.options.material'
size:
description: Set the brush size
usage: /<command> [pattern]
permissions: 'worldedit.brush.options.size'
range: range:
description: Set the brush range description: Set the brush range
usage: /<command> [range] usage: /<command> [pattern]
permissions: 'worldedit.brush.options.range' permissions: 'worldedit.brush.options.range'
mask: info:
description: Set the brush mask description: Block information tool
usage: /<command> [mask] usage: /<command>
permissions: 'worldedit.brush.options.mask' permissions: 'worldedit.tool.info'
none: none:
description: Turn off all superpickaxe alternate modes description: Turn off all superpickaxe alternate modes
usage: /<command> usage: /<command>
tree:
description: Tree generator tool
usage: /<command> [type]
permissions: 'worldedit.tool.tree'
repl: repl:
description: Block replacer tool description: Block replacer tool
usage: /<command> <block> usage: /<command> <block>
@ -307,18 +319,23 @@ commands:
description: Floating tree remover tool description: Floating tree remover tool
usage: /<command> usage: /<command>
permissions: 'worldedit.tool.deltree' permissions: 'worldedit.tool.deltree'
info: remove:
description: Block information tool description: Remove all entities of a type
usage: /<command> usage: /<command> <type> <radius>
permissions: 'worldedit.tool.info' aliases: ['rem', 'rement']
tree: permissions: 'worldedit.remove'
description: Tree generator tool /fill:
usage: /<command> [type] description: Fill a hole
permissions: 'worldedit.tool.tree' usage: /<command> <block> <radius> [depth]
permissions: 'worldedit.fill'
/fillr: /fillr:
description: Fill a hole recursively description: Fill a hole recursively
usage: /<command> <block> <radius> [depth] usage: /<command> <block> <radius> [depth]
permissions: 'worldedit.fill.recursive' permissions: 'worldedit.fill.recursive'
/drain:
description: Drain a pool
usage: /<command> <radius>
permissions: 'worldedit.drain'
fixlava: fixlava:
description: Fix lava to be stationary description: Fix lava to be stationary
usage: /<command> <radius> usage: /<command> <radius>
@ -360,16 +377,3 @@ commands:
description: Kill all or nearby mobs description: Kill all or nearby mobs
usage: /<command> [-p] [radius] usage: /<command> [-p] [radius]
permissions: 'worldedit.butcher' permissions: 'worldedit.butcher'
remove:
description: Remove all entities of a type
usage: /<command> <type> <radius>
aliases: ['rem', 'rement']
permissions: 'worldedit.remove'
/fill:
description: Fill a hole
usage: /<command> <block> <radius> [depth]
permissions: 'worldedit.fill'
/drain:
description: Drain a pool
usage: /<command> <radius>
permissions: 'worldedit.drain'

View File

@ -1296,6 +1296,79 @@ && getBlock(above).isAir()) {
return affected; return affected;
} }
/**
* Turns the first 3 layers into dirt/grass and the bottom layers
* into rock, like a natural Minecraft mountain.
*
* @param region
* @return number of blocks affected
* @throws MaxChangedBlocksException
*/
public int naturalizeCuboidBlocks(Region region)
throws MaxChangedBlocksException {
Vector min = region.getMinimumPoint();
Vector max = region.getMaximumPoint();
int upperY = Math.min(127, max.getBlockY() + 1);
int lowerY = Math.max(0, min.getBlockY() - 1);
int affected = 0;
int minX = min.getBlockX();
int minZ = min.getBlockZ();
int maxX = max.getBlockX();
int maxZ = max.getBlockZ();
BaseBlock grass = new BaseBlock(BlockID.GRASS);
BaseBlock dirt = new BaseBlock(BlockID.DIRT);
BaseBlock stone = new BaseBlock(BlockID.STONE);
for (int x = minX; x <= maxX; ++x) {
for (int z = minZ; z <= maxZ; ++z) {
int level = -1;
for (int y = upperY; y >= lowerY; --y) {
Vector pt = new Vector(x, y, z);
Vector above = new Vector(x, y + 1, z);
int blockType = getBlockType(pt);
boolean isTransformable =
blockType == BlockID.GRASS
|| blockType == BlockID.DIRT
|| blockType == BlockID.STONE;
// Still searching for the top block
if (level == -1) {
if (!isTransformable) {
continue; // Not transforming this column yet
}
level = 0;
}
if (level >= 0) {
if (isTransformable) {
if (level == 0) {
setBlock(pt, grass);
affected++;
} else if (level <= 2) {
setBlock(pt, dirt);
affected++;
} else {
setBlock(pt, stone);
affected++;
}
}
level++;
}
}
}
}
return affected;
}
/** /**
* Stack a cuboid region. * Stack a cuboid region.
* *

View File

@ -121,6 +121,23 @@ public static void overlay(CommandContext args, WorldEdit we,
player.print(affected + " block(s) have been overlayed."); player.print(affected + " block(s) have been overlayed.");
} }
@Command(
aliases = {"/naturalize"},
usage = "",
desc = "3 layers of dirt on top then rock below",
min = 0,
max = 0
)
@CommandPermissions({"worldedit.region.naturalize"})
public static void naturalize(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
Region region = session.getSelection(player.getWorld());
int affected = editSession.naturalizeCuboidBlocks(region);
player.print(affected + " block(s) have been naturalized.");
}
@Command( @Command(
aliases = {"/walls"}, aliases = {"/walls"},
usage = "<block>", usage = "<block>",