mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-22 17:27:38 +00:00
Remove the 'natural only' smooth brush feature due to inaccuracies.
This commit is contained in:
parent
57c13ef8f4
commit
efa09001c2
@ -416,34 +416,19 @@ public class EditSession implements Extent {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the highest solid 'terrain' block which can occur naturally.
|
||||
*
|
||||
* @param x the X coordinate
|
||||
* @param z the Z cooridnate
|
||||
* @param minY minimal height
|
||||
* @param maxY maximal height
|
||||
* @return height of highest block found or 'minY'
|
||||
*/
|
||||
public int getHighestTerrainBlock(int x, int z, int minY, int maxY) {
|
||||
return getHighestTerrainBlock(x, z, minY, maxY, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the highest solid 'terrain' block which can occur naturally.
|
||||
* Returns the highest solid 'terrain' block.
|
||||
*
|
||||
* @param x the X coordinate
|
||||
* @param z the Z coordinate
|
||||
* @param minY minimal height
|
||||
* @param maxY maximal height
|
||||
* @param naturalOnly look at natural blocks or all blocks
|
||||
* @return height of highest block found or 'minY'
|
||||
*/
|
||||
public int getHighestTerrainBlock(int x, int z, int minY, int maxY, boolean naturalOnly) {
|
||||
public int getHighestTerrainBlock(int x, int z, int minY, int maxY) {
|
||||
for (int y = maxY; y >= minY; --y) {
|
||||
Vector pt = new Vector(x, y, z);
|
||||
BlockState block = getBlock(pt);
|
||||
int[] datas = LegacyMapper.getInstance().getLegacyFromBlock(block);
|
||||
if (naturalOnly ? BlockType.isNaturalTerrainBlock(datas[0], datas[1]) : block.getBlockType().getMaterial().isMovementBlocker()) {
|
||||
if (block.getBlockType().getMaterial().isMovementBlocker()) {
|
||||
return y;
|
||||
}
|
||||
}
|
||||
|
@ -26,19 +26,8 @@ package com.sk89q.worldedit.blocks;
|
||||
*/
|
||||
@Deprecated
|
||||
public final class BlockID {
|
||||
public static final int AIR = 0;
|
||||
public static final int STONE = 1;
|
||||
public static final int GRASS = 2;
|
||||
public static final int DIRT = 3;
|
||||
public static final int SAPLING = 6;
|
||||
public static final int BEDROCK = 7;
|
||||
public static final int SAND = 12;
|
||||
public static final int GRAVEL = 13;
|
||||
public static final int GOLD_ORE = 14;
|
||||
public static final int IRON_ORE = 15;
|
||||
public static final int COAL_ORE = 16;
|
||||
public static final int LOG = 17;
|
||||
public static final int LAPIS_LAZULI_ORE = 21; // LAPIS_ORE
|
||||
public static final int DISPENSER = 23;
|
||||
public static final int BED = 26;
|
||||
public static final int POWERED_RAIL = 27; // GOLDEN_RAIL
|
||||
@ -54,15 +43,11 @@ public final class BlockID {
|
||||
public static final int BROWN_MUSHROOM = 39;
|
||||
public static final int RED_MUSHROOM = 40;
|
||||
public static final int STEP = 44; // STONE_SLAB
|
||||
public static final int TNT = 46;
|
||||
public static final int TORCH = 50;
|
||||
public static final int FIRE = 51;
|
||||
@Deprecated
|
||||
public static final int WOODEN_STAIRS = 53;
|
||||
public static final int OAK_WOOD_STAIRS = 53; // OAK_STAIRS
|
||||
public static final int CHEST = 54;
|
||||
public static final int REDSTONE_WIRE = 55;
|
||||
public static final int DIAMOND_ORE = 56;
|
||||
public static final int CROPS = 59; // WHEAT
|
||||
public static final int FURNACE = 61;
|
||||
public static final int BURNING_FURNACE = 62; // LIT_FURNACE
|
||||
@ -76,29 +61,20 @@ public final class BlockID {
|
||||
public static final int STONE_PRESSURE_PLATE = 70;
|
||||
public static final int IRON_DOOR = 71;
|
||||
public static final int WOODEN_PRESSURE_PLATE = 72;
|
||||
public static final int REDSTONE_ORE = 73; // LIT_REDSTONE_ORE
|
||||
public static final int GLOWING_REDSTONE_ORE = 74; // UNLIT_REDSTONE_ORE
|
||||
public static final int REDSTONE_TORCH_OFF = 75; // UNLIT_REDSTONE_TORCH
|
||||
public static final int REDSTONE_TORCH_ON = 76; // LIT_REDSTONE_TORCH
|
||||
public static final int STONE_BUTTON = 77;
|
||||
public static final int SNOW = 78; // SNOW_LAYER
|
||||
public static final int CACTUS = 81;
|
||||
public static final int CLAY = 82;
|
||||
public static final int REED = 83; // REEDS
|
||||
public static final int FENCE = 85;
|
||||
public static final int PUMPKIN = 86;
|
||||
@Deprecated
|
||||
public static final int NETHERSTONE = 87;
|
||||
public static final int NETHERRACK = 87;
|
||||
public static final int SLOW_SAND = 88; // SOUL_SAND
|
||||
public static final int LIGHTSTONE = 89; // GLOWSTONE
|
||||
public static final int PORTAL = 90;
|
||||
public static final int JACKOLANTERN = 91; // LIT_PUMPKIN
|
||||
public static final int CAKE_BLOCK = 92; // CAKE
|
||||
public static final int REDSTONE_REPEATER_OFF = 93; // UNPOWERED_REPEATER
|
||||
public static final int REDSTONE_REPEATER_ON = 94; // POWERED_REPEATER
|
||||
@Deprecated
|
||||
public static final int LOCKED_CHEST = 95;
|
||||
public static final int TRAP_DOOR = 96; // TRAPDOOR
|
||||
public static final int BROWN_MUSHROOM_CAP = 99; // BROWN_MUSHROOM_BLOCK
|
||||
public static final int RED_MUSHROOM_CAP = 100; // RED_MUSHROOM_BLOCK
|
||||
@ -108,7 +84,6 @@ public final class BlockID {
|
||||
public static final int FENCE_GATE = 107;
|
||||
public static final int BRICK_STAIRS = 108;
|
||||
public static final int STONE_BRICK_STAIRS = 109;
|
||||
public static final int MYCELIUM = 110;
|
||||
public static final int LILY_PAD = 111; // WATERLILY
|
||||
public static final int NETHER_BRICK_STAIRS = 114;
|
||||
public static final int NETHER_WART = 115;
|
||||
@ -119,7 +94,6 @@ public final class BlockID {
|
||||
public static final int WOODEN_STEP = 126; // WOODEN_SLAB
|
||||
public static final int COCOA_PLANT = 127; // COCOA
|
||||
public static final int SANDSTONE_STAIRS = 128;
|
||||
public static final int EMERALD_ORE = 129;
|
||||
public static final int ENDER_CHEST = 130;
|
||||
public static final int TRIPWIRE_HOOK = 131;
|
||||
public static final int TRIPWIRE = 132;
|
||||
@ -139,19 +113,16 @@ public final class BlockID {
|
||||
public static final int COMPARATOR_OFF = 149; // UNPOWERED_COMPARATOR
|
||||
public static final int COMPARATOR_ON = 150; // COMPARATOR
|
||||
public static final int DAYLIGHT_SENSOR = 151; // DAYLIGHT_DETECTOR
|
||||
public static final int QUARTZ_ORE = 153;
|
||||
public static final int HOPPER = 154;
|
||||
public static final int QUARTZ_STAIRS = 156;
|
||||
public static final int ACTIVATOR_RAIL = 157;
|
||||
public static final int DROPPER = 158;
|
||||
public static final int STAINED_CLAY = 159; // STAINED_HARDENED_CLAY
|
||||
public static final int LOG2 = 162;
|
||||
public static final int ACACIA_STAIRS = 163;
|
||||
public static final int DARK_OAK_STAIRS = 164;
|
||||
public static final int IRON_TRAP_DOOR = 167;
|
||||
public static final int HAY_BLOCK = 170;
|
||||
public static final int CARPET = 171;
|
||||
public static final int PACKED_ICE = 174;
|
||||
public static final int DOUBLE_PLANT = 175;
|
||||
public static final int STANDING_BANNER = 176;
|
||||
public static final int WALL_BANNER = 177;
|
||||
|
@ -232,51 +232,6 @@ public enum BlockType {
|
||||
return centralTopLimit(block.getBlockType().getLegacyId(), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* HashSet for isNaturalBlock.
|
||||
*/
|
||||
private static final Set<Integer> isNaturalTerrainBlock = new HashSet<>();
|
||||
static {
|
||||
isNaturalTerrainBlock.add(BlockID.STONE);
|
||||
isNaturalTerrainBlock.add(BlockID.GRASS);
|
||||
isNaturalTerrainBlock.add(BlockID.DIRT);
|
||||
// isNaturalBlock.add(BlockID.COBBLESTONE); // technically can occur next to water and lava
|
||||
isNaturalTerrainBlock.add(BlockID.BEDROCK);
|
||||
isNaturalTerrainBlock.add(BlockID.SAND);
|
||||
isNaturalTerrainBlock.add(BlockID.GRAVEL);
|
||||
isNaturalTerrainBlock.add(BlockID.CLAY);
|
||||
isNaturalTerrainBlock.add(BlockID.MYCELIUM);
|
||||
isNaturalTerrainBlock.add(BlockID.PACKED_ICE);
|
||||
isNaturalTerrainBlock.add(BlockID.STAINED_CLAY);
|
||||
|
||||
// hell
|
||||
isNaturalTerrainBlock.add(BlockID.NETHERRACK);
|
||||
isNaturalTerrainBlock.add(BlockID.SLOW_SAND);
|
||||
isNaturalTerrainBlock.add(BlockID.LIGHTSTONE);
|
||||
isNaturalTerrainBlock.add(BlockID.QUARTZ_ORE);
|
||||
|
||||
// ores
|
||||
isNaturalTerrainBlock.add(BlockID.COAL_ORE);
|
||||
isNaturalTerrainBlock.add(BlockID.IRON_ORE);
|
||||
isNaturalTerrainBlock.add(BlockID.GOLD_ORE);
|
||||
isNaturalTerrainBlock.add(BlockID.LAPIS_LAZULI_ORE);
|
||||
isNaturalTerrainBlock.add(BlockID.DIAMOND_ORE);
|
||||
isNaturalTerrainBlock.add(BlockID.REDSTONE_ORE);
|
||||
isNaturalTerrainBlock.add(BlockID.GLOWING_REDSTONE_ORE);
|
||||
isNaturalTerrainBlock.add(BlockID.EMERALD_ORE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the block type is naturally occurring
|
||||
*
|
||||
* @param id the type ID of the block
|
||||
* @param data data value of the block
|
||||
* @return true if the block type is naturally occurring
|
||||
*/
|
||||
public static boolean isNaturalTerrainBlock(int id, int data) {
|
||||
return isNaturalTerrainBlock.contains(-16*id-data) || isNaturalTerrainBlock.contains(id);
|
||||
}
|
||||
|
||||
private static final Map<Integer, PlayerDirection> dataAttachments = new HashMap<>();
|
||||
private static final Map<Integer, PlayerDirection> nonDataAttachments = new HashMap<>();
|
||||
static {
|
||||
|
@ -158,27 +158,23 @@ public class BrushCommands {
|
||||
@Command(
|
||||
aliases = { "smooth" },
|
||||
usage = "[size] [iterations]",
|
||||
flags = "n",
|
||||
desc = "Choose the terrain softener brush",
|
||||
help =
|
||||
"Chooses the terrain softener brush.\n" +
|
||||
"The -n flag makes it only consider naturally occurring blocks.",
|
||||
"Chooses the terrain softener brush.",
|
||||
min = 0,
|
||||
max = 2
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.smooth")
|
||||
public void smoothBrush(Player player, LocalSession session, EditSession editSession,
|
||||
@Optional("2") double radius, @Optional("4") int iterations, @Switch('n')
|
||||
boolean naturalBlocksOnly) throws WorldEditException {
|
||||
@Optional("2") double radius, @Optional("4") int iterations) throws WorldEditException {
|
||||
|
||||
worldEdit.checkMaxBrushRadius(radius);
|
||||
|
||||
BrushTool tool = session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType());
|
||||
tool.setSize(radius);
|
||||
tool.setBrush(new SmoothBrush(iterations, naturalBlocksOnly), "worldedit.brush.smooth");
|
||||
tool.setBrush(new SmoothBrush(iterations), "worldedit.brush.smooth");
|
||||
|
||||
player.print(String.format("Smooth brush equipped (%.0f x %dx, using " + (naturalBlocksOnly ? "natural blocks only" : "any block") + ").",
|
||||
radius, iterations));
|
||||
player.print(String.format("Smooth brush equipped (%.0f x %dx, using any block).", radius, iterations));
|
||||
}
|
||||
|
||||
@Command(
|
||||
|
@ -234,18 +234,16 @@ public class RegionCommands {
|
||||
@Command(
|
||||
aliases = { "/smooth" },
|
||||
usage = "[iterations]",
|
||||
flags = "n",
|
||||
desc = "Smooth the elevation in the selection",
|
||||
help =
|
||||
"Smooths the elevation in the selection.\n" +
|
||||
"The -n flag makes it only consider naturally occuring blocks.",
|
||||
"Smooths the elevation in the selection.",
|
||||
min = 0,
|
||||
max = 1
|
||||
)
|
||||
@CommandPermissions("worldedit.region.smooth")
|
||||
@Logging(REGION)
|
||||
public void smooth(Player player, EditSession editSession, @Selection Region region, @Optional("1") int iterations, @Switch('n') boolean affectNatural) throws WorldEditException {
|
||||
HeightMap heightMap = new HeightMap(editSession, region, affectNatural);
|
||||
public void smooth(Player player, EditSession editSession, @Selection Region region, @Optional("1") int iterations) throws WorldEditException {
|
||||
HeightMap heightMap = new HeightMap(editSession, region);
|
||||
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
|
||||
int affected = heightMap.applyFilter(filter, iterations);
|
||||
player.print("Terrain's height map smoothed. " + affected + " block(s) changed.");
|
||||
|
@ -33,15 +33,9 @@ import com.sk89q.worldedit.util.Location;
|
||||
public class SmoothBrush implements Brush {
|
||||
|
||||
private int iterations;
|
||||
private boolean naturalOnly;
|
||||
|
||||
public SmoothBrush(int iterations) {
|
||||
this(iterations, false);
|
||||
}
|
||||
|
||||
public SmoothBrush(int iterations, boolean naturalOnly) {
|
||||
this.iterations = iterations;
|
||||
this.naturalOnly = naturalOnly;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -49,7 +43,7 @@ public class SmoothBrush implements Brush {
|
||||
Location min = new Location(editSession.getWorld(), position.subtract(size, size, size));
|
||||
Vector max = position.add(size, size + 10, size);
|
||||
Region region = new CuboidRegion(editSession.getWorld(), min.toVector(), max);
|
||||
HeightMap heightMap = new HeightMap(editSession, region, naturalOnly);
|
||||
HeightMap heightMap = new HeightMap(editSession, region);
|
||||
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
|
||||
heightMap.applyFilter(filter, iterations);
|
||||
}
|
||||
|
@ -44,22 +44,11 @@ public class HeightMap {
|
||||
|
||||
/**
|
||||
* Constructs the HeightMap
|
||||
*
|
||||
*
|
||||
* @param session an edit session
|
||||
* @param region the region
|
||||
*/
|
||||
public HeightMap(EditSession session, Region region) {
|
||||
this(session, region, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs the HeightMap
|
||||
*
|
||||
* @param session an edit session
|
||||
* @param region the region
|
||||
* @param naturalOnly ignore non-natural blocks
|
||||
*/
|
||||
public HeightMap(EditSession session, Region region, boolean naturalOnly) {
|
||||
checkNotNull(session);
|
||||
checkNotNull(region);
|
||||
|
||||
@ -78,7 +67,7 @@ public class HeightMap {
|
||||
data = new int[width * height];
|
||||
for (int z = 0; z < height; ++z) {
|
||||
for (int x = 0; x < width; ++x) {
|
||||
data[z * width + x] = session.getHighestTerrainBlock(x + minX, z + minZ, minY, maxY, naturalOnly);
|
||||
data[z * width + x] = session.getHighestTerrainBlock(x + minX, z + minZ, minY, maxY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user