Not all implementations support all side effects. Use + * {@link Platform#getSupportedSideEffects()} for a list of supported side effects. + * Non-supported side effects will be ignored.
+ * + * @param position position of the block + * @param block block to set + * @param sideEffects which side effects to perform + * @return true if the block was successfully set (return value may not be accurate) + */ + > boolean setBlock(BlockVector3 position, B block, SideEffectSet sideEffects) throws WorldEditException; + /** * Notifies the simulation that the block at the given location has * been changed and it must be re-lighted (and issue other events). @@ -124,7 +146,20 @@ public interface World extends Extent, Keyed, IChunkCache^*FtPQfeF;&p!YXTs3p9?U8Q0nzxqE+bM#Y7^_TmK zsw$bo4WCokyvS6N_0(KUJ2!8X|5~{<8pDd7rDt;^sCOx&=RxoN<`o-B}EwumojPl2bzq!x}k%%W5t9nTM1xeXi zQv;z_icyd<$#$rBJk9nk)8!h|c`$y~+NUVUGMRKk0aIBHQxP%YPu#d}ntgv1C_my; zpbt9K?YSK7jR%!jIUz+E3dnfbRMkv&7^h$B&oh5Ae2U {ka*7&~Z|XGk#69p1c_G1F C{&L1hn#)ZCmqpbHXC6uk;Obwn7kSJKaZ`H?u#%dz%W!fJP&`<51T`RomXjQ_%* zZ6iKVWhSW(o;7GYUuAwQxLzZTMt^H4@rorBp`tprXq9xsaKz)V<&_~zzsbGC#J2xC zQqiFYS<^~7D^Pcs?HzZm78=|`Ql?|`KIZR%#&qOMAEpStCrEMl8R0iZLR|#8%!;8p z0VGG*J(7WAxG~ij`ISsxDD--ge}1Dh3vAj>!wtQtec=#YCHNFKz$`Il6fa~c`rYYD z(xqyH;ETfFb?fK!?^*s3`))*65xs|5*^u3Snz(6t59|0kESGze=0W7f>LL{K_sC3& z*ardr??S+*s+p>{8sni`20|xZQ#^D^AQTjp`=*)izGeFN$qoSHK6K7(lg#A*T_gM( zK|#q5@BmyU)j&w qjB*=s29ufgV)YL%VJRV>@1p)anJxE7WkARdZ36Lb~f2b6Q zlm7uK{1gU}2|U1INlYN^Cl9Dh;{WL3PjQf^)PE=rpfSw?($jsQ rq#T^it69uKY15Tb~K=hm} zh{f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0>eZdon>BH(O$mACnxk3D?vSlCFFnvZ #+&hUs)Wr!aP {<@|oc^G>bJk59^xhmz!RA%|K_$o)V`D@gVs>@bSmXVID_PQXp znfja8U01+t3V!o{8ZKi~G@#q$KrAH-Ks3$G{Qo}H|N1ijJMsgZDgOmM1O$Fi0>0CX zpbAzXhYbP@PV;~=*nn7eQGjoT2b9nGFNg-PpHT$a@?7J L7I&pmkmcl S7# Y#zRYg_`D0h47O z&|%88tXNh8{Yk$@@*HA-B9r#tDkY$>!U#Ie`j1TupjRn@;(ykyyld-zJ{@qm!UG~I zxR#ZxV8CEi5JXV?ANc~bS9*;MYtkTvifc5iynmg!XpIr%SN*R#E?|3&2QVs~N02d=N!1;GdfNGr)gc$|K#-y*M=Ra9B4#cmk-naoQuS*cWnE3C4 F{|nTN-B$nr diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 4c5803d13..ac33e9944 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/gradlew b/gradlew index 2fe81a7d9..fbd7c5158 100755 --- a/gradlew +++ b/gradlew @@ -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 diff --git a/gradlew.bat b/gradlew.bat index 9109989e3..a9f778a7a 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -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% diff --git a/worldedit-core/build.gradle.kts b/worldedit-core/build.gradle.kts index f18e45a3e..5d965a63d 100644 --- a/worldedit-core/build.gradle.kts +++ b/worldedit-core/build.gradle.kts @@ -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 { diff --git a/worldedit-core/doctools/build.gradle.kts b/worldedit-core/doctools/build.gradle.kts index 0fba2e7f2..a9b2a7439 100644 --- a/worldedit-core/doctools/build.gradle.kts +++ b/worldedit-core/doctools/build.gradle.kts @@ -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 } diff --git a/worldedit-libs/core/build.gradle.kts b/worldedit-libs/core/build.gradle.kts index 128dab86c..d78841df8 100644 --- a/worldedit-libs/core/build.gradle.kts +++ b/worldedit-libs/core/build.gradle.kts @@ -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") } From d3afc9c65d4fd8137d00c45cc27d269573ae20e4 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Thu, 2 Jul 2020 14:34:05 +0100 Subject: [PATCH 07/18] Update to p2 5.12.2 and implement clear pipeline --- .../plotsquared/FaweRegionManager.java | 82 +++++++++++++++++++ .../regions/plotsquared/PlotSetBiome.java | 2 +- .../plotsquared/PlotSquaredFeature.java | 3 +- worldedit-core/build.gradle.kts | 2 +- 4 files changed, 85 insertions(+), 4 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweRegionManager.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweRegionManager.java index 7fe036c90..78da2d18b 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweRegionManager.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweRegionManager.java @@ -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.BlockState; +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 BlockState bedrock; + final BlockState air = BlockTypes.AIR.getDefaultState(); + if (hybridPlotWorld.PLOT_BEDROCK) { + bedrock = BlockTypes.BEDROCK.getDefaultState(); + } 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(() -> { diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotSetBiome.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotSetBiome.java index b0374799d..30ed06ff2 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotSetBiome.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotSetBiome.java @@ -45,7 +45,7 @@ public class PlotSetBiome extends Command { } @Override - public CompletableFuture execute(final PlotPlayer player, String[] args, RunnableVal3 confirm, RunnableVal2 whenDone) throws CommandException { + public CompletableFuture execute(final PlotPlayer> player, String[] args, RunnableVal3 confirm, RunnableVal2 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); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotSquaredFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotSquaredFeature.java index 02242021e..e51494aed 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotSquaredFeature.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotSquaredFeature.java @@ -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; diff --git a/worldedit-core/build.gradle.kts b/worldedit-core/build.gradle.kts index 5d965a63d..41dac87ff 100644 --- a/worldedit-core/build.gradle.kts +++ b/worldedit-core/build.gradle.kts @@ -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")) From b58877a57b3998fe9bb2e0579acac16bb553e1c4 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Thu, 2 Jul 2020 14:51:09 +0100 Subject: [PATCH 08/18] Use BlockType not BlockState --- .../bukkit/regions/plotsquared/FaweRegionManager.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweRegionManager.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweRegionManager.java index 78da2d18b..4660c20e4 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweRegionManager.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweRegionManager.java @@ -29,7 +29,7 @@ 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.BlockState; +import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; import java.io.File; @@ -98,10 +98,10 @@ public class FaweRegionManager extends RegionManager { 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 BlockState bedrock; - final BlockState air = BlockTypes.AIR.getDefaultState(); + final BlockType bedrock; + final BlockType air = BlockTypes.AIR; if (hybridPlotWorld.PLOT_BEDROCK) { - bedrock = BlockTypes.BEDROCK.getDefaultState(); + bedrock = BlockTypes.BEDROCK; } else { bedrock = air; } From 18c9da372c8e3ab3f27e1fd053c80592a5dc2753 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Thu, 2 Jul 2020 18:16:15 +0100 Subject: [PATCH 09/18] GetBlocks should default to air not reserved --- .../bukkit/adapter/mc1_14/BukkitGetBlocks_1_14.java | 5 ++++- .../adapter/mc1_15_2/BukkitGetBlocks_1_15_2.java | 5 ++++- .../adapter/mc1_16_1/BukkitGetBlocks_1_16_1.java | 5 ++++- .../beta/implementation/blocks/CharGetBlocks.java | 12 ++++++++++-- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BukkitGetBlocks_1_14.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BukkitGetBlocks_1_14.java index ae871b419..c2c4395d1 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BukkitGetBlocks_1_14.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BukkitGetBlocks_1_14.java @@ -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) { diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitGetBlocks_1_15_2.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitGetBlocks_1_15_2.java index e0cbf7266..e77c06f85 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitGetBlocks_1_15_2.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitGetBlocks_1_15_2.java @@ -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) { diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitGetBlocks_1_16_1.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitGetBlocks_1_16_1.java index d6dada109..d09240f6c 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitGetBlocks_1_16_1.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitGetBlocks_1_16_1.java @@ -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) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharGetBlocks.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharGetBlocks.java index f38d1bae4..fc2b72b96 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharGetBlocks.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharGetBlocks.java @@ -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) { + return new char[4096]; + } + Arrays.fill(data, (char) 1); + return data; + } + @Override public boolean trim(boolean aggressive, int layer) { sections[layer] = EMPTY; From f1d41044804c044d17a44db95332796f6f768569 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Thu, 2 Jul 2020 22:09:12 +0100 Subject: [PATCH 10/18] Bunch of changes to help masks --- .../adapter/mc1_14/BukkitGetBlocks_1_14.java | 12 ++++++++++++ .../adapter/mc1_15_2/BukkitGetBlocks_1_15_2.java | 12 ++++++++++++ .../adapter/mc1_16_1/BukkitGetBlocks_1_16_1.java | 12 ++++++++++++ .../beta/implementation/blocks/CharGetBlocks.java | 2 +- .../sk89q/worldedit/function/mask/BlockMask.java | 2 +- .../mask/InverseSingleBlockStateMask.java | 15 ++++++++++++--- .../function/mask/SingleBlockTypeMask.java | 2 +- 7 files changed, 51 insertions(+), 6 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BukkitGetBlocks_1_14.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BukkitGetBlocks_1_14.java index c2c4395d1..0f5d33fe0 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BukkitGetBlocks_1_14.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BukkitGetBlocks_1_14.java @@ -609,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; @@ -636,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 { diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitGetBlocks_1_15_2.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitGetBlocks_1_15_2.java index e77c06f85..4518420a2 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitGetBlocks_1_15_2.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitGetBlocks_1_15_2.java @@ -629,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 { @@ -654,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 { diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitGetBlocks_1_16_1.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitGetBlocks_1_16_1.java index d09240f6c..2d5ace231 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitGetBlocks_1_16_1.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitGetBlocks_1_16_1.java @@ -600,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 { @@ -625,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 { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharGetBlocks.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharGetBlocks.java index fc2b72b96..9f3fd88a8 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharGetBlocks.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharGetBlocks.java @@ -27,7 +27,7 @@ public abstract class CharGetBlocks extends CharBlocks implements IChunkGet { public char[] update(int layer, char[] data) { if (data == null) { - return new char[4096]; + data = new char[4096]; } Arrays.fill(data, (char) 1); return data; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java index e13026ba7..31259f5dd 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java @@ -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 diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/InverseSingleBlockStateMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/InverseSingleBlockStateMask.java index 0f0ddb907..18812adac 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/InverseSingleBlockStateMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/InverseSingleBlockStateMask.java @@ -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 diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SingleBlockTypeMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SingleBlockTypeMask.java index 466f51c7e..d21eaf28d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SingleBlockTypeMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SingleBlockTypeMask.java @@ -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 From fae528ab64dca14dc7435b6ae411c98995825d10 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Fri, 3 Jul 2020 13:18:09 +0100 Subject: [PATCH 11/18] add a couple more changes++ Fixes #508 --- .../fawe/beta/implementation/queue/ParallelQueueExtent.java | 4 +++- .../src/main/java/com/sk89q/worldedit/EditSession.java | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/ParallelQueueExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/ParallelQueueExtent.java index b68207afe..bab16d39a 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/ParallelQueueExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/ParallelQueueExtent.java @@ -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; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java index e3e38757c..b3679aacb 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -2756,6 +2756,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); } From 63bc151f6cb8fea47dc17f9039ceae3296ecb291 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Fri, 3 Jul 2020 13:27:26 +0100 Subject: [PATCH 12/18] Hopefully allow for unloaded world to be referenced after GC. Possibly fixes #504 --- .../com/sk89q/worldedit/bukkit/BukkitWorld.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java index 588071c34..bdfcf27d0 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java @@ -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 worldRef; + private WeakReference 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); @@ -150,7 +154,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"); } /** From ea7897934f93243764ac8e4566e0475557bdf68e Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Fri, 3 Jul 2020 13:49:17 +0100 Subject: [PATCH 13/18] Implement ability to use -w flag on //drain fixes #464 --- .../java/com/sk89q/worldedit/EditSession.java | 15 ++++++++------- .../function/pattern/WaterloggedRemover.java | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java index b3679aacb..ce1b78f05 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -63,6 +63,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; @@ -135,6 +136,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,13 +1626,12 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { 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); + Mask liquidMask = new BlockTypeMask(this, BlockTypes.LAVA, BlockTypes.WATER); + if (waterlogged) { + Map 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))), diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/WaterloggedRemover.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/WaterloggedRemover.java index 886706f08..a8610b80d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/WaterloggedRemover.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/WaterloggedRemover.java @@ -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; From 28128414815959079496eb9833383d335cebe37d Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Fri, 3 Jul 2020 14:01:16 +0100 Subject: [PATCH 14/18] Add -p flag to //drain to allow kelp and watergrass to be removed. properly fixed #464 --- .../java/com/sk89q/worldedit/EditSession.java | 22 ++++++++++++++++++- .../worldedit/command/UtilityCommands.java | 6 +++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java index ce1b78f05..f309f27a3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -1623,10 +1623,30 @@ 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 = new BlockTypeMask(this, BlockTypes.LAVA, BlockTypes.WATER); + Mask liquidMask; + 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 stateMap = new HashMap<>(); stateMap.put("waterlogged", "true"); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java index 58e20bc6c..b320dc300 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java @@ -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; } From 9e25c736a0156d451d8f6096dbfbfbfc39790401 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Fri, 3 Jul 2020 14:12:43 +0100 Subject: [PATCH 15/18] Add new blocks to BlockTypes --- .../worldedit/world/block/BlockTypes.java | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java index a2e73ae26..e38247c68 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java @@ -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(); From f7d375c76ce5b504d4d361f594ab4dd4fa96f5f9 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Fri, 3 Jul 2020 16:29:27 +0100 Subject: [PATCH 16/18] Lazy heightmap range fix --- .../com/sk89q/worldedit/math/convolution/HeightMap.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java index 432445223..ea4d57ff3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java @@ -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; From e2ab87cc073e7d2f52573902566747451d0c4cf1 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Fri, 3 Jul 2020 16:45:28 +0100 Subject: [PATCH 17/18] lazy //deform AIOOB fix. Fixes #495 --- .../src/main/java/com/sk89q/worldedit/EditSession.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java index f309f27a3..6905ce17f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -2506,8 +2506,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); } From 77204df3f06b8bf512178e23512bb392212f7586 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Fri, 3 Jul 2020 16:56:20 +0100 Subject: [PATCH 18/18] prevent players being teleported down a single block after some edits --- .../extension/platform/AbstractPlayerActor.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java index 040c5bb74..4419f34f6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java @@ -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;