mirror of
https://github.com/EngineHub/WorldEdit.git
synced 2025-02-17 13:20:23 +08:00
Add Snow Smooth Tools (#1580)
* Added Snow Smooth Tools * Added missing javadocs * Restore backwards compatibility * Use isAir and isLiquid instead of checking exact types * Changed message for smoothing snow * Use IntegerProperty instead of Property<Object> * Requested changes from review * Added missing ":", consistent command description * Drop unnecessary try-catch for snow layer property * Removed configuration arguments for gaussian kernel * Removed duplicated code fragments to calculate the heightmap * Fixed switched x and y coordinates * Added missing point for checkstyle * Changed command usage as requested * Reordered flag for //snowsmooth, nicer formatting Co-authored-by: Octavia Togami <octavia.togami@gmail.com>
This commit is contained in:
parent
0e0b4e7fcb
commit
1397ec769f
@ -36,6 +36,7 @@
|
||||
import com.sk89q.worldedit.command.tool.brush.ImageHeightmapBrush;
|
||||
import com.sk89q.worldedit.command.tool.brush.OperationFactoryBrush;
|
||||
import com.sk89q.worldedit.command.tool.brush.SmoothBrush;
|
||||
import com.sk89q.worldedit.command.tool.brush.SnowSmoothBrush;
|
||||
import com.sk89q.worldedit.command.tool.brush.SphereBrush;
|
||||
import com.sk89q.worldedit.command.tool.brush.SplatterBrush;
|
||||
import com.sk89q.worldedit.command.util.AsyncCommandBuilder;
|
||||
@ -267,11 +268,41 @@ public void smoothBrush(Player player, LocalSession session,
|
||||
"worldedit.brush.smooth.equip",
|
||||
TextComponent.of((int) radius),
|
||||
TextComponent.of(iterations),
|
||||
TextComponent.of(mask == null ? "any block" : "filter")
|
||||
TranslatableComponent.of("worldedit.brush.smooth." + (mask == null ? "no" : "") + "filter")
|
||||
));
|
||||
ToolCommands.sendUnbindInstruction(player, UNBIND_COMMAND_COMPONENT);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "snowsmooth",
|
||||
desc = "Choose the snow terrain softener brush",
|
||||
descFooter = "Example: '/brush snowsmooth 5 1 -l 3'"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.snowsmooth")
|
||||
public void snowSmoothBrush(Player player, LocalSession session,
|
||||
@Arg(desc = "The radius to sample for softening", def = "2")
|
||||
double radius,
|
||||
@Arg(desc = "The number of iterations to perform", def = "4")
|
||||
int iterations,
|
||||
@ArgFlag(name = 'l', desc = "The number of snow blocks under snow", def = "1")
|
||||
int snowBlockCount,
|
||||
@ArgFlag(name = 'm', desc = "The mask of blocks to use for the heightmap")
|
||||
Mask mask) throws WorldEditException {
|
||||
worldEdit.checkMaxBrushRadius(radius);
|
||||
|
||||
BrushTool tool = session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType());
|
||||
tool.setSize(radius);
|
||||
tool.setBrush(new SnowSmoothBrush(iterations, snowBlockCount, mask), "worldedit.brush.snowsmooth");
|
||||
|
||||
player.printInfo(TranslatableComponent.of(
|
||||
"worldedit.brush.snowsmooth.equip",
|
||||
TextComponent.of((int) radius),
|
||||
TextComponent.of(iterations),
|
||||
TranslatableComponent.of("worldedit.brush.snowsmooth." + (mask == null ? "no" : "") + "filter"),
|
||||
TextComponent.of(snowBlockCount)
|
||||
));
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "extinguish",
|
||||
aliases = { "ex" },
|
||||
|
@ -49,6 +49,7 @@
|
||||
import com.sk89q.worldedit.math.convolution.GaussianKernel;
|
||||
import com.sk89q.worldedit.math.convolution.HeightMap;
|
||||
import com.sk89q.worldedit.math.convolution.HeightMapFilter;
|
||||
import com.sk89q.worldedit.math.convolution.SnowHeightMap;
|
||||
import com.sk89q.worldedit.math.noise.RandomNoise;
|
||||
import com.sk89q.worldedit.regions.ConvexPolyhedralRegion;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
@ -291,6 +292,28 @@ public int smooth(Actor actor, EditSession editSession, @Selection Region region
|
||||
return affected;
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/snowsmooth",
|
||||
desc = "Smooth the elevation in the selection with snow layers",
|
||||
descFooter = "Example: '//snowsmooth 1 -m snow_block,snow' would only smooth snow terrain."
|
||||
)
|
||||
@CommandPermissions("worldedit.region.snowsmooth")
|
||||
@Logging(REGION)
|
||||
public int snowSmooth(Actor actor, EditSession editSession, @Selection Region region,
|
||||
@Arg(desc = "# of iterations to perform", def = "1")
|
||||
int iterations,
|
||||
@ArgFlag(name = 'l', desc = "Set the amount of snow blocks under the snow", def = "1")
|
||||
int snowBlockCount,
|
||||
@ArgFlag(name = 'm', desc = "The mask of blocks to use as the height map")
|
||||
Mask mask) throws WorldEditException {
|
||||
SnowHeightMap heightMap = new SnowHeightMap(editSession, region, mask);
|
||||
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
|
||||
float[] changed = heightMap.applyFilter(filter, iterations);
|
||||
int affected = heightMap.applyChanges(changed, snowBlockCount);
|
||||
actor.printInfo(TranslatableComponent.of("worldedit.snowsmooth.changed", TextComponent.of(affected)));
|
||||
return affected;
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/move",
|
||||
desc = "Move the contents of the selection"
|
||||
|
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.command.tool.brush;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.math.convolution.GaussianKernel;
|
||||
import com.sk89q.worldedit.math.convolution.HeightMapFilter;
|
||||
import com.sk89q.worldedit.math.convolution.SnowHeightMap;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class SnowSmoothBrush implements Brush {
|
||||
private final Mask mask;
|
||||
private final int iterations;
|
||||
private final int snowBlockLayer;
|
||||
|
||||
|
||||
public SnowSmoothBrush(int iterations) {
|
||||
this(iterations, null);
|
||||
}
|
||||
|
||||
public SnowSmoothBrush(int iterations, @Nullable Mask mask) {
|
||||
this(iterations, 1, mask);
|
||||
}
|
||||
|
||||
public SnowSmoothBrush(int iterations, int snowBlockLayer, @Nullable Mask mask) {
|
||||
this.iterations = iterations;
|
||||
this.mask = mask;
|
||||
this.snowBlockLayer = snowBlockLayer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||
Vector3 posDouble = position.toVector3();
|
||||
BlockVector3 min = posDouble.subtract(size, size, size).toBlockPoint();
|
||||
BlockVector3 max = posDouble.add(size, size + 10, size).toBlockPoint();
|
||||
Region region = new CuboidRegion(editSession.getWorld(), min, max);
|
||||
SnowHeightMap heightMap = new SnowHeightMap(editSession, region, mask);
|
||||
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(10, 1.0));
|
||||
float[] data = heightMap.applyFilter(filter, iterations);
|
||||
heightMap.applyChanges(data, snowBlockLayer);
|
||||
}
|
||||
}
|
@ -50,6 +50,7 @@ public class HeightMap {
|
||||
*
|
||||
* @param session an edit session
|
||||
* @param region the region
|
||||
* @param mask optional mask for the height map
|
||||
*/
|
||||
public HeightMap(EditSession session, Region region, @Nullable Mask mask) {
|
||||
checkNotNull(session);
|
||||
@ -90,7 +91,7 @@ public int applyFilter(HeightMapFilter filter, int iterations) throws MaxChanged
|
||||
System.arraycopy(data, 0, newData, 0, data.length);
|
||||
|
||||
for (int i = 0; i < iterations; ++i) {
|
||||
newData = filter.filter(newData, width, height);
|
||||
newData = filter.filter(newData, width, height, 0.5F);
|
||||
}
|
||||
|
||||
return apply(newData);
|
||||
@ -138,7 +139,7 @@ public int apply(int[] data) throws MaxChangedBlocksException {
|
||||
BlockState existing = session.getBlock(BlockVector3.at(xr, curHeight, zr));
|
||||
|
||||
// Skip water/lava
|
||||
if (existing.getBlockType() != BlockTypes.WATER && existing.getBlockType() != BlockTypes.LAVA) {
|
||||
if (!existing.getBlockType().getMaterial().isLiquid()) {
|
||||
session.setBlock(BlockVector3.at(xr, newHeight, zr), existing);
|
||||
++blocksChanged;
|
||||
|
||||
|
@ -80,50 +80,109 @@ public void setKernel(Kernel kernel) {
|
||||
* @return the modified height map
|
||||
*/
|
||||
public int[] filter(int[] inData, int width, int height) {
|
||||
return filter(inData, width, height, 0.5F);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter with a 2D kernel.
|
||||
*
|
||||
* @param inData the data
|
||||
* @param width the width
|
||||
* @param height the height
|
||||
* @param offset the offset added to the height
|
||||
*
|
||||
* @return the modified height map
|
||||
*/
|
||||
public int[] filter(int[] inData, int width, int height, float offset) {
|
||||
checkNotNull(inData);
|
||||
|
||||
float[] inDataFloat = new float[inData.length];
|
||||
for (int i = 0; i < inData.length; i++) {
|
||||
inDataFloat[i] = inData[i];
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
float[] matrix = kernel.getKernelData(null);
|
||||
int[] outData = new int[inData.length];
|
||||
|
||||
int kh = kernel.getHeight();
|
||||
int kw = kernel.getWidth();
|
||||
int kox = kernel.getXOrigin();
|
||||
int koy = kernel.getYOrigin();
|
||||
|
||||
for (int y = 0; y < height; ++y) {
|
||||
for (int x = 0; x < width; ++x) {
|
||||
float z = 0;
|
||||
|
||||
for (int ky = 0; ky < kh; ++ky) {
|
||||
int offsetY = y + ky - koy;
|
||||
// Clamp coordinates inside data
|
||||
if (offsetY < 0 || offsetY >= height) {
|
||||
offsetY = y;
|
||||
}
|
||||
|
||||
offsetY *= width;
|
||||
|
||||
int matrixOffset = ky * kw;
|
||||
for (int kx = 0; kx < kw; ++kx) {
|
||||
float f = matrix[matrixOffset + kx];
|
||||
if (f == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int offsetX = x + kx - kox;
|
||||
// Clamp coordinates inside data
|
||||
if (offsetX < 0 || offsetX >= width) {
|
||||
offsetX = x;
|
||||
}
|
||||
|
||||
z += f * inData[offsetY + offsetX];
|
||||
}
|
||||
}
|
||||
outData[index++] = (int) (z + 0.5);
|
||||
outData[index++] = (int) calculateHeight(inDataFloat, width, height, offset, matrix, x, y);
|
||||
}
|
||||
}
|
||||
return outData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter with a 2D kernel for float values.
|
||||
*
|
||||
* @param inData the data
|
||||
* @param width the width
|
||||
* @param height the height
|
||||
*
|
||||
* @return the modified height map
|
||||
*/
|
||||
public float[] filter(float[] inData, int width, int height, float offset) {
|
||||
checkNotNull(inData);
|
||||
|
||||
int index = 0;
|
||||
float[] matrix = kernel.getKernelData(null);
|
||||
float[] outData = new float[inData.length];
|
||||
|
||||
for (int y = 0; y < height; ++y) {
|
||||
for (int x = 0; x < width; ++x) {
|
||||
outData[index++] = calculateHeight(inData, width, height, offset, matrix, x, y);
|
||||
}
|
||||
}
|
||||
return outData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the height based on the existing data and the kernel data.
|
||||
*
|
||||
* @param inData the existing height data
|
||||
* @param width the width
|
||||
* @param height the height
|
||||
* @param offset the offset to add to the height
|
||||
* @param matrix the matrix with the kernel's data
|
||||
* @param x the current x coordinate
|
||||
* @param y the current y coordinate
|
||||
* @return the calculated height for that block
|
||||
*/
|
||||
private float calculateHeight(float[] inData, int width, int height, float offset, float[] matrix, int x, int y) {
|
||||
int kh = kernel.getHeight();
|
||||
int kw = kernel.getWidth();
|
||||
int kox = kernel.getXOrigin();
|
||||
int koy = kernel.getYOrigin();
|
||||
|
||||
float z = 0;
|
||||
|
||||
for (int ky = 0; ky < kh; ++ky) {
|
||||
int offsetY = y + ky - koy;
|
||||
// Clamp coordinates inside data
|
||||
if (offsetY < 0 || offsetY >= height) {
|
||||
offsetY = y;
|
||||
}
|
||||
|
||||
offsetY *= width;
|
||||
|
||||
int matrixOffset = ky * kw;
|
||||
for (int kx = 0; kx < kw; ++kx) {
|
||||
float f = matrix[matrixOffset + kx];
|
||||
if (f == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int offsetX = x + kx - kox;
|
||||
// Clamp coordinates inside data
|
||||
if (offsetX < 0 || offsetX >= width) {
|
||||
offsetX = x;
|
||||
}
|
||||
|
||||
z += f * inData[offsetY + offsetX];
|
||||
}
|
||||
}
|
||||
return z + offset;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,214 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.math.convolution;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.registry.state.IntegerProperty;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Allows applications of Kernels onto the region's height map for snow layers
|
||||
*
|
||||
* <p>Currently only used for snow layer smoothing (with a GaussianKernel)</p>.
|
||||
*/
|
||||
public class SnowHeightMap {
|
||||
private final float[] data;
|
||||
private final int width;
|
||||
private final int height;
|
||||
|
||||
private final Region region;
|
||||
private final EditSession session;
|
||||
|
||||
private final Property<Integer> layers;
|
||||
|
||||
/**
|
||||
* Constructs the SnowHeightMap.
|
||||
*
|
||||
* @param session an edit session
|
||||
* @param region the region
|
||||
* @param mask optional mask for the height map
|
||||
*/
|
||||
public SnowHeightMap(EditSession session, Region region, @Nullable Mask mask) {
|
||||
checkNotNull(session);
|
||||
checkNotNull(region);
|
||||
|
||||
this.session = session;
|
||||
this.region = region;
|
||||
|
||||
this.width = region.getWidth();
|
||||
this.height = region.getLength();
|
||||
|
||||
this.layers = BlockTypes.SNOW.getProperty("layers");
|
||||
|
||||
int minX = region.getMinimumPoint().getBlockX();
|
||||
int minY = region.getMinimumPoint().getBlockY();
|
||||
int minZ = region.getMinimumPoint().getBlockZ();
|
||||
int maxY = region.getMaximumPoint().getBlockY();
|
||||
|
||||
// Store current heightmap data
|
||||
data = new float[width * height];
|
||||
for (int z = 0; z < height; ++z) {
|
||||
for (int x = 0; x < width; ++x) {
|
||||
int highestBlockY = session.getHighestTerrainBlock(x + minX, z + minZ, minY, maxY, mask);
|
||||
BlockState upper = session.getBlock(BlockVector3.at(x + minX, highestBlockY + 1, z + minZ));
|
||||
if (upper.getBlockType() == BlockTypes.SNOW) {
|
||||
Integer amountLayers = upper.getState(layers);
|
||||
data[z * width + x] = (highestBlockY + 1 + (((float) amountLayers - 1) / 8));
|
||||
} else {
|
||||
BlockState block = session.getBlock(BlockVector3.at(x + minX, highestBlockY, z + minZ));
|
||||
if (block.getBlockType().getMaterial().isAir()) {
|
||||
data[z * width + x] = highestBlockY;
|
||||
} else {
|
||||
data[z * width + x] = highestBlockY + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute the new heightmap with the filter 'iterations' amount times.
|
||||
*
|
||||
* @param filter the filter
|
||||
* @param iterations the number of iterations
|
||||
* @return new generated heightmap of the terrain
|
||||
*/
|
||||
public float[] applyFilter(HeightMapFilter filter, int iterations) {
|
||||
checkNotNull(filter);
|
||||
|
||||
float[] newData = data.clone();
|
||||
|
||||
for (int i = 0; i < iterations; ++i) {
|
||||
// add an offset from 0.0625F to the values (snowlayer half)
|
||||
newData = filter.filter(newData, width, height, 0.0625F);
|
||||
}
|
||||
return newData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply a raw heightmap to a region. Use snow layers.
|
||||
*
|
||||
* @param data the data
|
||||
* @param layerBlocks amount of blocks with type SNOW_BLOCK
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException if the maximum block change limit is exceeded
|
||||
*/
|
||||
public int applyChanges(float[] data, int layerBlocks) throws MaxChangedBlocksException {
|
||||
checkNotNull(data);
|
||||
|
||||
BlockVector3 minY = region.getMinimumPoint();
|
||||
int originX = minY.getBlockX();
|
||||
int originY = minY.getBlockY();
|
||||
int originZ = minY.getBlockZ();
|
||||
|
||||
int maxY = region.getMaximumPoint().getBlockY();
|
||||
|
||||
BlockState fillerAir = BlockTypes.AIR.getDefaultState();
|
||||
BlockState fillerSnow = BlockTypes.SNOW_BLOCK.getDefaultState();
|
||||
|
||||
int blocksChanged = 0;
|
||||
|
||||
// Apply heightmap
|
||||
for (int z = 0; z < height; ++z) {
|
||||
for (int x = 0; x < width; ++x) {
|
||||
int index = z * width + x;
|
||||
float curHeight = this.data[index];
|
||||
|
||||
if (curHeight == originY) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Clamp newHeight within the selection area
|
||||
float newHeight = Math.min(maxY, data[index]);
|
||||
|
||||
// Offset x,z to be 'real' coordinates
|
||||
int xr = x + originX;
|
||||
int zr = z + originZ;
|
||||
|
||||
// We are keeping the topmost blocks so take that in account for the scale
|
||||
double scale = (double) (curHeight - originY) / (double) (newHeight - originY);
|
||||
|
||||
// Depending on growing or shrinking we need to start at the bottom or top
|
||||
if (newHeight >= curHeight) {
|
||||
// Set the top block of the column to be the same type (this might go wrong with rounding)
|
||||
BlockState existing = session.getBlock(BlockVector3.at(xr, curHeight, zr));
|
||||
|
||||
// Skip water/lava
|
||||
if (!existing.getBlockType().getMaterial().isLiquid()) {
|
||||
setSnowLayer(xr, zr, newHeight);
|
||||
++blocksChanged;
|
||||
|
||||
// Grow -- start from 1 below top replacing airblocks
|
||||
for (int y = (int) newHeight - 1 - originY; y >= 0; --y) {
|
||||
if (y >= newHeight - 1 - originY - layerBlocks) {
|
||||
session.setBlock(BlockVector3.at(xr, originY + y, zr), fillerSnow);
|
||||
} else {
|
||||
int copyFrom = (int) (y * scale);
|
||||
BlockState block = session.getBlock(BlockVector3.at(xr, originY + copyFrom, zr));
|
||||
session.setBlock(BlockVector3.at(xr, originY + y, zr), block);
|
||||
}
|
||||
++blocksChanged;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Shrink -- start from bottom
|
||||
for (int y = 0; y < (int) newHeight - originY; ++y) {
|
||||
if (y >= (int) newHeight - originY - layerBlocks) {
|
||||
session.setBlock(BlockVector3.at(xr, originY + y, zr), fillerSnow);
|
||||
} else {
|
||||
int copyFrom = (int) (y * scale);
|
||||
BlockState block = session.getBlock(BlockVector3.at(xr, originY + copyFrom, zr));
|
||||
session.setBlock(BlockVector3.at(xr, originY + y, zr), block);
|
||||
}
|
||||
++blocksChanged;
|
||||
}
|
||||
|
||||
setSnowLayer(xr, zr, newHeight);
|
||||
++blocksChanged;
|
||||
|
||||
// Fill rest with air
|
||||
for (int y = (int) newHeight + 1; y <= curHeight; ++y) {
|
||||
session.setBlock(BlockVector3.at(xr, y, zr), fillerAir);
|
||||
++blocksChanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Drop trees to the floor -- TODO
|
||||
return blocksChanged;
|
||||
}
|
||||
|
||||
private void setSnowLayer(int x, int z, float newHeight) throws MaxChangedBlocksException {
|
||||
int numOfLayers = (int) ((newHeight % 1) * 8) + 1;
|
||||
session.setBlock(BlockVector3.at(x, (int) newHeight, z), BlockTypes.SNOW.getState(ImmutableMap.of(this.layers, numOfLayers)));
|
||||
}
|
||||
}
|
@ -25,6 +25,11 @@
|
||||
"worldedit.brush.splatter.decay-out-of-range": "Splatter brush decay value: {0} is out of range 0 - 10.",
|
||||
"worldedit.brush.clipboard.equip": "Clipboard brush shape equipped.",
|
||||
"worldedit.brush.smooth.equip": "Smooth brush equipped ({0} x {1}x using {2}).",
|
||||
"worldedit.brush.smooth.nofilter": "any block",
|
||||
"worldedit.brush.smooth.filter": "filter",
|
||||
"worldedit.brush.snowsmooth.equip": "SnowSmooth brush equipped ({0} x {1}x using {2}), {3} snow blocks.",
|
||||
"worldedit.brush.snowsmooth.nofilter": "any block",
|
||||
"worldedit.brush.snowsmooth.filter": "filter",
|
||||
"worldedit.brush.extinguish.equip": "Extinguisher equipped ({0}).",
|
||||
"worldedit.brush.gravity.equip": "Gravity brush equipped ({0}).",
|
||||
"worldedit.brush.butcher.equip": "Butcher brush equipped ({0}).",
|
||||
@ -208,6 +213,7 @@
|
||||
"worldedit.naturalize.naturalized": "{0} block(s) have been made to look more natural.",
|
||||
"worldedit.center.changed": "Center set. ({0} blocks changed)",
|
||||
"worldedit.smooth.changed": "Terrain's height map smoothed. {0} blocks changed.",
|
||||
"worldedit.snowsmooth.changed": "Snow's height map smoothed. {0} blocks changed.",
|
||||
"worldedit.move.moved": "{0} blocks moved.",
|
||||
"worldedit.deform.deformed": "{0} blocks have been deformed.",
|
||||
"worldedit.hollow.changed": "{0} blocks have been changed.",
|
||||
|
Loading…
Reference in New Issue
Block a user