3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-24 18:10:08 +01:00

Added flag to //smooth to only use "natural" blocks

Dieser Commit ist enthalten in:
zml2008 2011-08-17 00:33:46 -07:00
Ursprung c99d64cfa0
Commit 2b94ddf7ed
6 geänderte Dateien mit 47 neuen und 31 gelöschten Zeilen

Datei anzeigen

@ -2378,12 +2378,12 @@ public class EditSession {
* maximal height * maximal height
* @return height of highest block found or 'minY' * @return height of highest block found or 'minY'
*/ */
public int getHighestTerrainBlock(int x, int z, int minY, int maxY) { public int getHighestTerrainBlock(int x, int z, int minY, int maxY, boolean naturalOnly) {
for (int y = maxY; y >= minY; --y) { for (int y = maxY; y >= minY; --y) {
Vector pt = new Vector(x, y, z); Vector pt = new Vector(x, y, z);
int id = getBlockType(pt); int id = getBlockType(pt);
if (naturalOnly ?
if (!BlockType.canPassThrough(id) /*id == 1 // stone id == 1 // stone
|| id == 2 // grass || id == 2 // grass
|| id == 3 // dirt || id == 3 // dirt
|| id == 7 // bedrock || id == 7 // bedrock
@ -2400,8 +2400,8 @@ public class EditSession {
|| id == 16 // gold ore || id == 16 // gold ore
|| id == 56 // diamond ore || id == 56 // diamond ore
|| id == 73 // redstone ore || id == 73 // redstone ore
|| id == 74 // redstone ore (active)*/ || id == 74 // redstone ore (active)
) { : !BlockType.canPassThrough(id)) {
return y; return y;
} }
} }

Datei anzeigen

@ -44,7 +44,7 @@ public class HeightMap {
* @param region * @param region
*/ */
public HeightMap(EditSession session, Region region) { public HeightMap(EditSession session, Region region, boolean naturalOnly) {
this.session = session; this.session = session;
this.region = region; this.region = region;
@ -60,7 +60,7 @@ public class HeightMap {
data = new int[width * height]; data = new int[width * height];
for (int z = 0; z < height; ++z) { for (int z = 0; z < height; ++z) {
for (int x = 0; x < width; ++x) { for (int x = 0; x < width; ++x) {
data[z * width + x] = session.getHighestTerrainBlock(x + minX, z + minZ, minY, maxY); data[z * width + x] = session.getHighestTerrainBlock(x + minX, z + minZ, minY, maxY, naturalOnly);
} }
} }
} }

Datei anzeigen

@ -171,6 +171,7 @@ public class BrushCommands {
@Command( @Command(
aliases = {"smooth"}, aliases = {"smooth"},
usage = "[size] [iterations]", usage = "[size] [iterations]",
flags = "n",
desc = "Choose the terrain softener brush", desc = "Choose the terrain softener brush",
min = 0, min = 0,
max = 2 max = 2
@ -193,9 +194,9 @@ public class BrushCommands {
BrushTool tool = session.getBrushTool(player.getItemInHand()); BrushTool tool = session.getBrushTool(player.getItemInHand());
tool.setSize(radius); tool.setSize(radius);
tool.setBrush(new SmoothBrush(iterations), "worldedit.brush.smooth"); tool.setBrush(new SmoothBrush(iterations, args.hasFlag('n')), "worldedit.brush.smooth");
player.print(String.format("Smooth brush equipped (%.0f x %dx).", player.print(String.format("Smooth brush equipped (%.0f x %dx, using " + (args.hasFlag('n') ? "natural blocks only" : "any block") + ").",
radius, iterations)); radius, iterations));
} }

Datei anzeigen

@ -186,6 +186,7 @@ public class RegionCommands {
@Command( @Command(
aliases = {"/smooth"}, aliases = {"/smooth"},
usage = "[iterations]", usage = "[iterations]",
flags = "n",
desc = "Smooth the elevation in the selection", desc = "Smooth the elevation in the selection",
min = 0, min = 0,
max = 1 max = 1
@ -201,7 +202,7 @@ public class RegionCommands {
iterations = args.getInteger(0); iterations = args.getInteger(0);
} }
HeightMap heightMap = new HeightMap(editSession, session.getSelection(player.getWorld())); HeightMap heightMap = new HeightMap(editSession, session.getSelection(player.getWorld()), args.hasFlag('n'));
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0)); HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
int affected = heightMap.applyFilter(filter, iterations); int affected = heightMap.applyFilter(filter, iterations);
player.print("Terrain's height map smoothed. " + affected + " block(s) changed."); player.print("Terrain's height map smoothed. " + affected + " block(s) changed.");

Datei anzeigen

@ -31,9 +31,11 @@ import com.sk89q.worldedit.regions.Region;
public class SmoothBrush implements Brush { public class SmoothBrush implements Brush {
private int iterations; private int iterations;
private boolean naturalOnly;
public SmoothBrush(int iterations) { public SmoothBrush(int iterations, boolean naturalOnly) {
this.iterations = iterations; this.iterations = iterations;
this.naturalOnly = naturalOnly;
} }
public void build(EditSession editSession, Vector pos, Pattern mat, double size) public void build(EditSession editSession, Vector pos, Pattern mat, double size)
@ -42,7 +44,7 @@ public class SmoothBrush implements Brush {
Vector min = pos.subtract(rad, rad, rad); Vector min = pos.subtract(rad, rad, rad);
Vector max = pos.add(rad, rad + 10, rad); Vector max = pos.add(rad, rad + 10, rad);
Region region = new CuboidRegion(min, max); Region region = new CuboidRegion(min, max);
HeightMap heightMap = new HeightMap(editSession, region); HeightMap heightMap = new HeightMap(editSession, region, naturalOnly);
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0)); HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
heightMap.applyFilter(filter, iterations); heightMap.applyFilter(filter, iterations);
} }

Datei anzeigen

@ -96,8 +96,12 @@ commands:
permissions: 'worldedit.generation.pumpkins' permissions: 'worldedit.generation.pumpkins'
/pyramid: /pyramid:
description: Generate a filled pyramid description: Generate a filled pyramid
usage: /<command> <block> <range> <height> [inverted] usage: /<command> <block> <range>
permissions: 'worldedit.generation.sphere' permissions: 'worldedit.generation.pyramid'
/hpyramid:
description: Generate a hollow pyramid
usage: /<command> <block> <range>
permissions: 'worldedit.generation.pyramid'
/undo: /undo:
description: Undoes the last action description: Undoes the last action
usage: /<command> [times] usage: /<command> [times]
@ -165,13 +169,13 @@ commands:
usage: /<command> <block> usage: /<command> <block>
permissions: 'worldedit.region.walls' permissions: 'worldedit.region.walls'
/faces: /faces:
description: Build the walls, ceiling, and roof of a selection description: Build the walls, ceiling, and floor of a selection
usage: /<command> <block> usage: /<command> <block>
aliases: ['/outline'] aliases: ['/outline']
permissions: 'worldedit.region.faces' permissions: 'worldedit.region.faces'
/smooth: /smooth:
description: Smooth the elevation in the selection description: Smooth the elevation in the selection
usage: /<command> [iterations] usage: /<command> [-n] [iterations]
permissions: 'worldedit.region.smooth' permissions: 'worldedit.region.smooth'
/move: /move:
description: Move the contents of the selection description: Move the contents of the selection
@ -201,25 +205,29 @@ commands:
description: Shift the selection area description: Shift the selection area
usage: /<command> <amount> [direction] usage: /<command> <amount> [direction]
permissions: 'worldedit.selection.shift' permissions: 'worldedit.selection.shift'
/chunk:
description: Set the selection to your current chunk
usage: /<command>
permissions: 'worldedit.selection.chunk'
/expand: /expand:
description: Expand the selection area description: Expand the selection area
usage: /<command> <amount> [reverse-amount] <direction> usage: /<command> <amount> [reverse-amount] <direction>
permissions: 'worldedit.selection.expand' permissions: 'worldedit.selection.expand'
/sel:
description: Choose a region selector
usage: /<command> [type]
aliases: [',']
/chunk:
description: Set the selection to your current chunk. The -s flag extends your current selection to the encompassed chunks.
usage: /<command> [-s]
permissions: 'worldedit.selection.chunk'
/contract: /contract:
description: Contract the selection area description: Contract the selection area
usage: /<command> <amount> [reverse-amount] [direction] usage: /<command> <amount> [reverse-amount] [direction]
permissions: 'worldedit.selection.contract' permissions: 'worldedit.selection.contract'
/pos1: /pos1:
description: Set position 1 description: Set position 1
usage: /<command> usage: /<command> [coordinates]
permissions: 'worldedit.selection.pos' permissions: 'worldedit.selection.pos'
/pos2: /pos2:
description: Set position 2 description: Set position 2
usage: /<command> usage: /<command> [coordinates]
permissions: 'worldedit.selection.pos' permissions: 'worldedit.selection.pos'
/hpos1: /hpos1:
description: Set position 1 to targeted block description: Set position 1 to targeted block
@ -249,10 +257,6 @@ commands:
description: Get the distribution of blocks in the selection description: Get the distribution of blocks in the selection
usage: /<command> [-c] usage: /<command> [-c]
permissions: 'worldedit.analysis.distr' permissions: 'worldedit.analysis.distr'
/sel:
description: Choose a region selector
usage: /<command> [type]
aliases: [',']
snapshot: snapshot:
description: Snapshot commands description: Snapshot commands
usage: /<command> usage: /<command>
@ -270,9 +274,13 @@ commands:
description: Set the brush mask description: Set the brush mask
usage: /<command> [mask] usage: /<command> [mask]
permissions: 'worldedit.brush.options.mask' permissions: 'worldedit.brush.options.mask'
range:
description: Set the brush range
usage: /<command> [pattern]
permissions: 'worldedit.brush.options.range'
/: /:
description: Toggle the super pickaxe pickaxe function description: Toggle the super pickaxe pickaxe function
usage: /<command> usage: /<command> [on|off]
aliases: [','] aliases: [',']
permissions: 'worldedit.superpickaxe' permissions: 'worldedit.superpickaxe'
superpickaxe: superpickaxe:
@ -287,10 +295,6 @@ commands:
usage: /<command> [pattern] usage: /<command> [pattern]
aliases: ['material', 'fill'] aliases: ['material', 'fill']
permissions: 'worldedit.brush.options.material' permissions: 'worldedit.brush.options.material'
range:
description: Set the brush range
usage: /<command> [pattern]
permissions: 'worldedit.brush.options.range'
info: info:
description: Block information tool description: Block information tool
usage: /<command> usage: /<command>
@ -323,6 +327,10 @@ commands:
description: Floating tree remover tool description: Floating tree remover tool
usage: /<command> usage: /<command>
permissions: 'worldedit.tool.deltree' permissions: 'worldedit.tool.deltree'
farwand:
description: Wand at a distance tool
usage: /<command>
permissions: 'worldedit.tool.farwand'
remove: remove:
description: Remove all entities of a type description: Remove all entities of a type
usage: /<command> <type> <radius> usage: /<command> <type> <radius>
@ -372,6 +380,10 @@ commands:
description: Thaws the area description: Thaws the area
usage: /<command> [radius] usage: /<command> [radius]
permissions: 'worldedit.thaw' permissions: 'worldedit.thaw'
green:
description: Greens the area
usage: /<command> [radius]
permissions: 'worldedit.green'
ex: ex:
description: Extinguish nearby fire description: Extinguish nearby fire
usage: /<command> [radius] usage: /<command> [radius]