This commit is contained in:
Aurora 2020-07-03 19:54:08 +02:00
commit bc45a112ee
30 changed files with 326 additions and 78 deletions

Binary file not shown.

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

2
gradlew vendored
View File

@ -82,6 +82,7 @@ esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
@ -129,6 +130,7 @@ fi
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath

1
gradlew.bat vendored
View File

@ -84,6 +84,7 @@ set CMD_LINE_ARGS=%*
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

View File

@ -563,10 +563,13 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
ChunkSection section = getSections()[layer];
// Section is null, return empty array
if (section == null) {
return FaweCache.IMP.EMPTY_CHAR_4096;
data = new char[4096];
Arrays.fill(data, (char) 1);
return data;
}
if (data == null || data == FaweCache.IMP.EMPTY_CHAR_4096) {
data = new char[4096];
Arrays.fill(data, (char) 1);
}
DelegateLock lock = BukkitAdapter_1_14.applyLock(section);
synchronized (lock) {
@ -606,6 +609,10 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
} else {
ordinal = adapter.adaptToChar(ibd);
}
// Don't read "empty".
if (ordinal == 0) {
ordinal = 1;
}
paletteToBlockChars[paletteVal] = ordinal;
}
data[i] = ordinal;
@ -633,10 +640,18 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
val = ordinal(palette.a(i), adapter);
paletteToOrdinal[i] = val;
}
// Don't read "empty".
if (val == 0) {
val = 1;
}
data[i] = val;
}
} else {
char ordinal = ordinal(palette.a(0), adapter);
// Don't read "empty".
if (ordinal == 0) {
ordinal = 1;
}
Arrays.fill(data, ordinal);
}
} finally {

View File

@ -581,10 +581,13 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
ChunkSection section = getSections()[layer];
// Section is null, return empty array
if (section == null) {
return FaweCache.IMP.EMPTY_CHAR_4096;
data = new char[4096];
Arrays.fill(data, (char) 1);
return data;
}
if (data == null || data == FaweCache.IMP.EMPTY_CHAR_4096) {
data = new char[4096];
Arrays.fill(data, (char) 1);
}
DelegateLock lock = BukkitAdapter_1_15_2.applyLock(section);
synchronized (lock) {
@ -626,6 +629,10 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
}
paletteToBlockChars[paletteVal] = ordinal;
}
// Don't read "empty".
if (ordinal == 0) {
ordinal = 1;
}
data[i] = ordinal;
}
} finally {
@ -651,10 +658,18 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
val = ordinal(palette.a(i), adapter);
paletteToOrdinal[i] = val;
}
// Don't read "empty".
if (val == 0) {
val = 1;
}
data[i] = val;
}
} else {
char ordinal = ordinal(palette.a(0), adapter);
// Don't read "empty".
if (ordinal == 0) {
ordinal = 1;
}
Arrays.fill(data, ordinal);
}
} finally {

View File

@ -552,10 +552,13 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
ChunkSection section = getSections()[layer];
// Section is null, return empty array
if (section == null) {
return FaweCache.IMP.EMPTY_CHAR_4096;
data = new char[4096];
Arrays.fill(data, (char) 1);
return data;
}
if (data == null || data == FaweCache.IMP.EMPTY_CHAR_4096) {
data = new char[4096];
Arrays.fill(data, (char) 1);
}
DelegateLock lock = BukkitAdapter_1_16_1.applyLock(section);
synchronized (lock) {
@ -597,6 +600,10 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
}
paletteToBlockChars[paletteVal] = ordinal;
}
// Don't read "empty".
if (ordinal == 0) {
ordinal = 1;
}
data[i] = ordinal;
}
} finally {
@ -622,10 +629,18 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
val = ordinal(palette.a(i), adapter);
paletteToOrdinal[i] = val;
}
// Don't read "empty".
if (val == 0) {
val = 1;
}
data[i] = val;
}
} else {
char ordinal = ordinal(palette.a(0), adapter);
// Don't read "empty".
if (ordinal == 0) {
ordinal = 1;
}
Arrays.fill(data, ordinal);
}
} finally {

View File

@ -2,14 +2,22 @@ package com.boydti.fawe.bukkit.regions.plotsquared;
import com.boydti.fawe.util.EditSessionBuilder;
import com.boydti.fawe.util.TaskManager;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.generator.HybridPlotManager;
import com.plotsquared.core.generator.HybridPlotWorld;
import com.plotsquared.core.location.Location;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotAreaTerrainType;
import com.plotsquared.core.plot.PlotAreaType;
import com.plotsquared.core.plot.PlotManager;
import com.plotsquared.core.util.RegionManager;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
import com.sk89q.worldedit.function.FlatRegionFunction;
import com.sk89q.worldedit.function.biome.BiomeReplace;
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
@ -21,7 +29,12 @@ import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Set;
import static org.bukkit.Bukkit.getWorld;
@ -65,6 +78,75 @@ public class FaweRegionManager extends RegionManager {
return true;
}
@Override
public boolean notifyClear(PlotManager manager) {
if (!(manager instanceof HybridPlotManager)) {
return false;
}
final HybridPlotWorld hpw = ((HybridPlotManager) manager).getHybridPlotWorld();
return hpw.getType() != PlotAreaType.AUGMENTED || hpw.getTerrain() == PlotAreaTerrainType.NONE;
}
@Override
public boolean handleClear(final Plot plot, final Runnable whenDone, final PlotManager manager) {
if (!(manager instanceof HybridPlotManager)) {
return false;
}
TaskManager.IMP.async(() -> {
synchronized (FaweRegionManager.class) {
final HybridPlotWorld hybridPlotWorld = ((HybridPlotManager) manager).getHybridPlotWorld();
EditSession editSession = new EditSessionBuilder(BukkitAdapter.adapt(getWorld(hybridPlotWorld.getWorldName()))).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
if (!hybridPlotWorld.PLOT_SCHEMATIC || !Settings.Schematics.PASTE_ON_TOP) {
final BlockType bedrock;
final BlockType air = BlockTypes.AIR;
if (hybridPlotWorld.PLOT_BEDROCK) {
bedrock = BlockTypes.BEDROCK;
} else {
bedrock = air;
}
final Pattern filling = hybridPlotWorld.MAIN_BLOCK.toPattern();
final Pattern plotfloor = hybridPlotWorld.TOP_BLOCK.toPattern();
BlockVector3 pos1 = plot.getBottomAbs().getBlockVector3();
BlockVector3 pos2 = plot.getExtendedTopAbs().getBlockVector3();
Region bedrockRegion = new CuboidRegion(pos1.withY(0), pos2.withY(0));
Region fillingRegion = new CuboidRegion(pos1.withY(1), pos2.withY(hybridPlotWorld.PLOT_HEIGHT - 1));
Region floorRegion = new CuboidRegion(pos1.withY(hybridPlotWorld.PLOT_HEIGHT),
pos2.withY(hybridPlotWorld.PLOT_HEIGHT));
Region airRegion = new CuboidRegion(pos1.withY(hybridPlotWorld.PLOT_HEIGHT + 1),
pos2.withY(manager.getWorldHeight()));
editSession.setBlocks(bedrockRegion, bedrock);
editSession.setBlocks(fillingRegion, filling);
editSession.setBlocks(floorRegion, plotfloor);
editSession.setBlocks(airRegion, air);
}
if (hybridPlotWorld.PLOT_SCHEMATIC) {
File schematicFile = new File(hybridPlotWorld.getRoot(), "plot.schem");
if (!schematicFile.exists()) {
schematicFile = new File(hybridPlotWorld.getRoot(), "plot.schematic");
}
BlockVector3 to = plot.getBottomAbs().getBlockVector3().withY(Settings.Schematics.PASTE_ON_TOP ? hybridPlotWorld.SCHEM_Y : 1);
try {
Clipboard clip = ClipboardFormats.findByFile(schematicFile).getReader(new FileInputStream(schematicFile)).read();
clip.paste(editSession, to, true, true, true);
} catch (IOException e) {
e.printStackTrace();
}
}
editSession.flushQueue();
TaskManager.IMP.task(whenDone);
}
});
return true;
}
@Override
public void swap(final Location pos1, final Location pos2, final Location pos3, final Location pos4, final Runnable whenDone) {
TaskManager.IMP.async(() -> {

View File

@ -45,7 +45,7 @@ public class PlotSetBiome extends Command {
}
@Override
public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
public CompletableFuture<Boolean> execute(final PlotPlayer<?> player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT);
checkTrue(plot.isOwner(player.getUUID()) || Permissions
.hasPermission(player, "plots.admin.command.generatebiome"), Captions.NO_PLOT_PERMS);

View File

@ -5,11 +5,11 @@ import com.boydti.fawe.object.RegionWrapper;
import com.boydti.fawe.regions.FaweMask;
import com.boydti.fawe.regions.FaweMaskManager;
import com.boydti.fawe.regions.general.RegionFilter;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.command.MainCommand;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.generator.HybridPlotManager;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea;
@ -18,7 +18,6 @@ import com.plotsquared.core.plot.flag.implementations.NoWorldeditFlag;
import com.plotsquared.core.util.RegionManager;
import com.plotsquared.core.util.SchematicHandler;
import com.plotsquared.core.util.WEManager;
import com.plotsquared.core.util.uuid.UUIDHandler;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
@ -76,9 +75,9 @@ public class PlotSquaredFeature extends FaweMaskManager {
// If it's going to fail, throw an error now rather than later
//QueueProvider provider = QueueProvider.of(FaweLocalBlockQueue.class, null);
//GlobalBlockQueue.IMP.setProvider(provider);
HybridPlotManager.REGENERATIVE_CLEAR = false;
//HybridPlotManager.REGENERATIVE_CLEAR = false;
//log.debug(" - QueueProvider: " + FaweLocalBlockQueue.class);
log.debug(" - HybridPlotManager.REGENERATIVE_CLEAR: " + HybridPlotManager.REGENERATIVE_CLEAR);
//log.debug(" - HybridPlotManager.REGENERATIVE_CLEAR: " + HybridPlotManager.REGENERATIVE_CLEAR);
}
private void setupRegionManager() throws RuntimeException {

View File

@ -77,9 +77,9 @@ public class PlotSquaredFeature extends FaweMaskManager {
// If it's going to fail, throw an error now rather than later
//QueueProvider provider = QueueProvider.of(FaweLocalBlockQueue.class, null);
//GlobalBlockQueue.IMP.setProvider(provider);
HybridPlotManager.REGENERATIVE_CLEAR = false;
//HybridPlotManager.REGENERATIVE_CLEAR = false;
//log.debug(" - QueueProvider: " + FaweLocalBlockQueue.class);
log.debug(" - HybridPlotManager.REGENERATIVE_CLEAR: " + HybridPlotManager.REGENERATIVE_CLEAR);
//log.debug(" - HybridPlotManager.REGENERATIVE_CLEAR: " + HybridPlotManager.REGENERATIVE_CLEAR);
}
private void setupChunkManager() throws RuntimeException {

View File

@ -55,6 +55,8 @@ import java.lang.ref.WeakReference;
import java.nio.file.Path;
import java.util.*;
import javax.annotation.Nullable;
import org.bukkit.Bukkit;
import org.bukkit.Effect;
import org.bukkit.TreeType;
import org.bukkit.World;
@ -78,7 +80,8 @@ public class BukkitWorld extends AbstractWorld {
}
}
private final WeakReference<World> worldRef;
private WeakReference<World> worldRef;
private final String worldNameRef;
private final WorldNativeAccess<?, ?, ?> worldNativeAccess;
/**
@ -88,6 +91,7 @@ public class BukkitWorld extends AbstractWorld {
*/
public BukkitWorld(World world) {
this.worldRef = new WeakReference<>(world);
this.worldNameRef = world.getName();
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
if (adapter != null) {
this.worldNativeAccess = adapter.createWorldNativeAccess(world);
@ -125,7 +129,12 @@ public class BukkitWorld extends AbstractWorld {
* @return the world
*/
public World getWorld() {
return checkNotNull(worldRef.get(), "The world was unloaded and the reference is unavailable");
World tmp = worldRef.get();
if (tmp == null) {
tmp = Bukkit.getWorld(worldNameRef);
if (tmp != null) worldRef = new WeakReference<>(tmp);
}
return checkNotNull(tmp, "The world was unloaded and the reference is unavailable");
}
/**

View File

@ -10,7 +10,7 @@ plugins {
id("net.ltgt.apt-idea")
id("antlr")
id("com.mendhak.gradlecrowdin")
kotlin("jvm") version "1.3.61"
kotlin("jvm") version "1.3.72"
}
repositories {
@ -59,7 +59,7 @@ dependencies {
"compile"("com.github.intellectualsites.plotsquared:PlotSquared-API:latest") {
isTransitive = false
}
"compile"("com.plotsquared:PlotSquared-Core:5.11.2") {
"compile"("com.plotsquared:PlotSquared-Core:5.12.2") {
isTransitive = false
}
implementation(kotlin("stdlib-jdk8", "1.3.61"))

View File

@ -1,7 +1,7 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm") version "1.3.41"
kotlin("jvm") version "1.3.72"
application
}

View File

@ -78,32 +78,6 @@ public class FaweAPI {
return TaskManager.IMP;
}
// /**
// * Add a custom mask for use in e.g {@literal //mask #id:<input>}
// *
// * @param methods The class with a bunch of mask methods
// * @return true if the mask was registered
// * @see com.sk89q.worldedit.command.MaskCommands
// */
// public static boolean registerMasks(Object methods) {
// DefaultMaskParser parser = getParser(DefaultMaskParser.class);
// if (parser != null) parser.register(methods);
// return parser != null;
// }
//
// /**
// * Add a custom material for use in e.g {@literal //material #id:<input>}
// *
// * @param methods The class with a bunch of pattern methods
// * @return true if the mask was registered
// * @see com.sk89q.worldedit.command.PatternCommands
// */
// public static boolean registerPatterns(Object methods) {
// DefaultPatternParser parser = getParser(DefaultPatternParser.class);
// if (parser != null) parser.register(methods);
// return parser != null;
// }
//
// /**
// * Add a custom transform for use in
// *

View File

@ -2,12 +2,12 @@ package com.boydti.fawe.beta.implementation.blocks;
import com.boydti.fawe.beta.IChunkGet;
import com.boydti.fawe.beta.IChunkSet;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.block.BlockTypesCache;
import java.util.Arrays;
public abstract class CharGetBlocks extends CharBlocks implements IChunkGet {
@Override
@ -25,6 +25,14 @@ public abstract class CharGetBlocks extends CharBlocks implements IChunkGet {
return true;
}
public char[] update(int layer, char[] data) {
if (data == null) {
data = new char[4096];
}
Arrays.fill(data, (char) 1);
return data;
}
@Override
public boolean trim(boolean aggressive, int layer) {
sections[layer] = EMPTY;

View File

@ -157,7 +157,9 @@ public class ParallelQueueExtent extends PassthroughExtent implements IQueueWrap
}
// TODO optimize parallel
for (BlockVector3 blockVector3 : vset) {
pattern.apply(this, blockVector3, blockVector3);
if (pattern.apply(this, blockVector3, blockVector3)) {
this.changes++;
}
}
return this.changes;
}

View File

@ -30,7 +30,7 @@ public class HistoryExtent extends AbstractDelegateExtent {
/**
* Create a new instance.
*
* @param extent the extent
* @param extent the extent
* @param changeSet the change set
*/
public HistoryExtent(Extent extent, AbstractChangeSet changeSet) {

View File

@ -46,6 +46,7 @@ public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor {
private final World world;
protected AtomicInteger waitingCombined = new AtomicInteger(0);
protected AtomicInteger waitingAsync = new AtomicInteger(0);
protected boolean closed;
public AbstractChangeSet(World world) {

View File

@ -2,11 +2,7 @@ package com.boydti.fawe.object.regions;
import com.boydti.fawe.object.collection.BlockVectorSet;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.RegionFunction;
import com.sk89q.worldedit.function.mask.AbstractExtentMask;
import com.sk89q.worldedit.function.mask.DelegateExtentMask;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.function.visitor.RecursiveVisitor;
@ -45,12 +41,9 @@ public class FuzzyRegion extends AbstractRegion {
}
public void select(int x, int y, int z) {
RecursiveVisitor search = new RecursiveVisitor(mask.withExtent(extent), new RegionFunction() {
@Override
public boolean apply(BlockVector3 p) throws WorldEditException {
setMinMax(p.getBlockX(), p.getBlockY(), p.getBlockZ());
return true;
}
RecursiveVisitor search = new RecursiveVisitor(mask.withExtent(extent), p -> {
setMinMax(p.getBlockX(), p.getBlockY(), p.getBlockZ());
return true;
}, 256);
search.setVisited(set);
search.visit(BlockVector3.at(x, y, z));

View File

@ -65,6 +65,7 @@ import com.sk89q.worldedit.function.block.BlockReplace;
import com.sk89q.worldedit.function.block.Naturalizer;
import com.sk89q.worldedit.function.generator.ForestGenerator;
import com.sk89q.worldedit.function.generator.GardenPatchGenerator;
import com.sk89q.worldedit.function.mask.BlockStateMask;
import com.sk89q.worldedit.function.mask.BlockTypeMask;
import com.sk89q.worldedit.function.mask.BoundedHeightMask;
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
@ -138,6 +139,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@ -1624,16 +1626,35 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int drainArea(BlockVector3 origin, double radius, boolean waterlogged) throws MaxChangedBlocksException {
return drainArea(origin, radius, waterlogged, false);
}
/**
* Drain nearby pools of water or lava, optionally removed waterlogged states from blocks.
*
* @param origin the origin to drain from, which will search a 3x3 area
* @param radius the radius of the removal, where a value should be 0 or greater
* @param waterlogged true to make waterlogged blocks non-waterlogged as well
* @param plants true to remove underwater plants
* @return number of blocks affected
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int drainArea(BlockVector3 origin, double radius, boolean waterlogged, boolean plants) throws MaxChangedBlocksException {
checkNotNull(origin);
checkArgument(radius >= 0, "radius >= 0 required");
Mask liquidMask;
// Not thread safe, use hardcoded liquidmask
// if (getWorld() != null) {
// liquidMask = getWorld().createLiquidMask();
// } else {
// }
liquidMask = new BlockTypeMask(this, BlockTypes.LAVA, BlockTypes.WATER);
if (plants) {
liquidMask = new BlockTypeMask(this, BlockTypes.LAVA, BlockTypes.WATER,
BlockTypes.KELP_PLANT, BlockTypes.KELP, BlockTypes.SEAGRASS, BlockTypes.TALL_SEAGRASS);
} else {
liquidMask = new BlockTypeMask(this, BlockTypes.LAVA, BlockTypes.WATER);
}
if (waterlogged) {
Map<String, String> stateMap = new HashMap<>();
stateMap.put("waterlogged", "true");
liquidMask = new MaskUnion(liquidMask, new BlockStateMask(this, stateMap, true));
}
Mask mask = new MaskIntersection(
new BoundedHeightMask(0, getWorld().getMaxY()),
new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))),
@ -2488,8 +2509,15 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
int yv = (int) (y.getValue() * unit.getY() + zero2.getY());
int zv = (int) (z.getValue() * unit.getZ() + zero2.getZ());
BlockState get;
if (yv >= 0 && yv < 265) {
get = getBlock(xv, yv, zv);
} else {
get = BlockTypes.AIR.getDefaultState();
}
// read block from world
return setBlock(position, getBlock(xv, yv, zv));
return setBlock(position, get);
} catch (EvaluationException e) {
throw new RuntimeException(e);
}
@ -2759,6 +2787,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
BlockVector3 tipv = interpol.getPosition(loop).toBlockPoint();
if (radius == 0) {
pattern.apply(this, tipv, tipv);
changes++;
} else {
vset.add(tipv);
}

View File

@ -326,11 +326,13 @@ public class UtilityCommands {
@Arg(desc = "The radius to drain")
Expression radiusExp,
@Switch(name = 'w', desc = "Also un-waterlog blocks")
boolean waterlogged) throws WorldEditException {
boolean waterlogged,
@Switch(name = 'p', desc = "Also remove water plants")
boolean plants) throws WorldEditException {
double radius = radiusExp.evaluate();
radius = Math.max(0, radius);
we.checkMaxRadius(radius);
int affected = editSession.drainArea(session.getPlacementPosition(actor), radius, waterlogged);
int affected = editSession.drainArea(session.getPlacementPosition(actor), radius, waterlogged, plants);
actor.printInfo(TranslatableComponent.of("worldedit.drain.drained", TextComponent.of(affected)));
return affected;
}

View File

@ -161,12 +161,16 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
Extent world = searchPos.getExtent();
int x = searchPos.getBlockX();
int y = Math.max(0, searchPos.getBlockY());
int origY = y;
int yPlusSearchHeight = y + WorldEdit.getInstance().getConfiguration().defaultVerticalHeight;
int z = searchPos.getBlockZ();
int maxY = Math.min(255, yPlusSearchHeight) + 2;
byte free = 0;
BlockVector3 mutablePos = MutableBlockVector3.ZERO;
while (y <= world.getMaximumPoint().getBlockY() + 2) {
while (y <= maxY) {
if (!world.getBlock(mutablePos.setComponents(x, y, z)).getBlockType().getMaterial()
.isMovementBlocker()) {
++free;
@ -175,10 +179,10 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
}
if (free == 2) {
final BlockVector3 pos = mutablePos.setComponents(x, y - 2, z);
final BlockState state = world.getBlock(pos);
setPosition(Vector3.at(x + 0.5, y - 2 + BlockTypeUtil.centralTopLimit(state), z + 0.5));
return;
if (y - 1 != origY) {
setPosition(Vector3.at(x + 0.5, y - 2 + 1, z + 0.5));
return;
}
}
++y;

View File

@ -184,7 +184,7 @@ public class BlockMask extends ABlockMask {
}
@Override
public boolean test(BlockState state) {
return ordinals[state.getOrdinal()];
return ordinals[state.getOrdinal()] || replacesAir() && state.getOrdinal() <= 3;
}
@Override

View File

@ -3,10 +3,10 @@ package com.sk89q.worldedit.function.mask;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
public class InverseSingleBlockStateMask extends ABlockMask {
private final char ordinal;
private final boolean isAir;
public BlockState getBlockState() {
return BlockState.getFromOrdinal(ordinal);
@ -14,17 +14,26 @@ public class InverseSingleBlockStateMask extends ABlockMask {
public InverseSingleBlockStateMask(Extent extent, BlockState state) {
super(extent);
isAir = state.isAir();
this.ordinal = state.getOrdinalChar();
}
@Override
public boolean test(Extent extent, BlockVector3 vector) {
return ordinal != vector.getOrdinal(extent);
int test = vector.getOrdinal(extent);
if (isAir && test == 0) {
return false;
}
return ordinal != test;
}
@Override
public final boolean test(BlockState state) {
return state.getOrdinalChar() != ordinal;
int test = state.getOrdinalChar();
if (isAir && test == 0) {
return false;
}
return test != ordinal;
}
@Override

View File

@ -13,7 +13,7 @@ public class SingleBlockTypeMask extends ABlockMask {
public SingleBlockTypeMask(Extent extent, BlockType type) {
super(extent);
isAir = type == BlockTypes.AIR || type == BlockTypes.CAVE_AIR || type == BlockTypes.VOID_AIR;
this.internalId = type.getInternalId();
this.internalId = type.getInternalId();
}
@Override

View File

@ -45,7 +45,7 @@ public class WaterloggedRemover extends AbstractExtentPattern {
// init
for (int i = 0; i < remap.length; i++) {
BlockState state = remap[i];
BlockState state = BlockTypesCache.states[i];
BlockType type = state.getBlockType();
if (!type.hasProperty(PropertyKey.WATERLOGGED)) {
continue;

View File

@ -286,7 +286,12 @@ public class HeightMap {
if (existing.getBlockType().getMaterial().isMovementBlocker()) {
int y0 = newHeight - 1;
for (int setY = y0, getY = curHeight - 1; setY >= curHeight; setY--, getY--) {
BlockState get = session.getBlock(xr, getY, zr);
BlockState get;
if (getY >= 0 && getY < 256) {
get = session.getBlock(xr, getY, zr);
} else {
get = BlockTypes.AIR.getDefaultState();
}
if (get != BlockTypes.AIR.getDefaultState()) tmpBlock = get;
session.setBlock(xr, setY, zr, tmpBlock);
++blocksChanged;

View File

@ -56,6 +56,7 @@ public final class BlockTypes {
@Nullable public static final BlockType ACTIVATOR_RAIL = init();
@Nullable public static final BlockType AIR = init();
@Nullable public static final BlockType ALLIUM = init();
@Nullable public static final BlockType ANCIENT_DEBRIS = init();
@Nullable public static final BlockType ANDESITE = init();
@Nullable public static final BlockType ANDESITE_SLAB = init();
@Nullable public static final BlockType ANDESITE_STAIRS = init();
@ -68,6 +69,7 @@ public final class BlockTypes {
@Nullable public static final BlockType BAMBOO_SAPLING = init();
@Nullable public static final BlockType BARREL = init();
@Nullable public static final BlockType BARRIER = init();
@Nullable public static final BlockType BASALT = init();
@Nullable public static final BlockType BEACON = init();
@Nullable public static final BlockType BEDROCK = init();
@Nullable public static final BlockType BEE_NEST = init();
@ -101,6 +103,10 @@ public final class BlockTypes {
@Nullable public static final BlockType BLACK_TERRACOTTA = init();
@Nullable public static final BlockType BLACK_WALL_BANNER = init();
@Nullable public static final BlockType BLACK_WOOL = init();
@Nullable public static final BlockType BLACKSTONE = init();
@Nullable public static final BlockType BLACKSTONE_SLAB = init();
@Nullable public static final BlockType BLACKSTONE_STAIRS = init();
@Nullable public static final BlockType BLACKSTONE_WALL = init();
@Nullable public static final BlockType BLAST_FURNACE = init();
@Nullable public static final BlockType BLUE_BANNER = init();
@Nullable public static final BlockType BLUE_BED = init();
@ -154,9 +160,12 @@ public final class BlockTypes {
@Nullable public static final BlockType CARVED_PUMPKIN = init();
@Nullable public static final BlockType CAULDRON = init();
@Nullable public static final BlockType CAVE_AIR = init();
@Nullable public static final BlockType CHAIN = init();
@Nullable public static final BlockType CHAIN_COMMAND_BLOCK = init();
@Nullable public static final BlockType CHEST = init();
@Nullable public static final BlockType CHIPPED_ANVIL = init();
@Nullable public static final BlockType CHISELED_NETHER_BRICKS = init();
@Nullable public static final BlockType CHISELED_POLISHED_BLACKSTONE = init();
@Nullable public static final BlockType CHISELED_QUARTZ_BLOCK = init();
@Nullable public static final BlockType CHISELED_RED_SANDSTONE = init();
@Nullable public static final BlockType CHISELED_SANDSTONE = init();
@ -178,10 +187,29 @@ public final class BlockTypes {
@Nullable public static final BlockType COMPOSTER = init();
@Nullable public static final BlockType CONDUIT = init();
@Nullable public static final BlockType CORNFLOWER = init();
@Nullable public static final BlockType CRACKED_NETHER_BRICKS = init();
@Nullable public static final BlockType CRACKED_POLISHED_BLACKSTONE_BRICKS = init();
@Nullable public static final BlockType CRACKED_STONE_BRICKS = init();
@Nullable public static final BlockType CRAFTING_TABLE = init();
@Nullable public static final BlockType CREEPER_HEAD = init();
@Nullable public static final BlockType CREEPER_WALL_HEAD = init();
@Nullable public static final BlockType CRIMSON_BUTTON = init();
@Nullable public static final BlockType CRIMSON_DOOR = init();
@Nullable public static final BlockType CRIMSON_FENCE = init();
@Nullable public static final BlockType CRIMSON_FENCE_GATE = init();
@Nullable public static final BlockType CRIMSON_FUNGUS = init();
@Nullable public static final BlockType CRIMSON_HYPHAE = init();
@Nullable public static final BlockType CRIMSON_NYLIUM = init();
@Nullable public static final BlockType CRIMSON_PLANKS = init();
@Nullable public static final BlockType CRIMSON_PRESSURE_PLATE = init();
@Nullable public static final BlockType CRIMSON_ROOTS = init();
@Nullable public static final BlockType CRIMSON_SIGN = init();
@Nullable public static final BlockType CRIMSON_SLAB = init();
@Nullable public static final BlockType CRIMSON_STAIRS = init();
@Nullable public static final BlockType CRIMSON_STEM = init();
@Nullable public static final BlockType CRIMSON_TRAPDOOR = init();
@Nullable public static final BlockType CRIMSON_WALL_SIGN = init();
@Nullable public static final BlockType CRYING_OBSIDIAN = init();
@Nullable public static final BlockType CUT_RED_SANDSTONE = init();
@Nullable public static final BlockType CUT_RED_SANDSTONE_SLAB = init();
@Nullable public static final BlockType CUT_SANDSTONE = init();
@ -278,6 +306,7 @@ public final class BlockTypes {
@Nullable public static final BlockType FLOWER_POT = init();
@Nullable public static final BlockType FROSTED_ICE = init();
@Nullable public static final BlockType FURNACE = init();
@Nullable public static final BlockType GILDED_BLACKSTONE = init();
@Nullable public static final BlockType GLASS = init();
@Nullable public static final BlockType GLASS_PANE = init();
@Nullable public static final BlockType GLOWSTONE = init();
@ -405,6 +434,7 @@ public final class BlockTypes {
@Nullable public static final BlockType LIME_TERRACOTTA = init();
@Nullable public static final BlockType LIME_WALL_BANNER = init();
@Nullable public static final BlockType LIME_WOOL = init();
@Nullable public static final BlockType LODESTONE = init();
@Nullable public static final BlockType LOOM = init();
@Nullable public static final BlockType MAGENTA_BANNER = init();
@Nullable public static final BlockType MAGENTA_BED = init();
@ -437,10 +467,13 @@ public final class BlockTypes {
@Nullable public static final BlockType NETHER_BRICK_STAIRS = init();
@Nullable public static final BlockType NETHER_BRICK_WALL = init();
@Nullable public static final BlockType NETHER_BRICKS = init();
@Nullable public static final BlockType NETHER_GOLD_ORE = init();
@Nullable public static final BlockType NETHER_PORTAL = init();
@Nullable public static final BlockType NETHER_QUARTZ_ORE = init();
@Nullable public static final BlockType NETHER_SPROUTS = init();
@Nullable public static final BlockType NETHER_WART = init();
@Nullable public static final BlockType NETHER_WART_BLOCK = init();
@Nullable public static final BlockType NETHERITE_BLOCK = init();
@Nullable public static final BlockType NETHERRACK = init();
@Nullable public static final BlockType NOTE_BLOCK = init();
@Nullable public static final BlockType OAK_BUTTON = init();
@ -498,6 +531,17 @@ public final class BlockTypes {
@Nullable public static final BlockType POLISHED_ANDESITE = init();
@Nullable public static final BlockType POLISHED_ANDESITE_SLAB = init();
@Nullable public static final BlockType POLISHED_ANDESITE_STAIRS = init();
@Nullable public static final BlockType POLISHED_BASALT = init();
@Nullable public static final BlockType POLISHED_BLACKSTONE = init();
@Nullable public static final BlockType POLISHED_BLACKSTONE_BRICK_SLAB = init();
@Nullable public static final BlockType POLISHED_BLACKSTONE_BRICK_STAIRS = init();
@Nullable public static final BlockType POLISHED_BLACKSTONE_BRICK_WALL = init();
@Nullable public static final BlockType POLISHED_BLACKSTONE_BRICKS = init();
@Nullable public static final BlockType POLISHED_BLACKSTONE_BUTTON = init();
@Nullable public static final BlockType POLISHED_BLACKSTONE_PRESSURE_PLATE = init();
@Nullable public static final BlockType POLISHED_BLACKSTONE_SLAB = init();
@Nullable public static final BlockType POLISHED_BLACKSTONE_STAIRS = init();
@Nullable public static final BlockType POLISHED_BLACKSTONE_WALL = init();
@Nullable public static final BlockType POLISHED_DIORITE = init();
@Nullable public static final BlockType POLISHED_DIORITE_SLAB = init();
@Nullable public static final BlockType POLISHED_DIORITE_STAIRS = init();
@ -515,6 +559,8 @@ public final class BlockTypes {
@Nullable public static final BlockType POTTED_BROWN_MUSHROOM = init();
@Nullable public static final BlockType POTTED_CACTUS = init();
@Nullable public static final BlockType POTTED_CORNFLOWER = init();
@Nullable public static final BlockType POTTED_CRIMSON_FUNGUS = init();
@Nullable public static final BlockType POTTED_CRIMSON_ROOTS = init();
@Nullable public static final BlockType POTTED_DANDELION = init();
@Nullable public static final BlockType POTTED_DARK_OAK_SAPLING = init();
@Nullable public static final BlockType POTTED_DEAD_BUSH = init();
@ -529,6 +575,8 @@ public final class BlockTypes {
@Nullable public static final BlockType POTTED_RED_MUSHROOM = init();
@Nullable public static final BlockType POTTED_RED_TULIP = init();
@Nullable public static final BlockType POTTED_SPRUCE_SAPLING = init();
@Nullable public static final BlockType POTTED_WARPED_FUNGUS = init();
@Nullable public static final BlockType POTTED_WARPED_ROOTS = init();
@Nullable public static final BlockType POTTED_WHITE_TULIP = init();
@Nullable public static final BlockType POTTED_WITHER_ROSE = init();
@Nullable public static final BlockType POWERED_RAIL = init();
@ -558,6 +606,7 @@ public final class BlockTypes {
@Nullable public static final BlockType PURPUR_SLAB = init();
@Nullable public static final BlockType PURPUR_STAIRS = init();
@Nullable public static final BlockType QUARTZ_BLOCK = init();
@Nullable public static final BlockType QUARTZ_BRICKS = init();
@Nullable public static final BlockType QUARTZ_PILLAR = init();
@Nullable public static final BlockType QUARTZ_SLAB = init();
@Nullable public static final BlockType QUARTZ_STAIRS = init();
@ -594,6 +643,7 @@ public final class BlockTypes {
@Nullable public static final BlockType REDSTONE_WIRE = init();
@Nullable public static final BlockType REPEATER = init();
@Nullable public static final BlockType REPEATING_COMMAND_BLOCK = init();
@Nullable public static final BlockType RESPAWN_ANCHOR = init();
@Nullable public static final BlockType ROSE_BUSH = init();
@Nullable public static final BlockType SAND = init();
@Nullable public static final BlockType SANDSTONE = init();
@ -604,6 +654,7 @@ public final class BlockTypes {
@Nullable public static final BlockType SEA_LANTERN = init();
@Nullable public static final BlockType SEA_PICKLE = init();
@Nullable public static final BlockType SEAGRASS = init();
@Nullable public static final BlockType SHROOMLIGHT = init();
@Nullable public static final BlockType SHULKER_BOX = init();
@Nullable public static final BlockType SKELETON_SKULL = init();
@Nullable public static final BlockType SKELETON_WALL_SKULL = init();
@ -623,7 +674,13 @@ public final class BlockTypes {
@Nullable public static final BlockType SMOOTH_STONE_SLAB = init();
@Nullable public static final BlockType SNOW = init();
@Nullable public static final BlockType SNOW_BLOCK = init();
@Nullable public static final BlockType SOUL_CAMPFIRE = init();
@Nullable public static final BlockType SOUL_FIRE = init();
@Nullable public static final BlockType SOUL_LANTERN = init();
@Nullable public static final BlockType SOUL_SAND = init();
@Nullable public static final BlockType SOUL_SOIL = init();
@Nullable public static final BlockType SOUL_TORCH = init();
@Nullable public static final BlockType SOUL_WALL_TORCH = init();
@Nullable public static final BlockType SPAWNER = init();
@Nullable public static final BlockType SPONGE = init();
@Nullable public static final BlockType SPRUCE_BUTTON = init();
@ -656,6 +713,8 @@ public final class BlockTypes {
@Nullable public static final BlockType STRIPPED_ACACIA_WOOD = init();
@Nullable public static final BlockType STRIPPED_BIRCH_LOG = init();
@Nullable public static final BlockType STRIPPED_BIRCH_WOOD = init();
@Nullable public static final BlockType STRIPPED_CRIMSON_HYPHAE = init();
@Nullable public static final BlockType STRIPPED_CRIMSON_STEM = init();
@Nullable public static final BlockType STRIPPED_DARK_OAK_LOG = init();
@Nullable public static final BlockType STRIPPED_DARK_OAK_WOOD = init();
@Nullable public static final BlockType STRIPPED_JUNGLE_LOG = init();
@ -664,6 +723,8 @@ public final class BlockTypes {
@Nullable public static final BlockType STRIPPED_OAK_WOOD = init();
@Nullable public static final BlockType STRIPPED_SPRUCE_LOG = init();
@Nullable public static final BlockType STRIPPED_SPRUCE_WOOD = init();
@Nullable public static final BlockType STRIPPED_WARPED_HYPHAE = init();
@Nullable public static final BlockType STRIPPED_WARPED_STEM = init();
@Nullable public static final BlockType STRUCTURE_BLOCK = init();
@Nullable public static final BlockType STRUCTURE_VOID = init();
@Nullable public static final BlockType SUGAR_CANE = init();
@ -671,6 +732,7 @@ public final class BlockTypes {
@Nullable public static final BlockType SWEET_BERRY_BUSH = init();
@Nullable public static final BlockType TALL_GRASS = init();
@Nullable public static final BlockType TALL_SEAGRASS = init();
@Nullable public static final BlockType TARGET = init();
@Nullable public static final BlockType TERRACOTTA = init();
@Nullable public static final BlockType TNT = init();
@Nullable public static final BlockType TORCH = init();
@ -682,10 +744,31 @@ public final class BlockTypes {
@Nullable public static final BlockType TUBE_CORAL_FAN = init();
@Nullable public static final BlockType TUBE_CORAL_WALL_FAN = init();
@Nullable public static final BlockType TURTLE_EGG = init();
@Nullable public static final BlockType TWISTING_VINES = init();
@Nullable public static final BlockType TWISTING_VINES_PLANT = init();
@Nullable public static final BlockType VINE = init();
@Nullable public static final BlockType VOID_AIR = init();
@Nullable public static final BlockType WALL_TORCH = init();
@Nullable public static final BlockType WARPED_BUTTON = init();
@Nullable public static final BlockType WARPED_DOOR = init();
@Nullable public static final BlockType WARPED_FENCE = init();
@Nullable public static final BlockType WARPED_FENCE_GATE = init();
@Nullable public static final BlockType WARPED_FUNGUS = init();
@Nullable public static final BlockType WARPED_HYPHAE = init();
@Nullable public static final BlockType WARPED_NYLIUM = init();
@Nullable public static final BlockType WARPED_PLANKS = init();
@Nullable public static final BlockType WARPED_PRESSURE_PLATE = init();
@Nullable public static final BlockType WARPED_ROOTS = init();
@Nullable public static final BlockType WARPED_SIGN = init();
@Nullable public static final BlockType WARPED_SLAB = init();
@Nullable public static final BlockType WARPED_STAIRS = init();
@Nullable public static final BlockType WARPED_STEM = init();
@Nullable public static final BlockType WARPED_TRAPDOOR = init();
@Nullable public static final BlockType WARPED_WALL_SIGN = init();
@Nullable public static final BlockType WARPED_WART_BLOCK = init();
@Nullable public static final BlockType WATER = init();
@Nullable public static final BlockType WEEPING_VINES = init();
@Nullable public static final BlockType WEEPING_VINES_PLANT = init();
@Nullable public static final BlockType WET_SPONGE = init();
@Nullable public static final BlockType WHEAT = init();
@Nullable public static final BlockType WHITE_BANNER = init();

View File

@ -14,5 +14,5 @@ dependencies {
"shade"("org.enginehub.piston:core:${Versions.PISTON}")
"shade"("org.enginehub.piston.core-ap:runtime:${Versions.PISTON}")
"shade"("org.enginehub.piston:default-impl:${Versions.PISTON}")
"shade"("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.61")
"shade"("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72")
}