mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-05 04:26:42 +00:00
Update Upstream
ed28089 Don't crash if fields are null in ChunkDeleter (1874) f049d56 Revert "Use a Guava Cache instead of a ThreadLocal (1859)" c5a4450 Internally use a negated mask class to prevent russian doll wrapping (1877) 1397ec7 Add Snow Smooth Tools (1580) Fixes #955 Fixes #858
This commit is contained in:
@ -79,6 +79,7 @@ import com.sk89q.worldedit.command.tool.brush.HollowCylinderBrush;
|
||||
import com.sk89q.worldedit.command.tool.brush.HollowSphereBrush;
|
||||
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.util.CommandPermissions;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
@ -1292,20 +1293,65 @@ public class BrushCommands {
|
||||
@CommandPermissions("worldedit.brush.smooth")
|
||||
public void smoothBrush(
|
||||
Player player, LocalSession session,
|
||||
//FAWE start - Expression > double
|
||||
@Arg(desc = "The radius to sample for softening", def = "2")
|
||||
Expression radius,
|
||||
//FAWE end
|
||||
@Arg(desc = "The number of iterations to perform", def = "4")
|
||||
int iterations,
|
||||
@Arg(desc = "The mask of blocks to use for the heightmap", def = "")
|
||||
Mask maskOpt,
|
||||
Mask mask,
|
||||
InjectedValueAccess context
|
||||
) throws WorldEditException {
|
||||
worldEdit.checkMaxBrushRadius(radius);
|
||||
|
||||
//FAWE start
|
||||
FaweLimit limit = Settings.IMP.getLimit(player);
|
||||
iterations = Math.min(limit.MAX_ITERATIONS, iterations);
|
||||
//FAWE end
|
||||
|
||||
set(context, new SmoothBrush(iterations, maskOpt)).setSize(radius);
|
||||
set(context, new SmoothBrush(iterations, mask)).setSize(radius);
|
||||
player.print(Caption.of(
|
||||
"worldedit.brush.smooth.equip",
|
||||
radius,
|
||||
iterations,
|
||||
Caption.of("worldedit.brush.smooth." + (mask == null ? "no" : "") + "filter")
|
||||
));
|
||||
}
|
||||
|
||||
@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,
|
||||
//FAWE start - Expression > double
|
||||
@Arg(desc = "The radius to sample for softening", def = "2")
|
||||
Expression radius,
|
||||
//FAWE end
|
||||
@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, InjectedValueAccess context
|
||||
) throws WorldEditException {
|
||||
worldEdit.checkMaxBrushRadius(radius);
|
||||
|
||||
//FAWE start
|
||||
FaweLimit limit = Settings.IMP.getLimit(player);
|
||||
iterations = Math.min(limit.MAX_ITERATIONS, iterations);
|
||||
//FAWE end
|
||||
|
||||
set(context, new SnowSmoothBrush(iterations, mask)).setSize(radius);
|
||||
player.print(Caption.of(
|
||||
"worldedit.brush.smooth.equip",
|
||||
radius,
|
||||
iterations,
|
||||
Caption.of("worldedit.brush.smooth." + (mask == null ? "no" : "") + "filter")
|
||||
));
|
||||
}
|
||||
|
||||
@Command(
|
||||
|
@ -55,6 +55,7 @@ import com.sk89q.worldedit.math.Vector3;
|
||||
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;
|
||||
@ -466,9 +467,7 @@ public class RegionCommands {
|
||||
@Arg(desc = "# of iterations to perform", def = "1")
|
||||
int iterations,
|
||||
@Arg(desc = "The mask of blocks to use as the height map", def = "")
|
||||
Mask mask,
|
||||
@Switch(name = 's', desc = "The flag makes it only consider snow")
|
||||
boolean snow
|
||||
Mask mask
|
||||
) throws WorldEditException {
|
||||
//FAWE start > the mask will have been initialised with a WorldWrapper extent (very bad/slow)
|
||||
if (mask instanceof AbstractExtentMask) {
|
||||
@ -485,7 +484,7 @@ public class RegionCommands {
|
||||
}
|
||||
int affected;
|
||||
try {
|
||||
HeightMap heightMap = new HeightMap(editSession, region, mask, snow);
|
||||
HeightMap heightMap = new HeightMap(editSession, region, mask);
|
||||
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
|
||||
affected = heightMap.applyFilter(filter, iterations);
|
||||
actor.print(Caption.of("worldedit.smooth.changed", TextComponent.of(affected)));
|
||||
@ -527,6 +526,31 @@ public class RegionCommands {
|
||||
}
|
||||
}
|
||||
|
||||
@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)
|
||||
@Preload(Preload.PreloadCheck.PRELOAD)
|
||||
@Confirm(Confirm.Processor.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(Caption.of("worldedit.snowsmooth.changed", TextComponent.of(affected)));
|
||||
return affected;
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "/move",
|
||||
|
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* 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 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);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user