From 4a767926c1ddaed7c9dc48f3024820790f1c2a9c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 27 Mar 2024 21:58:06 +0000 Subject: [PATCH 01/90] Update dependency io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin to v1.5.12 --- buildSrc/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index e4227d576..878f1b845 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -24,7 +24,7 @@ dependencies { implementation(gradleApi()) implementation("org.ajoberstar.grgit:grgit-gradle:5.2.2") implementation("com.github.johnrengelman:shadow:8.1.1") - implementation("io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin:1.5.11") + implementation("io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin:1.5.12") } kotlin { From b60a0c532c6b76d9b943a5f19a9cfca211242845 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 29 Mar 2024 19:56:45 +0000 Subject: [PATCH 02/90] Update dependency paperweight-userdev to v1.20.4-R0.1-20240329.175742-144 --- worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts b/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts index d55d44a76..3e2bbe382 100644 --- a/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts +++ b/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts @@ -12,6 +12,6 @@ repositories { dependencies { // url=https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/1.20.4-R0.1-SNAPSHOT - the().paperDevBundle("1.20.4-R0.1-20240325.123556-143") + the().paperDevBundle("1.20.4-R0.1-20240329.175742-144") compileOnly(libs.paperlib) } From 23bcdb0409e46f59776526946e7121f4e37c10bf Mon Sep 17 00:00:00 2001 From: Jordan Date: Sat, 30 Mar 2024 10:31:52 +0100 Subject: [PATCH 03/90] fix: introduce approx size to patterns and use in ScatterBrush (#2631) * fix: introduce approx size to patterns and use in ScatterBrush - fixes #2610 * Do not use patternsize in blockvectorset offset --- .../core/command/tool/brush/ScatterBrush.java | 34 +++++++- .../core/command/tool/brush/ShatterBrush.java | 5 +- .../core/function/pattern/OffsetPattern.java | 7 ++ .../pattern/RandomFullClipboardPattern.java | 16 ++++ .../function/pattern/RandomOffsetPattern.java | 5 ++ .../pattern/SurfaceRandomOffsetPattern.java | 5 ++ .../core/math/BlockVectorSet.java | 43 +++++++++++ .../core/math/LocalBlockVectorSet.java | 31 ++------ .../core/math/MutableBlockVector3.java | 16 ++++ .../core/util/collection/BlockVector3Set.java | 77 +++++++++++++++---- .../worldedit/function/pattern/Pattern.java | 11 +++ 11 files changed, 208 insertions(+), 42 deletions(-) diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/ScatterBrush.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/ScatterBrush.java index 7ea15e421..5e6c9ac52 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/ScatterBrush.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/ScatterBrush.java @@ -5,6 +5,7 @@ import com.fastasyncworldedit.core.function.mask.RadiusMask; import com.fastasyncworldedit.core.function.mask.SurfaceMask; import com.fastasyncworldedit.core.math.BlockVectorSet; import com.fastasyncworldedit.core.math.LocalBlockVectorSet; +import com.fastasyncworldedit.core.util.collection.BlockVector3Set; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.command.tool.brush.Brush; @@ -64,8 +65,9 @@ public class ScatterBrush implements Brush { length = 1; visited.add(position); } - LocalBlockVectorSet placed = new LocalBlockVectorSet(); - placed.setOffset(position.getX(), position.getZ()); + BlockVector3 patternSize = pattern.size(); + BlockVector3Set placed = BlockVector3Set.getAppropriateVectorSet(patternSize.add(distance, distance, distance)); + placed.setOffset(position.getX(), position.getY(), position.getZ()); int maxFails = 1000; for (int i = 0; i < count; i++) { int index = ThreadLocalRandom.current().nextInt(length); @@ -88,7 +90,20 @@ public class ScatterBrush implements Brush { finish(editSession, placed, position, pattern, size); } + /** + * @deprecated Use {@link ScatterBrush#finish(EditSession, BlockVector3Set, BlockVector3, Pattern, double)} + */ + @Deprecated(forRemoval = true, since = "TODO") public void finish(EditSession editSession, LocalBlockVectorSet placed, BlockVector3 pos, Pattern pattern, double size) { + finish(editSession, (BlockVector3Set) placed, pos, pattern, size); + } + + /** + * Complete the scatter brush process. + * + * @since TODO + */ + public void finish(EditSession editSession, BlockVector3Set placed, BlockVector3 pos, Pattern pattern, double size) { } public boolean canApply(BlockVector3 pos) { @@ -99,8 +114,23 @@ public class ScatterBrush implements Brush { return surface.direction(pt); } + + /** + * @deprecated Use {@link ScatterBrush#apply(EditSession, BlockVector3Set, BlockVector3, Pattern, double)} + */ + @Deprecated(forRemoval = true, since = "TODO") public void apply(EditSession editSession, LocalBlockVectorSet placed, BlockVector3 pt, Pattern p, double size) throws MaxChangedBlocksException { + apply(editSession, (BlockVector3Set) placed, pt, p, size); + } + + /** + * Apply the scatter brush to a given position + * + * @since TODO + */ + public void apply(EditSession editSession, BlockVector3Set placed, BlockVector3 pt, Pattern p, double size) throws + MaxChangedBlocksException { editSession.setBlock(pt, p); } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/ShatterBrush.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/ShatterBrush.java index 58fdb4997..41b36e12c 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/ShatterBrush.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/ShatterBrush.java @@ -3,6 +3,7 @@ package com.fastasyncworldedit.core.command.tool.brush; import com.fastasyncworldedit.core.function.mask.SurfaceMask; import com.fastasyncworldedit.core.math.LocalBlockVectorSet; import com.fastasyncworldedit.core.math.MutableBlockVector3; +import com.fastasyncworldedit.core.util.collection.BlockVector3Set; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.function.mask.Mask; @@ -24,7 +25,7 @@ public class ShatterBrush extends ScatterBrush { @Override public void apply( final EditSession editSession, - final LocalBlockVectorSet placed, + final BlockVector3Set placed, final BlockVector3 position, Pattern p, double size @@ -34,7 +35,7 @@ public class ShatterBrush extends ScatterBrush { @Override public void finish( EditSession editSession, - LocalBlockVectorSet placed, + BlockVector3Set placed, final BlockVector3 position, Pattern pattern, double size diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/OffsetPattern.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/OffsetPattern.java index 628b848e8..9a5ca2ceb 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/OffsetPattern.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/OffsetPattern.java @@ -60,6 +60,13 @@ public class OffsetPattern extends AbstractPattern { return pattern.apply(extent, get, mutable); } + @Override + public BlockVector3 size() { + // Not exactly the "size" but offset should be taken into consideration in most + // places where the "size" matters + return BlockVector3.at(dx, dy, dz); + } + @Override public Pattern fork() { return new OffsetPattern(this.pattern.fork(), this.dx, this.dy, this.dz, this.minY, this.maxY); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/RandomFullClipboardPattern.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/RandomFullClipboardPattern.java index 52348780b..957cf2617 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/RandomFullClipboardPattern.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/RandomFullClipboardPattern.java @@ -1,7 +1,9 @@ package com.fastasyncworldedit.core.function.pattern; +import com.fastasyncworldedit.core.math.MutableBlockVector3; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.function.pattern.AbstractPattern; import com.sk89q.worldedit.function.pattern.Pattern; @@ -9,6 +11,8 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.transform.AffineTransform; import com.sk89q.worldedit.math.transform.Transform; +import com.sk89q.worldedit.regions.CuboidRegion; +import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.world.block.BaseBlock; @@ -23,6 +27,7 @@ public class RandomFullClipboardPattern extends AbstractPattern { private final boolean randomRotate; private final boolean randomFlip; private final Vector3 flipVector = Vector3.at(1, 0, 0).multiply(-2).add(1, 1, 1); + private final BlockVector3 size; /** * Create a new {@link Pattern} instance @@ -34,6 +39,12 @@ public class RandomFullClipboardPattern extends AbstractPattern { public RandomFullClipboardPattern(List clipboards, boolean randomRotate, boolean randomFlip) { checkNotNull(clipboards); this.clipboards = clipboards; + MutableBlockVector3 mut = new MutableBlockVector3(); + clipboards.stream().flatMap(c -> c.getClipboards().stream()).map(c -> { + Region region = c.getRegion(); + return region.getMaximumPoint().subtract(c.getOrigin().getMinimum(region.getMinimumPoint())); + }).forEach(mut::getMaximum); + this.size = mut.toImmutable(); this.randomRotate = randomRotate; this.randomFlip = randomFlip; } @@ -66,4 +77,9 @@ public class RandomFullClipboardPattern extends AbstractPattern { throw new IllegalStateException("Incorrect use. This pattern can only be applied to an extent!"); } + @Override + public BlockVector3 size() { + return size; + } + } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/RandomOffsetPattern.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/RandomOffsetPattern.java index c0afd02e3..c68bb24b1 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/RandomOffsetPattern.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/RandomOffsetPattern.java @@ -72,6 +72,11 @@ public class RandomOffsetPattern extends AbstractPattern { return pattern.apply(extent, get, mutable); } + @Override + public BlockVector3 size() { + return BlockVector3.at(dx2, dy2, dz2); + } + @Override public Pattern fork() { return new RandomOffsetPattern(this.pattern.fork(), this.dx, this.dy, this.dz, this.minY, this.maxY); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/SurfaceRandomOffsetPattern.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/SurfaceRandomOffsetPattern.java index 34866fc54..03e3126be 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/SurfaceRandomOffsetPattern.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/SurfaceRandomOffsetPattern.java @@ -129,6 +129,11 @@ public class SurfaceRandomOffsetPattern extends AbstractPattern { return !block.getBlockType().getMaterial().isMovementBlocker(); } + @Override + public BlockVector3 size() { + return BlockVector3.at(moves, moves, moves); + } + @Override public Pattern fork() { return new SurfaceRandomOffsetPattern(this.pattern.fork(), this.moves, this.minY, this.maxY); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/BlockVectorSet.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/BlockVectorSet.java index e904244de..67aeadec8 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/BlockVectorSet.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/BlockVectorSet.java @@ -78,6 +78,49 @@ public class BlockVectorSet extends AbstractCollection implements return localMap != null && localMap.contains(x & 2047, ((y + 128) & 511) - 128, z & 2047); } + @Override + public void setOffset(final int x, final int z) { + // Do nothing + } + + @Override + public void setOffset(final int x, final int y, final int z) { + // Do nothing + } + + @Override + public boolean containsRadius(final int x, final int y, final int z, final int radius) { + if (radius <= 0) { + return contains(x, y, z); + } + // Quick corners check + if (!contains(x - radius, y, z - radius)) { + return false; + } + if (!contains(x + radius, y, z + radius)) { + return false; + } + if (!contains(x - radius, y, z + radius)) { + return false; + } + if (!contains(x + radius, y, z - radius)) { + return false; + } + // Slow but if someone wants to think of an elegant way then feel free to add it + for (int xx = -radius; xx <= radius; xx++) { + int rx = x + xx; + for (int yy = -radius; yy <= radius; yy++) { + int ry = y + yy; + for (int zz = -radius; zz <= radius; zz++) { + if (contains(rx, ry, z + zz)) { + return true; + } + } + } + } + return false; + } + @Override public boolean contains(Object o) { if (o instanceof BlockVector3 v) { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/LocalBlockVectorSet.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/LocalBlockVectorSet.java index 8e6cdabe8..2ed3a2f63 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/LocalBlockVectorSet.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/LocalBlockVectorSet.java @@ -100,14 +100,7 @@ public class LocalBlockVectorSet implements BlockVector3Set { return new LocalBlockVectorSet(offsetX, offsetY, offsetZ, set.clone()); } - /** - * If a radius is contained by the set - * - * @param x x radius center - * @param y y radius center - * @param z z radius center - * @return if radius is contained by the set - */ + @Override public boolean containsRadius(int x, int y, int z, int radius) { if (radius <= 0) { return contains(x, y, z); @@ -130,9 +123,11 @@ public class LocalBlockVectorSet implements BlockVector3Set { return false; } for (int xx = -radius; xx <= radius; xx++) { + int rx = x + xx; for (int yy = -radius; yy <= radius; yy++) { + int ry = y + yy; for (int zz = -radius; zz <= radius; zz++) { - if (contains(x + xx, y + yy, z + zz)) { + if (contains(rx, ry, z + zz)) { return true; } } @@ -141,27 +136,13 @@ public class LocalBlockVectorSet implements BlockVector3Set { return false; } - /** - * Set the offset applied to values when storing and reading to keep the values within -1024 to 1023. Uses default y offset - * of 128 to allow -64 -> 320 world height use. - * - * @param x x offset - * @param z z offset - */ + @Override public void setOffset(int x, int z) { this.offsetX = x; this.offsetZ = z; } - /** - * Set the offset applied to values when storing and reading to keep the x and z values within -1024 to 1023. Y values - * require keeping withing -256 and 255. - * - * @param x x offset - * @param y y offset - * @param z z offset - * @since 2.2.0 - */ + @Override public void setOffset(int x, int y, int z) { this.offsetX = x; this.offsetY = y; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/MutableBlockVector3.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/MutableBlockVector3.java index baa20163f..6ebabae1d 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/MutableBlockVector3.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/MutableBlockVector3.java @@ -61,6 +61,22 @@ public class MutableBlockVector3 extends BlockVector3 { return z; } + @Override + public BlockVector3 getMinimum(BlockVector3 v2) { + this.x = Math.min(v2.getX(), x); + this.y = Math.min(v2.getY(), y); + this.z = Math.min(v2.getZ(), z); + return this; + } + + @Override + public BlockVector3 getMaximum(BlockVector3 v2) { + this.x = Math.max(v2.getX(), x); + this.y = Math.max(v2.getY(), y); + this.z = Math.max(v2.getZ(), z); + return this; + } + @Override public MutableBlockVector3 mutX(double x) { this.x = (int) x; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/BlockVector3Set.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/BlockVector3Set.java index 881aaf9f3..83a639ead 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/BlockVector3Set.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/BlockVector3Set.java @@ -9,29 +9,80 @@ import java.util.Set; public interface BlockVector3Set extends Set { + /** + * Get the appropriate {@link BlockVector3Set} implementation for the given region. Either {@link LocalBlockVectorSet} or + * {@link BlockVectorSet}. Sets the offset if using {@link LocalBlockVectorSet}. + * + * @param region Region to get for + * @return Appropriate {@link BlockVector3Set} implementation + */ static BlockVector3Set getAppropriateVectorSet(Region region) { BlockVector3 max = region.getMaximumPoint(); BlockVector3 min = region.getMinimumPoint(); - BlockVector3 size = region.getDimensions(); + BlockVector3Set set = getAppropriateVectorSet(region.getDimensions()); + // Set default offset as many operations utilising a region are likely to start in a corner, this initialising the + // LocalBlockVectorSet poorly + // This needs to be ceiling as LocalBlockVector extends 1 block further "negative" + int offsetX = (int) Math.ceil((min.getX() + max.getX()) / 2d); + int offsetZ = (int) Math.ceil((min.getZ() + max.getZ()) / 2d); + int offsetY; + if (region.getMinimumY() < -128 || region.getMaximumY() > 320) { + offsetY = (min.getY() + max.getY()) / 2; + } else { + offsetY = 128; + } + set.setOffset(offsetX, offsetY, offsetZ); + return set; + } + + /** + * Get the appropriate {@link BlockVector3Set} implementation for the given dimensions. Either {@link LocalBlockVectorSet} or + * {@link BlockVectorSet}. The offset should be manually set. + * + * @param size Dimensions to get for + * @return Appropriate {@link BlockVector3Set} implementation + */ + static BlockVector3Set getAppropriateVectorSet(BlockVector3 size) { if (size.getBlockX() > 2048 || size.getBlockZ() > 2048 || size.getBlockY() > 512) { return new BlockVectorSet(); } else { - // Set default offset as many operations utilising a region are likely to start in a corner, this initialising the - // LocalBlockVectorSet poorly - // This needs to be ceiling as LocalBlockVector extends 1 block further "negative" - int offsetX = (int) Math.ceil((min.getX() + max.getX()) / 2d); - int offsetZ = (int) Math.ceil((min.getZ() + max.getZ()) / 2d); - int offsetY; - if (region.getMinimumY() < -128 || region.getMaximumY() > 320) { - offsetY = (min.getY() + max.getY()) / 2; - } else { - offsetY = 128; - } - return new LocalBlockVectorSet(offsetX, offsetY, offsetZ); + return new LocalBlockVectorSet(); } } boolean add(int x, int y, int z); boolean contains(int x, int y, int z); + /** + * Set the offset applied to values when storing and reading to keep the values within -1024 to 1023. Uses default y offset + * of 128 to allow -64 -> 320 world height use. + * + * @param x x offset + * @param z z offset + * @since TODO + */ + void setOffset(int x, int z); + + /** + * Set the offset applied to values when storing and reading to keep the x and z values within -1024 to 1023. Y values + * require keeping withing -256 and 255. + * + * @param x x offset + * @param y y offset + * @param z z offset + * @since TODO + */ + void setOffset(int x, int y, int z); + + /** + * If a radius is contained by the set + * + * @param x x radius center + * @param y y radius center + * @param z z radius center + * @return if radius is contained by the set + * @since TODO + */ + boolean containsRadius(int x, int y, int z, int radius); + } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/Pattern.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/Pattern.java index ab284c0cf..e44a1c19d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/Pattern.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/Pattern.java @@ -25,6 +25,7 @@ import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.internal.util.NonAbstractForCompatibility; import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.world.block.BaseBlock; /** @@ -74,4 +75,14 @@ public interface Pattern extends Filter { */ BaseBlock applyBlock(BlockVector3 position); + /** + * Get the likely maximum size of the volume this pattern will affect + * + * @return Pattern size + * @since TODO + */ + default BlockVector3 size() { + return BlockVector3.ONE; + } + } From 673233c777f5637cfad37412b62563bf6fa347ca Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 30 Mar 2024 09:33:30 +0000 Subject: [PATCH 04/90] Update dependency com.palmergames.bukkit.towny:towny to v0.100.1.24 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 85d7a18c8..8862924f5 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -14,7 +14,7 @@ mapmanager = "1.8.0-SNAPSHOT" griefprevention = "17.0.0" griefdefender = "2.1.0-SNAPSHOT" residence = "4.5._13.1" -towny = "0.100.1.23" +towny = "0.100.1.24" plotsquared = "7.3.6" # Third party From 628d894244282ffa4e6a9d2600bd2c8050f6bf22 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 31 Mar 2024 04:21:01 +0000 Subject: [PATCH 05/90] Update piston to v0.5.9 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 8862924f5..5d66014f2 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -43,7 +43,7 @@ serverlib = "2.3.4" ## Internal text-adapter = "3.0.6" text = "3.0.4" -piston = "0.5.8" +piston = "0.5.9" # Tests mockito = "5.11.0" From 91b4393190d6ec51f08dc871ad5b505e5020e374 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 31 Mar 2024 19:27:29 +0000 Subject: [PATCH 06/90] Update piston to v0.5.10 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 5d66014f2..f6d16d21d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -43,7 +43,7 @@ serverlib = "2.3.4" ## Internal text-adapter = "3.0.6" text = "3.0.4" -piston = "0.5.9" +piston = "0.5.10" # Tests mockito = "5.11.0" From af547e072c0d8bc78fbcd667d5bc411ebfaf24b7 Mon Sep 17 00:00:00 2001 From: Alexander Brandes Date: Mon, 1 Apr 2024 12:34:19 +0200 Subject: [PATCH 07/90] List FAWE class additions in Javadocs (#2659) * List FAWE class additions in Javadocs Signed-off-by: Alexander Brandes * Update worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/package-info.java --------- Signed-off-by: Alexander Brandes --- .../com/sk89q/worldedit/cli/package-info.java | 2 +- .../command/argument/package-info.java | 4 ++-- .../sk89q/worldedit/command/package-info.java | 2 +- .../command/util/annotation/package-info.java | 18 +++++++++--------- .../function/operation/package-info.java | 2 +- .../worldedit/world/block/package-info.java | 2 +- .../worldedit/world/chunk/package-info.java | 4 ++-- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/worldedit-cli/src/main/java/com/sk89q/worldedit/cli/package-info.java b/worldedit-cli/src/main/java/com/sk89q/worldedit/cli/package-info.java index 11ccf05d1..60e756259 100644 --- a/worldedit-cli/src/main/java/com/sk89q/worldedit/cli/package-info.java +++ b/worldedit-cli/src/main/java/com/sk89q/worldedit/cli/package-info.java @@ -1,6 +1,6 @@ /** * The following classes are FAWE additions: * - * @see com.sk89q.worldedit.cli.AccessPoint + * {@link com.sk89q.worldedit.cli.AccessPoint} */ package com.sk89q.worldedit.cli; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/package-info.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/package-info.java index 270468aa1..d1bd7bbd3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/package-info.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/package-info.java @@ -20,8 +20,8 @@ /** * The following classes are FAWE additions: * - * @see com.sk89q.worldedit.command.argument.ExpressionConverter - * @see com.sk89q.worldedit.command.argument.LocationConverter + * {@link com.sk89q.worldedit.command.argument.ExpressionConverter}, + * {@link com.sk89q.worldedit.command.argument.LocationConverter} */ @org.enginehub.piston.util.NonnullByDefault package com.sk89q.worldedit.command.argument; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/package-info.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/package-info.java index 61d4ea41d..4ffda131d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/package-info.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/package-info.java @@ -1,6 +1,6 @@ /** * The following classes are FAWE additions: * - * @see com.sk89q.worldedit.command.HistorySubCommands + * {@link com.sk89q.worldedit.command.HistorySubCommands} */ package com.sk89q.worldedit.command; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/package-info.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/package-info.java index dc15d98d6..006432a73 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/package-info.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/package-info.java @@ -1,14 +1,14 @@ /** * The following classes are FAWE additions: * - * @see com.sk89q.worldedit.command.util.annotation.AllowedRegion - * @see com.sk89q.worldedit.command.util.annotation.Confirm - * @see com.sk89q.worldedit.command.util.annotation.ConfirmHandler - * @see com.sk89q.worldedit.command.util.annotation.Link - * @see com.sk89q.worldedit.command.util.annotation.PatternList - * @see com.sk89q.worldedit.command.util.annotation.Preload - * @see com.sk89q.worldedit.command.util.annotation.PreloadHandler - * @see com.sk89q.worldedit.command.util.annotation.Step - * @see com.sk89q.worldedit.command.util.annotation.Time + * {@link com.sk89q.worldedit.command.util.annotation.AllowedRegion}, + * {@link com.sk89q.worldedit.command.util.annotation.Confirm}, + * {@link com.sk89q.worldedit.command.util.annotation.ConfirmHandler}, + * {@link com.sk89q.worldedit.command.util.annotation.Link}, + * {@link com.sk89q.worldedit.command.util.annotation.PatternList}, + * {@link com.sk89q.worldedit.command.util.annotation.Preload}, + * {@link com.sk89q.worldedit.command.util.annotation.PreloadHandler}, + * {@link com.sk89q.worldedit.command.util.annotation.Step}, + * {@link com.sk89q.worldedit.command.util.annotation.Time} */ package com.sk89q.worldedit.command.util.annotation; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/package-info.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/package-info.java index 5b9eb7485..13a3d4e7c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/package-info.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/package-info.java @@ -1,6 +1,6 @@ /** * The following classes are FAWE additions: * - * @see com.sk89q.worldedit.function.operation.BackwardsExtentBlockCopy + * {@link com.sk89q.worldedit.function.operation.BackwardsExtentBlockCopy} */ package com.sk89q.worldedit.function.operation; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/package-info.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/package-info.java index b8e54bc04..46a6490c9 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/package-info.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/package-info.java @@ -1,6 +1,6 @@ /** * The following classes are FAWE additions: * - * @see com.sk89q.worldedit.world.block.BlockTypesCache + * {@link com.sk89q.worldedit.world.block.BlockTypesCache} */ package com.sk89q.worldedit.world.block; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/package-info.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/package-info.java index ecb29c521..5ec273554 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/package-info.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/package-info.java @@ -1,7 +1,7 @@ /** * The following classes are FAWE additions: * - * @see com.sk89q.worldedit.world.chunk.AnvilChunk15 - * @see com.sk89q.worldedit.world.chunk.AnvilChunk17 + * {@link com.sk89q.worldedit.world.chunk.AnvilChunk15}, + * {@link com.sk89q.worldedit.world.chunk.AnvilChunk17} */ package com.sk89q.worldedit.world.chunk; From 4ac3f5ba1a2d4e3bace137913f1640ae1e450c24 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 2 Apr 2024 09:32:10 +0000 Subject: [PATCH 08/90] Update dependency com.palmergames.bukkit.towny:towny to v0.100.2.0 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index f6d16d21d..f1c25e764 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -14,7 +14,7 @@ mapmanager = "1.8.0-SNAPSHOT" griefprevention = "17.0.0" griefdefender = "2.1.0-SNAPSHOT" residence = "4.5._13.1" -towny = "0.100.1.24" +towny = "0.100.2.0" plotsquared = "7.3.6" # Third party From 778c212e853b6c08c8ce65b2e1af9fb17c6d9dde Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 2 Apr 2024 14:08:53 +0000 Subject: [PATCH 09/90] Update dependency paperweight-userdev to v1.20.4-R0.1-20240402.103709-145 --- worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts b/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts index 3e2bbe382..e4539cd79 100644 --- a/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts +++ b/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts @@ -12,6 +12,6 @@ repositories { dependencies { // url=https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/1.20.4-R0.1-SNAPSHOT - the().paperDevBundle("1.20.4-R0.1-20240329.175742-144") + the().paperDevBundle("1.20.4-R0.1-20240402.103709-145") compileOnly(libs.paperlib) } From 5e10c98915795206be8cacf3dd2a3b46f3412786 Mon Sep 17 00:00:00 2001 From: Alexander Brandes Date: Thu, 4 Apr 2024 21:56:07 +0200 Subject: [PATCH 10/90] Release 2.9.2 Signed-off-by: Alexander Brandes --- build.gradle.kts | 2 +- .../core/command/tool/brush/ScatterBrush.java | 8 ++++---- .../fastasyncworldedit/core/extent/TransformExtent.java | 2 +- .../core/function/pattern/Linear2DBlockPattern.java | 2 +- .../core/function/pattern/Linear3DBlockPattern.java | 2 +- .../core/math/random/Linear2DRandom.java | 2 +- .../core/math/random/Linear3DRandom.java | 2 +- .../core/util/collection/BlockVector3Set.java | 6 +++--- .../com/sk89q/worldedit/function/pattern/Pattern.java | 2 +- .../worldedit/regions/selector/RegionSelectorType.java | 2 +- 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 15845439a..8c2685561 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -52,7 +52,7 @@ ext { } } -version = String.format("%s-%s", rootVersion, buildNumber) +version = String.format("%s", rootVersion) if (!project.hasProperty("gitCommitHash")) { apply(plugin = "org.ajoberstar.grgit") diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/ScatterBrush.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/ScatterBrush.java index 5e6c9ac52..e14d0c599 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/ScatterBrush.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/ScatterBrush.java @@ -93,7 +93,7 @@ public class ScatterBrush implements Brush { /** * @deprecated Use {@link ScatterBrush#finish(EditSession, BlockVector3Set, BlockVector3, Pattern, double)} */ - @Deprecated(forRemoval = true, since = "TODO") + @Deprecated(forRemoval = true, since = "2.9.2") public void finish(EditSession editSession, LocalBlockVectorSet placed, BlockVector3 pos, Pattern pattern, double size) { finish(editSession, (BlockVector3Set) placed, pos, pattern, size); } @@ -101,7 +101,7 @@ public class ScatterBrush implements Brush { /** * Complete the scatter brush process. * - * @since TODO + * @since 2.9.2 */ public void finish(EditSession editSession, BlockVector3Set placed, BlockVector3 pos, Pattern pattern, double size) { } @@ -118,7 +118,7 @@ public class ScatterBrush implements Brush { /** * @deprecated Use {@link ScatterBrush#apply(EditSession, BlockVector3Set, BlockVector3, Pattern, double)} */ - @Deprecated(forRemoval = true, since = "TODO") + @Deprecated(forRemoval = true, since = "2.9.2") public void apply(EditSession editSession, LocalBlockVectorSet placed, BlockVector3 pt, Pattern p, double size) throws MaxChangedBlocksException { apply(editSession, (BlockVector3Set) placed, pt, p, size); @@ -127,7 +127,7 @@ public class ScatterBrush implements Brush { /** * Apply the scatter brush to a given position * - * @since TODO + * @since 2.9.2 */ public void apply(EditSession editSession, BlockVector3Set placed, BlockVector3 pt, Pattern p, double size) throws MaxChangedBlocksException { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/TransformExtent.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/TransformExtent.java index 64b940d97..250227439 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/TransformExtent.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/TransformExtent.java @@ -15,7 +15,7 @@ import com.sk89q.worldedit.world.block.BlockStateHolder; /** * @deprecated Unused internal, will be removed in v3 */ -@Deprecated(forRemoval = true, since = "TODO") +@Deprecated(forRemoval = true, since = "2.9.2") public class TransformExtent extends BlockTransformExtent { private final MutableVector3 mutable1 = new MutableVector3(); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/Linear2DBlockPattern.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/Linear2DBlockPattern.java index e99383d06..13df9ca6f 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/Linear2DBlockPattern.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/Linear2DBlockPattern.java @@ -15,7 +15,7 @@ import static java.lang.Math.floorDiv; * @deprecated replaced by {@link com.sk89q.worldedit.function.pattern.RandomPattern} * combined with {@link com.fastasyncworldedit.core.math.random.Linear2DRandom}. */ -@Deprecated(forRemoval = true, since = "TODO") +@Deprecated(forRemoval = true, since = "2.9.2") public class Linear2DBlockPattern extends AbstractPattern { private final Pattern[] patternsArray; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/Linear3DBlockPattern.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/Linear3DBlockPattern.java index e4d3822cc..6c9d039d0 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/Linear3DBlockPattern.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/Linear3DBlockPattern.java @@ -15,7 +15,7 @@ import static java.lang.Math.floorDiv; * @deprecated replaced by {@link com.sk89q.worldedit.function.pattern.RandomPattern} * combined with {@link com.fastasyncworldedit.core.math.random.Linear3DRandom}. */ -@Deprecated(forRemoval = true, since = "TODO") +@Deprecated(forRemoval = true, since = "2.9.2") public class Linear3DBlockPattern extends AbstractPattern { private final Pattern[] patternsArray; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/random/Linear2DRandom.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/random/Linear2DRandom.java index 4f039031e..04a837b72 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/random/Linear2DRandom.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/random/Linear2DRandom.java @@ -6,7 +6,7 @@ import static java.lang.Math.floorDiv; /** * A {@link SimpleRandom} that deterministically maps coordinates * to values. - * @since TODO + * @since 2.9.2 */ public class Linear2DRandom implements SimpleRandom { private final int xScale; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/random/Linear3DRandom.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/random/Linear3DRandom.java index 87f350fe4..a1ab87045 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/random/Linear3DRandom.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/random/Linear3DRandom.java @@ -5,7 +5,7 @@ import static java.lang.Math.floorDiv; /** * A {@link SimpleRandom} that deterministically maps coordinates * to values. - * @since TODO + * @since 2.9.2 */ public class Linear3DRandom implements SimpleRandom { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/BlockVector3Set.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/BlockVector3Set.java index 83a639ead..cadc35fc8 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/BlockVector3Set.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/BlockVector3Set.java @@ -59,7 +59,7 @@ public interface BlockVector3Set extends Set { * * @param x x offset * @param z z offset - * @since TODO + * @since 2.9.2 */ void setOffset(int x, int z); @@ -70,7 +70,7 @@ public interface BlockVector3Set extends Set { * @param x x offset * @param y y offset * @param z z offset - * @since TODO + * @since 2.9.2 */ void setOffset(int x, int y, int z); @@ -81,7 +81,7 @@ public interface BlockVector3Set extends Set { * @param y y radius center * @param z z radius center * @return if radius is contained by the set - * @since TODO + * @since 2.9.2 */ boolean containsRadius(int x, int y, int z, int radius); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/Pattern.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/Pattern.java index e44a1c19d..69563af87 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/Pattern.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/Pattern.java @@ -79,7 +79,7 @@ public interface Pattern extends Filter { * Get the likely maximum size of the volume this pattern will affect * * @return Pattern size - * @since TODO + * @since 2.9.2 */ default BlockVector3 size() { return BlockVector3.ONE; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/RegionSelectorType.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/RegionSelectorType.java index 5c8655893..c76b058b1 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/RegionSelectorType.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/RegionSelectorType.java @@ -65,7 +65,7 @@ public enum RegionSelectorType { * Get a {@link RegionSelectorType} for the given {@link RegionSelector} * * @param selector Region selector to get type enum for - * @since TODO + * @since 2.9.2 */ @Nullable public static RegionSelectorType getForSelector(RegionSelector selector) { From a39ee6e045a28eb3f5cb83eb4fff71b79a48e8e2 Mon Sep 17 00:00:00 2001 From: Alexander Brandes Date: Thu, 4 Apr 2024 22:31:51 +0200 Subject: [PATCH 11/90] Back to snaptshot for development Signed-off-by: Alexander Brandes --- build.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 8c2685561..ae8df13a5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -34,7 +34,7 @@ logger.lifecycle(""" ******************************************* """) -var rootVersion by extra("2.9.2") +var rootVersion by extra("2.9.3") var snapshot by extra("SNAPSHOT") var revision: String by extra("") var buildNumber by extra("") @@ -52,7 +52,7 @@ ext { } } -version = String.format("%s", rootVersion) +version = String.format("%s-%s", rootVersion, buildNumber) if (!project.hasProperty("gitCommitHash")) { apply(plugin = "org.ajoberstar.grgit") From 08f89b9a6976da6bd9237467a680543d66322b1b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 4 Apr 2024 20:32:52 +0000 Subject: [PATCH 12/90] Update plotsquared to v7.3.7 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index f1c25e764..24872b49a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -15,7 +15,7 @@ griefprevention = "17.0.0" griefdefender = "2.1.0-SNAPSHOT" residence = "4.5._13.1" towny = "0.100.2.0" -plotsquared = "7.3.6" +plotsquared = "7.3.7" # Third party bstats = "3.0.2" From 96f7ff4408711565ac1ab060385108ffe2b7c747 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 4 Apr 2024 23:56:33 +0000 Subject: [PATCH 13/90] Update dependency io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin to v1.5.13 --- buildSrc/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 878f1b845..c703a6c3a 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -24,7 +24,7 @@ dependencies { implementation(gradleApi()) implementation("org.ajoberstar.grgit:grgit-gradle:5.2.2") implementation("com.github.johnrengelman:shadow:8.1.1") - implementation("io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin:1.5.12") + implementation("io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin:1.5.13") } kotlin { From 58fd4ac288960351978cafef613eea3c7644c727 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 5 Apr 2024 11:03:19 +0000 Subject: [PATCH 14/90] Update dependency paperweight-userdev to v1.20.4-R0.1-20240405.071722-146 --- worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts b/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts index e4539cd79..d0188257f 100644 --- a/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts +++ b/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts @@ -12,6 +12,6 @@ repositories { dependencies { // url=https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/1.20.4-R0.1-SNAPSHOT - the().paperDevBundle("1.20.4-R0.1-20240402.103709-145") + the().paperDevBundle("1.20.4-R0.1-20240405.071722-146") compileOnly(libs.paperlib) } From 8b597418cc9d484bd1e869c64e241d58eac13ae1 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 6 Apr 2024 07:36:53 +0000 Subject: [PATCH 15/90] Update plugin io.github.gradle-nexus.publish-plugin to v2 --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index ae8df13a5..8086d4bda 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,7 +6,7 @@ import java.time.format.DateTimeFormatter import xyz.jpenilla.runpaper.task.RunServer plugins { - id("io.github.gradle-nexus.publish-plugin") version "1.3.0" + id("io.github.gradle-nexus.publish-plugin") version "2.0.0" id("xyz.jpenilla.run-paper") version "2.2.3" } From 606e07bfdfb967d97895c5a4c8e69ec30b99dcec Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 6 Apr 2024 22:27:02 +0000 Subject: [PATCH 16/90] Update dependency paperweight-userdev to v1.20.4-R0.1-20240406.215857-153 --- worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts b/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts index d0188257f..72a2e29a3 100644 --- a/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts +++ b/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts @@ -12,6 +12,6 @@ repositories { dependencies { // url=https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/1.20.4-R0.1-SNAPSHOT - the().paperDevBundle("1.20.4-R0.1-20240405.071722-146") + the().paperDevBundle("1.20.4-R0.1-20240406.215857-153") compileOnly(libs.paperlib) } From b4c3ec3a64ca630ecce34398a951289fd7ee89bb Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 7 Apr 2024 00:51:03 +0000 Subject: [PATCH 17/90] Update dependency paperweight-userdev to v1.20.4-R0.1-20240406.235646-156 --- worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts b/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts index 72a2e29a3..478c29e59 100644 --- a/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts +++ b/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts @@ -12,6 +12,6 @@ repositories { dependencies { // url=https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/1.20.4-R0.1-SNAPSHOT - the().paperDevBundle("1.20.4-R0.1-20240406.215857-153") + the().paperDevBundle("1.20.4-R0.1-20240406.235646-156") compileOnly(libs.paperlib) } From d16cb8eb916ae6bf501334ebdd5bd20f9b9956f2 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 7 Apr 2024 03:11:18 +0000 Subject: [PATCH 18/90] Update dependency paperweight-userdev to v1.20.4-R0.1-20240407.005218-157 --- worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts b/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts index 478c29e59..888646fb0 100644 --- a/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts +++ b/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts @@ -12,6 +12,6 @@ repositories { dependencies { // url=https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/1.20.4-R0.1-SNAPSHOT - the().paperDevBundle("1.20.4-R0.1-20240406.235646-156") + the().paperDevBundle("1.20.4-R0.1-20240407.005218-157") compileOnly(libs.paperlib) } From fa6e924f567bccac4bc4288c85c8bfa455923618 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 8 Apr 2024 08:03:47 +0000 Subject: [PATCH 19/90] Update dependency paperweight-userdev to v1.20.4-R0.1-20240408.052944-158 --- worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts b/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts index 888646fb0..5c69ec443 100644 --- a/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts +++ b/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts @@ -12,6 +12,6 @@ repositories { dependencies { // url=https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/1.20.4-R0.1-SNAPSHOT - the().paperDevBundle("1.20.4-R0.1-20240407.005218-157") + the().paperDevBundle("1.20.4-R0.1-20240408.052944-158") compileOnly(libs.paperlib) } From ca2c18e0069a9dc5ce2a8bc012c0f91eebf4f5a5 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 8 Apr 2024 21:42:05 +0000 Subject: [PATCH 20/90] Update dependency com.palmergames.bukkit.towny:towny to v0.100.2.1 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 24872b49a..84eb05c9c 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -14,7 +14,7 @@ mapmanager = "1.8.0-SNAPSHOT" griefprevention = "17.0.0" griefdefender = "2.1.0-SNAPSHOT" residence = "4.5._13.1" -towny = "0.100.2.0" +towny = "0.100.2.1" plotsquared = "7.3.7" # Third party From d0b676210b49c695ce2319d1261f2c52311f8554 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 11 Apr 2024 00:33:15 +0000 Subject: [PATCH 21/90] Update dependency io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin to v1.5.15 --- buildSrc/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index c703a6c3a..f3058a653 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -24,7 +24,7 @@ dependencies { implementation(gradleApi()) implementation("org.ajoberstar.grgit:grgit-gradle:5.2.2") implementation("com.github.johnrengelman:shadow:8.1.1") - implementation("io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin:1.5.13") + implementation("io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin:1.5.15") } kotlin { From a0ef151341016b3ae9e024dc777f0330a922bab9 Mon Sep 17 00:00:00 2001 From: Pierre Maurice Schwang Date: Fri, 12 Apr 2024 20:55:40 +0200 Subject: [PATCH 22/90] Fix heightmap brush with imgur images (#2680) fix: heightmap brush with imgur / remote images --- .../core/util/MainUtil.java | 20 +++++++++++-------- .../core/util/image/ImageUtil.java | 6 +++--- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/MainUtil.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/MainUtil.java index 41c4e5704..1c5fe044a 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/MainUtil.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/MainUtil.java @@ -554,8 +554,15 @@ public class MainUtil { } public static BufferedImage readImage(URL url) throws IOException { + try (final InputStream stream = readImageStream(url.toURI())) { + return readImage(stream); + } catch (URISyntaxException e) { + throw new IOException("failed to parse url to uri reference", e); + } + } + + public static InputStream readImageStream(final URI uri) throws IOException { try { - final URI uri = url.toURI(); HttpRequest.Builder requestBuilder = HttpRequest.newBuilder(uri).GET(); if (uri.getHost().equalsIgnoreCase("i.imgur.com")) { @@ -566,16 +573,13 @@ public class MainUtil { requestBuilder.build(), HttpResponse.BodyHandlers.ofInputStream() ); - try (final InputStream body = response.body()) { - if (response.statusCode() > 299) { - throw new IOException("Expected 2xx as response code, but received " + response.statusCode()); - } - return readImage(body); + final InputStream body = response.body(); + if (response.statusCode() > 299) { + throw new IOException("Expected 2xx as response code, but received " + response.statusCode()); } + return body; } catch (InterruptedException e) { throw new IOException("request was interrupted", e); - } catch (URISyntaxException e) { - throw new IOException("failed to parse url to uri reference", e); } } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/image/ImageUtil.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/image/ImageUtil.java index f99a17e6f..c7c8edda3 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/image/ImageUtil.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/image/ImageUtil.java @@ -176,8 +176,8 @@ public class ImageUtil { } public static BufferedImage load(URI uri) throws InputParseException { - try { - return MainUtil.readImage(getInputStream(uri)); + try (final InputStream stream = getInputStream(uri)) { + return MainUtil.readImage(stream); } catch (IOException e) { throw new InputParseException(TextComponent.of(e.getMessage())); } @@ -190,7 +190,7 @@ public class ImageUtil { File file = new File(uri.getPath()); return new FileInputStream(file); } - return new URL(uriStr).openStream(); + return MainUtil.readImageStream(uri); } catch (IOException e) { throw new InputParseException(TextComponent.of(e.getMessage())); } From c1e2f23f94711bb42c17b29a9eb7c6ad4ceff4f4 Mon Sep 17 00:00:00 2001 From: Pierre Maurice Schwang Date: Fri, 12 Apr 2024 20:55:58 +0200 Subject: [PATCH 23/90] Fix error on adapting custom entities / entity types (#2674) chore/fix: entity type adaption, more in line with upstream --- .../bukkit/adapter/IBukkitAdapter.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/IBukkitAdapter.java b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/IBukkitAdapter.java index 29162b607..9792f9344 100644 --- a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/IBukkitAdapter.java +++ b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/IBukkitAdapter.java @@ -31,6 +31,8 @@ import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemTypes; import org.bukkit.Bukkit; import org.bukkit.Material; +import org.bukkit.NamespacedKey; +import org.bukkit.Registry; import org.bukkit.TreeType; import org.bukkit.block.Biome; import org.bukkit.block.data.BlockData; @@ -186,10 +188,12 @@ public interface IBukkitAdapter { } default org.bukkit.entity.EntityType adapt(EntityType entityType) { - if (!entityType.getId().startsWith("minecraft:")) { - throw new IllegalArgumentException("Bukkit only supports vanilla entities"); + NamespacedKey entityKey = NamespacedKey.fromString(entityType.toString()); + if (entityKey == null) { + throw new IllegalArgumentException("Entity key '" + entityType + "' does not map to Bukkit"); } - return org.bukkit.entity.EntityType.fromName(entityType.getId().substring(10).toLowerCase(Locale.ROOT)); + + return Registry.ENTITY_TYPE.get(entityKey); } /** @@ -343,7 +347,7 @@ public interface IBukkitAdapter { * @return WorldEdit EntityType */ default EntityType adapt(org.bukkit.entity.EntityType entityType) { - return EntityTypes.get(entityType.getName().toLowerCase(Locale.ROOT)); + return EntityTypes.get(entityType.getKey().toString()); } /** From e76904f228e6869932184abf72403cacc5ee7688 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 12 Apr 2024 18:56:45 +0000 Subject: [PATCH 24/90] Update dependency paperweight-userdev to v1.20.4-R0.1-20240412.173131-159 --- worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts b/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts index 5c69ec443..108bce749 100644 --- a/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts +++ b/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts @@ -12,6 +12,6 @@ repositories { dependencies { // url=https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/1.20.4-R0.1-SNAPSHOT - the().paperDevBundle("1.20.4-R0.1-20240408.052944-158") + the().paperDevBundle("1.20.4-R0.1-20240412.173131-159") compileOnly(libs.paperlib) } From ed38f96f92767e93d3a6e6867bda7f1945aa398a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 12 Apr 2024 21:18:25 +0000 Subject: [PATCH 25/90] Update dependency paperweight-userdev to v1.20.4-R0.1-20240412.201522-163 --- worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts b/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts index 108bce749..361fd380a 100644 --- a/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts +++ b/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts @@ -12,6 +12,6 @@ repositories { dependencies { // url=https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/1.20.4-R0.1-SNAPSHOT - the().paperDevBundle("1.20.4-R0.1-20240412.173131-159") + the().paperDevBundle("1.20.4-R0.1-20240412.201522-163") compileOnly(libs.paperlib) } From 34dc1ddcd715a09e121c035f2d554367a10c4cad Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 13 Apr 2024 01:00:20 +0000 Subject: [PATCH 26/90] Update gradle/wrapper-validation-action action to v3 --- .github/workflows/build-pr.yml | 2 +- .github/workflows/build.yml | 2 +- .github/workflows/upload-release-assets.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index de239164e..0d3ffdfdd 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -11,7 +11,7 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 - name: Validate Gradle Wrapper - uses: gradle/wrapper-validation-action@v2 + uses: gradle/wrapper-validation-action@v3 - name: Setup Java uses: actions/setup-java@v4 with: diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 675f0cc1c..8e80ad997 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,7 +11,7 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 - name: Validate Gradle Wrapper - uses: gradle/wrapper-validation-action@v2 + uses: gradle/wrapper-validation-action@v3 - name: Setup Java uses: actions/setup-java@v4 with: diff --git a/.github/workflows/upload-release-assets.yml b/.github/workflows/upload-release-assets.yml index a621e9d13..b88961eb4 100644 --- a/.github/workflows/upload-release-assets.yml +++ b/.github/workflows/upload-release-assets.yml @@ -9,7 +9,7 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 - name: Validate Gradle Wrapper - uses: gradle/wrapper-validation-action@v2 + uses: gradle/wrapper-validation-action@v3 - name: Setup Java uses: actions/setup-java@v4 with: From e426e7c8ee293cdb6ba2ad4b63f2285606d016e4 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 13 Apr 2024 01:00:14 +0000 Subject: [PATCH 27/90] Update dependency paperweight-userdev to v1.20.4-R0.1-20240412.212303-164 --- worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts b/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts index 361fd380a..460b1a0de 100644 --- a/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts +++ b/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts @@ -12,6 +12,6 @@ repositories { dependencies { // url=https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/1.20.4-R0.1-SNAPSHOT - the().paperDevBundle("1.20.4-R0.1-20240412.201522-163") + the().paperDevBundle("1.20.4-R0.1-20240412.212303-164") compileOnly(libs.paperlib) } From 41af66e86b42ac5e1e2042563f2215d28ed0cf62 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 13 Apr 2024 20:31:18 +0000 Subject: [PATCH 28/90] Update dependency com.palmergames.bukkit.towny:towny to v0.100.2.2 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 84eb05c9c..91a96e24f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -14,7 +14,7 @@ mapmanager = "1.8.0-SNAPSHOT" griefprevention = "17.0.0" griefdefender = "2.1.0-SNAPSHOT" residence = "4.5._13.1" -towny = "0.100.2.1" +towny = "0.100.2.2" plotsquared = "7.3.7" # Third party From 1d79f2705a13ef19e27c9d3a56d67f6f9924aec1 Mon Sep 17 00:00:00 2001 From: Alexander Brandes Date: Sun, 14 Apr 2024 10:37:46 +0200 Subject: [PATCH 29/90] Update wrapper validation Signed-off-by: Alexander Brandes --- .github/workflows/build-pr.yml | 2 +- .github/workflows/build.yml | 2 +- .github/workflows/upload-release-assets.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index 0d3ffdfdd..fbb90ab03 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -11,7 +11,7 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 - name: Validate Gradle Wrapper - uses: gradle/wrapper-validation-action@v3 + uses: gradle/actions/wrapper-validation@v3 - name: Setup Java uses: actions/setup-java@v4 with: diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8e80ad997..d6072de2f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,7 +11,7 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 - name: Validate Gradle Wrapper - uses: gradle/wrapper-validation-action@v3 + uses: gradle/actions/wrapper-validation@v3 - name: Setup Java uses: actions/setup-java@v4 with: diff --git a/.github/workflows/upload-release-assets.yml b/.github/workflows/upload-release-assets.yml index b88961eb4..bff53a6b2 100644 --- a/.github/workflows/upload-release-assets.yml +++ b/.github/workflows/upload-release-assets.yml @@ -9,7 +9,7 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 - name: Validate Gradle Wrapper - uses: gradle/wrapper-validation-action@v3 + uses: gradle/actions/wrapper-validation@v3 - name: Setup Java uses: actions/setup-java@v4 with: From cdad55ef777b283700319f64ce054ae50a085a8f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 14 Apr 2024 11:41:30 +0000 Subject: [PATCH 30/90] Update dependency dev.notmyfault.serverlib:ServerLib to v2.3.5 --- worldedit-bukkit/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldedit-bukkit/build.gradle.kts b/worldedit-bukkit/build.gradle.kts index e02685954..12c451485 100644 --- a/worldedit-bukkit/build.gradle.kts +++ b/worldedit-bukkit/build.gradle.kts @@ -169,7 +169,7 @@ tasks.named("shadowJar") { include(dependency("it.unimi.dsi:fastutil")) } relocate("org.incendo.serverlib", "com.fastasyncworldedit.serverlib") { - include(dependency("dev.notmyfault.serverlib:ServerLib:2.3.4")) + include(dependency("dev.notmyfault.serverlib:ServerLib:2.3.5")) } relocate("com.intellectualsites.paster", "com.fastasyncworldedit.paster") { include(dependency("com.intellectualsites.paster:Paster")) From 595a17c903cefae258a82eacfbf1c77fa8bd6d89 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 14 Apr 2024 11:41:23 +0000 Subject: [PATCH 31/90] Update dependency dev.notmyfault.serverlib:ServerLib to v2.3.5 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 91a96e24f..187a0516c 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -39,7 +39,7 @@ commons-cli = "1.6.0" paperlib = "1.0.8" paster = "1.1.5" vault = "1.7.1" -serverlib = "2.3.4" +serverlib = "2.3.5" ## Internal text-adapter = "3.0.6" text = "3.0.4" From ccc8b15664cb1a393480dd19f0bf40c1418511cf Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 14 Apr 2024 14:35:45 +0000 Subject: [PATCH 32/90] Update dependency dev.notmyfault.serverlib:ServerLib to v2.3.6 --- worldedit-bukkit/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldedit-bukkit/build.gradle.kts b/worldedit-bukkit/build.gradle.kts index 12c451485..8705c931c 100644 --- a/worldedit-bukkit/build.gradle.kts +++ b/worldedit-bukkit/build.gradle.kts @@ -169,7 +169,7 @@ tasks.named("shadowJar") { include(dependency("it.unimi.dsi:fastutil")) } relocate("org.incendo.serverlib", "com.fastasyncworldedit.serverlib") { - include(dependency("dev.notmyfault.serverlib:ServerLib:2.3.5")) + include(dependency("dev.notmyfault.serverlib:ServerLib:2.3.6")) } relocate("com.intellectualsites.paster", "com.fastasyncworldedit.paster") { include(dependency("com.intellectualsites.paster:Paster")) From 11c09333251b13f3dbfb914201cab64b70878e6f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 14 Apr 2024 14:35:41 +0000 Subject: [PATCH 33/90] Update dependency dev.notmyfault.serverlib:ServerLib to v2.3.6 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 187a0516c..c605e3817 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -39,7 +39,7 @@ commons-cli = "1.6.0" paperlib = "1.0.8" paster = "1.1.5" vault = "1.7.1" -serverlib = "2.3.5" +serverlib = "2.3.6" ## Internal text-adapter = "3.0.6" text = "3.0.4" From 015b79d33309ec20eabaa3920efddac442107194 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 15 Apr 2024 18:10:57 +0000 Subject: [PATCH 34/90] Update dependency com.intellectualsites.paster:Paster to v1.1.6 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index c605e3817..90e306b00 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -37,7 +37,7 @@ lz4-java = "1.8.0" lz4-stream = "1.0.0" commons-cli = "1.6.0" paperlib = "1.0.8" -paster = "1.1.5" +paster = "1.1.6" vault = "1.7.1" serverlib = "2.3.6" ## Internal From 7afebdbc61f9f6995d49cd669c900b843657286d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 16 Apr 2024 22:27:42 +0000 Subject: [PATCH 35/90] Update dependency paperweight-userdev to v1.20.4-R0.1-20240416.195429-165 --- worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts b/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts index 460b1a0de..85964a8c5 100644 --- a/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts +++ b/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts @@ -12,6 +12,6 @@ repositories { dependencies { // url=https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/1.20.4-R0.1-SNAPSHOT - the().paperDevBundle("1.20.4-R0.1-20240412.212303-164") + the().paperDevBundle("1.20.4-R0.1-20240416.195429-165") compileOnly(libs.paperlib) } From 59aa3dfdfca2421e9ac2047088c849189c05bc42 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 16 Apr 2024 22:27:58 +0000 Subject: [PATCH 36/90] Update dependency me.lucko:fabric-permissions-api to v0.3 --- worldedit-fabric/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldedit-fabric/build.gradle.kts b/worldedit-fabric/build.gradle.kts index 88f1998b4..05bf8aa1f 100644 --- a/worldedit-fabric/build.gradle.kts +++ b/worldedit-fabric/build.gradle.kts @@ -100,7 +100,7 @@ dependencies { } // No need for this at runtime - "modCompileOnly"("me.lucko:fabric-permissions-api:0.1-SNAPSHOT") + "modCompileOnly"("me.lucko:fabric-permissions-api:0.3") // Hook these up manually, because Fabric doesn't seem to quite do it properly. "compileOnly"("net.fabricmc:sponge-mixin:${project.versions.mixin}") From a3661227be3f2a34df9a5184b626002883b7883e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 17 Apr 2024 01:10:47 +0000 Subject: [PATCH 37/90] Update dependency me.lucko:fabric-permissions-api to v0.3.1 --- worldedit-fabric/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldedit-fabric/build.gradle.kts b/worldedit-fabric/build.gradle.kts index 05bf8aa1f..4ba08c6eb 100644 --- a/worldedit-fabric/build.gradle.kts +++ b/worldedit-fabric/build.gradle.kts @@ -100,7 +100,7 @@ dependencies { } // No need for this at runtime - "modCompileOnly"("me.lucko:fabric-permissions-api:0.3") + "modCompileOnly"("me.lucko:fabric-permissions-api:0.3.1") // Hook these up manually, because Fabric doesn't seem to quite do it properly. "compileOnly"("net.fabricmc:sponge-mixin:${project.versions.mixin}") From 1bf46c6227f0914ae6431192986f501e2e2975d0 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 19 Apr 2024 06:04:34 +0000 Subject: [PATCH 38/90] Update dependency com.palmergames.bukkit.towny:towny to v0.100.2.3 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 90e306b00..d05d61861 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -14,7 +14,7 @@ mapmanager = "1.8.0-SNAPSHOT" griefprevention = "17.0.0" griefdefender = "2.1.0-SNAPSHOT" residence = "4.5._13.1" -towny = "0.100.2.2" +towny = "0.100.2.3" plotsquared = "7.3.7" # Third party From 341c7a5e8854f8fac08c5c5282b3891c63b67002 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 19 Apr 2024 11:20:49 +0000 Subject: [PATCH 39/90] Update plotsquared to v7.3.8 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index d05d61861..3d56b9c9e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -15,7 +15,7 @@ griefprevention = "17.0.0" griefdefender = "2.1.0-SNAPSHOT" residence = "4.5._13.1" towny = "0.100.2.3" -plotsquared = "7.3.7" +plotsquared = "7.3.8" # Third party bstats = "3.0.2" From 65fd3312325b725af78039676a1f85cba9a590a7 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 19 Apr 2024 22:06:46 +0000 Subject: [PATCH 40/90] Update dependency paperweight-userdev to v1.20.4-R0.1-20240419.201130-167 --- worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts b/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts index 85964a8c5..96d97d0bf 100644 --- a/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts +++ b/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts @@ -12,6 +12,6 @@ repositories { dependencies { // url=https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/1.20.4-R0.1-SNAPSHOT - the().paperDevBundle("1.20.4-R0.1-20240416.195429-165") + the().paperDevBundle("1.20.4-R0.1-20240419.201130-167") compileOnly(libs.paperlib) } From a3832515965e52ccc70ea749d9416ae74dac76b2 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 20 Apr 2024 05:05:26 +0000 Subject: [PATCH 41/90] Update dependency paperweight-userdev to v1.20.4-R0.1-20240420.033107-168 --- worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts b/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts index 96d97d0bf..900503d18 100644 --- a/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts +++ b/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts @@ -12,6 +12,6 @@ repositories { dependencies { // url=https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/1.20.4-R0.1-SNAPSHOT - the().paperDevBundle("1.20.4-R0.1-20240419.201130-167") + the().paperDevBundle("1.20.4-R0.1-20240420.033107-168") compileOnly(libs.paperlib) } From fdd6b86aeb6820e5f645c6cc2a36b65f53613e5e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 20 Apr 2024 18:49:33 +0000 Subject: [PATCH 42/90] Update dependency paperweight-userdev to v1.20.4-R0.1-20240420.181647-171 --- worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts b/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts index 900503d18..dd0babcbd 100644 --- a/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts +++ b/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts @@ -12,6 +12,6 @@ repositories { dependencies { // url=https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/1.20.4-R0.1-SNAPSHOT - the().paperDevBundle("1.20.4-R0.1-20240420.033107-168") + the().paperDevBundle("1.20.4-R0.1-20240420.181647-171") compileOnly(libs.paperlib) } From 3dfc4f8f79b2302b2c4077c8b47a922c71aafd40 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 20 Apr 2024 21:27:10 +0000 Subject: [PATCH 43/90] Update dependency paperweight-userdev to v1.20.4-R0.1-20240420.200855-173 --- worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts b/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts index dd0babcbd..d626798e0 100644 --- a/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts +++ b/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts @@ -12,6 +12,6 @@ repositories { dependencies { // url=https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/1.20.4-R0.1-SNAPSHOT - the().paperDevBundle("1.20.4-R0.1-20240420.181647-171") + the().paperDevBundle("1.20.4-R0.1-20240420.200855-173") compileOnly(libs.paperlib) } From 1a31f39d1fad882d466ab92c47d92fbba149a60d Mon Sep 17 00:00:00 2001 From: Alexander Brandes Date: Sun, 21 Apr 2024 13:16:43 +0200 Subject: [PATCH 44/90] Run renovate weekly Signed-off-by: Alexander Brandes --- .github/renovate.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/renovate.json b/.github/renovate.json index 3d0f91b5a..6b7783c42 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -2,7 +2,8 @@ "$schema" : "https://docs.renovatebot.com/renovate-schema.json", "extends" : [ "config:recommended", - ":semanticCommitsDisabled" + ":semanticCommitsDisabled", + "schedule:earlyMondays" ], "automerge" : true, "ignoreDeps" : [ From 45e18d0104b37688b177244029f5eb03d461e3a5 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 28 Apr 2024 13:58:34 +0000 Subject: [PATCH 45/90] Update dependency commons-cli:commons-cli to v1.7.0 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 3d56b9c9e..873a68c09 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -35,7 +35,7 @@ jlibnoise = "1.0.0" jchronic = "0.2.4a" lz4-java = "1.8.0" lz4-stream = "1.0.0" -commons-cli = "1.6.0" +commons-cli = "1.7.0" paperlib = "1.0.8" paster = "1.1.6" vault = "1.7.1" From b09310d745e6eeadbc7bcee4201a8efd3c9c71ae Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 29 Apr 2024 01:14:01 +0000 Subject: [PATCH 46/90] Update dependency com.palmergames.bukkit.towny:towny to v0.100.2.6 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 873a68c09..b4b5f642d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -14,7 +14,7 @@ mapmanager = "1.8.0-SNAPSHOT" griefprevention = "17.0.0" griefdefender = "2.1.0-SNAPSHOT" residence = "4.5._13.1" -towny = "0.100.2.3" +towny = "0.100.2.6" plotsquared = "7.3.8" # Third party From 3c206f44a517dfd27a054fc78f2d3b9da5cb9de0 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 29 Apr 2024 01:14:09 +0000 Subject: [PATCH 47/90] Update dependency paperweight-userdev to v1.20.4-R0.1-20240424.165410-174 --- worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts b/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts index d626798e0..821b6c52d 100644 --- a/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts +++ b/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts @@ -12,6 +12,6 @@ repositories { dependencies { // url=https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/1.20.4-R0.1-SNAPSHOT - the().paperDevBundle("1.20.4-R0.1-20240420.200855-173") + the().paperDevBundle("1.20.4-R0.1-20240424.165410-174") compileOnly(libs.paperlib) } From 3310686509fcf5c9693c300b1c5d2c3d9a253c1a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 29 Apr 2024 03:27:13 +0000 Subject: [PATCH 48/90] Update plugin xyz.jpenilla.run-paper to v2.2.4 --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 8086d4bda..3a5d41523 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,7 +7,7 @@ import xyz.jpenilla.runpaper.task.RunServer plugins { id("io.github.gradle-nexus.publish-plugin") version "2.0.0" - id("xyz.jpenilla.run-paper") version "2.2.3" + id("xyz.jpenilla.run-paper") version "2.2.4" } if (!File("$rootDir/.git").exists()) { From 1b2e2fe12ab23903ecf84d37469689293ec0b575 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 29 Apr 2024 03:27:19 +0000 Subject: [PATCH 49/90] Update dependency io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin to v1.6.2 --- buildSrc/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index f3058a653..ad4afd071 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -24,7 +24,7 @@ dependencies { implementation(gradleApi()) implementation("org.ajoberstar.grgit:grgit-gradle:5.2.2") implementation("com.github.johnrengelman:shadow:8.1.1") - implementation("io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin:1.5.15") + implementation("io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin:1.6.2") } kotlin { From debfabff08c829cf2eadd4130f9f7573ea10e2ac Mon Sep 17 00:00:00 2001 From: Jordan Date: Wed, 1 May 2024 17:31:06 +0900 Subject: [PATCH 50/90] feat: introduce migrating config nodes to new locations (#2642) - Initial case of moving schematic limits from experimental to limits - Closes #2533 --- .../core/configuration/Config.java | 121 ++++++++++++------ .../core/configuration/Settings.java | 32 +++-- .../core/limit/FaweLimit.java | 10 ++ .../worldedit/command/SchematicCommands.java | 16 +-- 4 files changed, 123 insertions(+), 56 deletions(-) diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Config.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Config.java index bc300d584..c3f223dc2 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Config.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Config.java @@ -2,6 +2,7 @@ package com.fastasyncworldedit.core.configuration; import com.fastasyncworldedit.core.configuration.file.YamlConfiguration; import com.fastasyncworldedit.core.util.StringMan; +import com.sk89q.util.StringUtil; import com.sk89q.worldedit.internal.util.LogManagerCompat; import org.apache.logging.log4j.Logger; @@ -14,8 +15,10 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.lang.invoke.MethodHandles; import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Modifier; import java.lang.reflect.ParameterizedType; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; @@ -27,6 +30,9 @@ public class Config { private static final Logger LOGGER = LogManagerCompat.getLogger(); + private final Map removedKeyVals = new HashMap<>(); + private List existingMigrateNodes = null; + public Config() { save(new PrintWriter(new ByteArrayOutputStream(0)), getClass(), this, 0); } @@ -43,7 +49,8 @@ public class Config { try { return (T) field.get(instance); } catch (IllegalAccessException e) { - e.printStackTrace(); + LOGGER.error("Failed to get config option: {}", key, e); + return null; } } } @@ -67,6 +74,10 @@ public class Config { if (field.getAnnotation(Final.class) != null) { return; } + Migrate migrate = field.getAnnotation(Migrate.class); + if (existingMigrateNodes != null && migrate != null) { + existingMigrateNodes.add(migrate.value()); + } if (field.getType() == String.class && !(value instanceof String)) { value = value + ""; } @@ -74,17 +85,22 @@ public class Config { field.set(instance, value); return; } catch (Throwable e) { - e.printStackTrace(); + LOGGER.error("Failed to set config option: {}", key); } } } - LOGGER.error("Failed to set config option: {}: {} | {} | {}.yml", key, value, instance, root.getSimpleName()); + removedKeyVals.put(key, value); + LOGGER.error( + "Failed to set config option: {}: {} | {} | {}.yml. This is likely because it was removed.", + key, + value, + instance, + root.getSimpleName() + ); } public boolean load(File file) { - if (!file.exists()) { - return false; - } + existingMigrateNodes = new ArrayList<>(); YamlConfiguration yml = YamlConfiguration.loadConfiguration(file); for (String key : yml.getKeys(true)) { Object value = yml.get(key); @@ -93,6 +109,10 @@ public class Config { } set(key, value, getClass()); } + for (String node : existingMigrateNodes) { + removedKeyVals.remove(node); + } + existingMigrateNodes = null; return true; } @@ -113,7 +133,7 @@ public class Config { save(writer, getClass(), instance, 0); writer.close(); } catch (Throwable e) { - e.printStackTrace(); + LOGGER.error("Failed to save config file: {}", file, e); } } @@ -166,6 +186,19 @@ public class Config { } + /** + * Indicates that a field should be instantiated / created. + * + * @since TODO + */ + @Retention(RetentionPolicy.RUNTIME) + @Target({ElementType.FIELD}) + public @interface Migrate { + + String value(); + + } + @Ignore // This is not part of the config public static class ConfigBlock { @@ -222,7 +255,6 @@ public class Config { try { String CTRF = System.lineSeparator(); String spacing = StringMan.repeat(" ", indent); - HashMap, Object> instances = new HashMap<>(); for (Field field : clazz.getFields()) { if (field.getAnnotation(Ignore.class) != null) { continue; @@ -239,31 +271,14 @@ public class Config { } if (current == ConfigBlock.class) { current = (Class) ((ParameterizedType) (field.getGenericType())).getActualTypeArguments()[0]; - comment = current.getAnnotation(Comment.class); - if (comment != null) { - for (String commentLine : comment.value()) { - writer.write(spacing + "# " + commentLine + CTRF); - } - } - BlockName blockNames = current.getAnnotation(BlockName.class); - if (blockNames != null) { - writer.write(spacing + toNodeName(current.getSimpleName()) + ":" + CTRF); - ConfigBlock configBlock = (ConfigBlock) field.get(instance); - if (configBlock == null || configBlock.getInstances().isEmpty()) { - configBlock = new ConfigBlock(); - field.set(instance, configBlock); - for (String blockName : blockNames.value()) { - configBlock.put(blockName, current.getDeclaredConstructor().newInstance()); - } - } - // Save each instance - for (Map.Entry entry : ((Map) configBlock.getRaw()).entrySet()) { - String key = entry.getKey(); - writer.write(spacing + " " + toNodeName(key) + ":" + CTRF); - save(writer, current, entry.getValue(), indent + 4); - } - } + handleConfigBlockSave(writer, instance, indent, field, spacing, CTRF, current); continue; + } else if (!removedKeyVals.isEmpty()) { + Migrate migrate = field.getAnnotation(Migrate.class); + Object value; + if (migrate != null && (value = removedKeyVals.remove(migrate.value())) != null) { + field.set(instance, value); + } } Create create = field.getAnnotation(Create.class); if (create != null) { @@ -281,7 +296,6 @@ public class Config { writer.write(spacing + toNodeName(current.getSimpleName()) + ":" + CTRF); if (value == null) { field.set(instance, value = current.getDeclaredConstructor().newInstance()); - instances.put(current, value); } save(writer, current, value, indent + 2); } else { @@ -292,7 +306,42 @@ public class Config { } } } catch (Throwable e) { - e.printStackTrace(); + LOGGER.error("Failed to save config file", e); + } + } + + private void handleConfigBlockSave( + PrintWriter writer, + Object instance, + int indent, + Field field, + String spacing, + String CTRF, + Class current + ) throws IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException { + Comment comment = current.getAnnotation(Comment.class); + if (comment != null) { + for (String commentLine : comment.value()) { + writer.write(spacing + "# " + commentLine + CTRF); + } + } + BlockName blockNames = current.getAnnotation(BlockName.class); + if (blockNames != null) { + writer.write(spacing + toNodeName(current.getSimpleName()) + ":" + CTRF); + ConfigBlock configBlock = (ConfigBlock) field.get(instance); + if (configBlock == null || configBlock.getInstances().isEmpty()) { + configBlock = new ConfigBlock<>(); + field.set(instance, configBlock); + for (String blockName : blockNames.value()) { + configBlock.put(blockName, current.getDeclaredConstructor().newInstance()); + } + } + // Save each instance + for (Map.Entry entry : configBlock.getRaw().entrySet()) { + String key = entry.getKey(); + writer.write(spacing + " " + toNodeName(key) + ":" + CTRF); + save(writer, current, entry.getValue(), indent + 4); + } } } @@ -311,7 +360,7 @@ public class Config { return field; } catch (Throwable ignored) { LOGGER.warn( - "Invalid config field: {} for {}", + "Invalid config field: {} for {}. It is possible this is because it has been removed.", StringMan.join(split, "."), toNodeName(instance.getClass().getSimpleName()) ); @@ -379,7 +428,7 @@ public class Config { return null; } } catch (Throwable e) { - e.printStackTrace(); + LOGGER.error("Failed retrieving instance for config node: {}", StringUtil.joinString(split, "."), e); } return null; } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Settings.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Settings.java index 89f48b697..8c8077d66 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Settings.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Settings.java @@ -145,6 +145,14 @@ public class Settings extends Config { limit.MAX_HISTORY, newLimit.MAX_HISTORY_MB != -1 ? newLimit.MAX_HISTORY_MB : Integer.MAX_VALUE ); + limit.SCHEM_FILE_NUM_LIMIT = Math.max( + limit.SCHEM_FILE_NUM_LIMIT, + newLimit.SCHEM_FILE_NUM_LIMIT != -1 ? newLimit.SCHEM_FILE_NUM_LIMIT : Integer.MAX_VALUE + ); + limit.SCHEM_FILE_SIZE_LIMIT = Math.max( + limit.SCHEM_FILE_SIZE_LIMIT, + newLimit.SCHEM_FILE_SIZE_LIMIT != -1 ? newLimit.SCHEM_FILE_SIZE_LIMIT : Integer.MAX_VALUE + ); limit.MAX_EXPRESSION_MS = Math.max( limit.MAX_EXPRESSION_MS, newLimit.MAX_EXPRESSION_MS != -1 ? newLimit.MAX_EXPRESSION_MS : Integer.MAX_VALUE @@ -353,6 +361,18 @@ public class Settings extends Config { " - History on disk or memory will be deleted", }) public int MAX_HISTORY_MB = -1; + @Comment({ + "Sets a maximum limit (in kb) for the size of a player's schematics directory (per-player mode only)", + "Set to -1 to disable" + }) + @Migrate("experimental.per-player-file-size-limit") + public int SCHEM_FILE_SIZE_LIMIT = -1; + @Comment({ + "Sets a maximum limit for the amount of schematics in a player's schematics directory (per-player mode only)", + "Set to -1 to disable" + }) + @Migrate("experimental.per-player-file-num-limit") + public int SCHEM_FILE_NUM_LIMIT = -1; @Comment("Maximum time in milliseconds //calc can execute") public int MAX_EXPRESSION_MS = 50; @Comment({ @@ -615,18 +635,6 @@ public class Settings extends Config { }) public boolean ALLOW_TICK_FLUIDS = false; - @Comment({ - "Sets a maximum limit (in kb) for the size of a player's schematics directory (per-player mode only)", - "Set to -1 to disable" - }) - public int PER_PLAYER_FILE_SIZE_LIMIT = -1; - - @Comment({ - "Sets a maximum limit for the amount of schematics in a player's schematics directory (per-player mode only)", - "Set to -1 to disable" - }) - public int PER_PLAYER_FILE_NUM_LIMIT = -1; - } @Comment({"Web/HTTP connection related settings"}) diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/limit/FaweLimit.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/limit/FaweLimit.java index 00a47178c..e02e3abc9 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/limit/FaweLimit.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/limit/FaweLimit.java @@ -15,6 +15,8 @@ public class FaweLimit { public int MAX_BLOCKSTATES = 0; public int MAX_ENTITIES = 0; public int MAX_HISTORY = 0; + public int SCHEM_FILE_SIZE_LIMIT = 0; + public int SCHEM_FILE_NUM_LIMIT = 0; public int MAX_EXPRESSION_MS = 0; public int INVENTORY_MODE = Integer.MAX_VALUE; public int SPEED_REDUCTION = Integer.MAX_VALUE; @@ -111,6 +113,8 @@ public class FaweLimit { MAX.MAX_BLOCKSTATES = Integer.MAX_VALUE; MAX.MAX_ENTITIES = Integer.MAX_VALUE; MAX.MAX_HISTORY = Integer.MAX_VALUE; + MAX.SCHEM_FILE_NUM_LIMIT = Integer.MAX_VALUE; + MAX.SCHEM_FILE_SIZE_LIMIT = Integer.MAX_VALUE; MAX.MAX_EXPRESSION_MS = 50; MAX.FAST_PLACEMENT = true; MAX.CONFIRM_LARGE = true; @@ -237,6 +241,8 @@ public class FaweLimit { && MAX_BLOCKSTATES == Integer.MAX_VALUE && MAX_ENTITIES == Integer.MAX_VALUE && MAX_HISTORY == Integer.MAX_VALUE + && SCHEM_FILE_SIZE_LIMIT == Integer.MAX_VALUE + && SCHEM_FILE_NUM_LIMIT == Integer.MAX_VALUE && INVENTORY_MODE == 0 && SPEED_REDUCTION == 0 && FAST_PLACEMENT @@ -256,6 +262,8 @@ public class FaweLimit { MAX_FAILS = limit.MAX_FAILS; MAX_ITERATIONS = limit.MAX_ITERATIONS; MAX_HISTORY = limit.MAX_HISTORY; + SCHEM_FILE_NUM_LIMIT = limit.SCHEM_FILE_NUM_LIMIT; + SCHEM_FILE_SIZE_LIMIT = limit.SCHEM_FILE_SIZE_LIMIT; INVENTORY_MODE = limit.INVENTORY_MODE; SPEED_REDUCTION = limit.SPEED_REDUCTION; FAST_PLACEMENT = limit.FAST_PLACEMENT; @@ -279,6 +287,8 @@ public class FaweLimit { limit.MAX_FAILS = MAX_FAILS; limit.MAX_ITERATIONS = MAX_ITERATIONS; limit.MAX_HISTORY = MAX_HISTORY; + limit.SCHEM_FILE_SIZE_LIMIT = SCHEM_FILE_SIZE_LIMIT; + limit.SCHEM_FILE_NUM_LIMIT = SCHEM_FILE_NUM_LIMIT; limit.FAST_PLACEMENT = FAST_PLACEMENT; limit.CONFIRM_LARGE = CONFIRM_LARGE; limit.RESTRICT_HISTORY_TO_REGIONS = RESTRICT_HISTORY_TO_REGIONS; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java index 1158a7847..3bd62f02b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java @@ -700,10 +700,10 @@ public class SchematicCommands { String headerBytesElem = String.format("%.1fkb", totalBytes / 1000.0); - if (Settings.settings().PATHS.PER_PLAYER_SCHEMATICS && Settings.settings().EXPERIMENTAL.PER_PLAYER_FILE_SIZE_LIMIT > -1) { + if (Settings.settings().PATHS.PER_PLAYER_SCHEMATICS && actor.getLimit().SCHEM_FILE_SIZE_LIMIT > -1) { headerBytesElem += String.format( " / %dkb", - Settings.settings().EXPERIMENTAL.PER_PLAYER_FILE_SIZE_LIMIT + actor.getLimit().SCHEM_FILE_SIZE_LIMIT ); } @@ -837,7 +837,7 @@ public class SchematicCommands { //FAWE start boolean checkFilesize = Settings.settings().PATHS.PER_PLAYER_SCHEMATICS - && Settings.settings().EXPERIMENTAL.PER_PLAYER_FILE_SIZE_LIMIT > -1; + && actor.getLimit().SCHEM_FILE_SIZE_LIMIT > -1; double directorysizeKb = 0; String curFilepath = file.getAbsolutePath(); @@ -867,7 +867,7 @@ public class SchematicCommands { } - if (Settings.settings().PATHS.PER_PLAYER_SCHEMATICS && Settings.settings().EXPERIMENTAL.PER_PLAYER_FILE_NUM_LIMIT > -1) { + if (Settings.settings().PATHS.PER_PLAYER_SCHEMATICS && actor.getLimit().SCHEM_FILE_NUM_LIMIT > -1) { if (numFiles == -1) { numFiles = 0; @@ -880,7 +880,7 @@ public class SchematicCommands { } } } - int limit = Settings.settings().EXPERIMENTAL.PER_PLAYER_FILE_NUM_LIMIT; + int limit = actor.getLimit().SCHEM_FILE_NUM_LIMIT; if (numFiles >= limit) { TextComponent noSlotsErr = TextComponent.of( //TODO - to be moved into captions/translatablecomponents @@ -931,7 +931,7 @@ public class SchematicCommands { if (checkFilesize) { double curKb = filesizeKb + directorysizeKb; - int allocatedKb = Settings.settings().EXPERIMENTAL.PER_PLAYER_FILE_SIZE_LIMIT; + int allocatedKb = actor.getLimit().SCHEM_FILE_SIZE_LIMIT; if (overwrite) { curKb -= oldKbOverwritten; @@ -966,11 +966,11 @@ public class SchematicCommands { actor.print(kbRemainingNotif); } - if (Settings.settings().PATHS.PER_PLAYER_SCHEMATICS && Settings.settings().EXPERIMENTAL.PER_PLAYER_FILE_NUM_LIMIT > -1) { + if (Settings.settings().PATHS.PER_PLAYER_SCHEMATICS && actor.getLimit().SCHEM_FILE_NUM_LIMIT > -1) { TextComponent slotsRemainingNotif = TextComponent.of( //TODO - to be moved into captions/translatablecomponents - "You have " + (Settings.settings().EXPERIMENTAL.PER_PLAYER_FILE_NUM_LIMIT - numFiles) + "You have " + (actor.getLimit().SCHEM_FILE_NUM_LIMIT - numFiles) + " schematic file slots left.", TextColor.GRAY ); From d79bbce73a9f1f03e536e5e826e909fd093acfeb Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 6 May 2024 00:46:47 +0000 Subject: [PATCH 51/90] Update dependency org.mozilla:rhino-runtime to v1.7.15 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index b4b5f642d..87bc9496b 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -27,7 +27,7 @@ checkerqual = "3.42.0" truezip = "6.8.4" auto-value = "1.10.4" findbugs = "3.0.2" -rhino-runtime = "1.7.14" +rhino-runtime = "1.7.15" zstd-jni = "1.4.8-1" # Not latest as it can be difficult to obtain latest ZSTD libs antlr4 = "4.13.1" json-simple = "1.1.1" From a96b620b790477afd46754ae8706ccc78d69bb1b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 6 May 2024 00:46:41 +0000 Subject: [PATCH 52/90] Update dependency com.palmergames.bukkit.towny:towny to v0.100.2.7 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 87bc9496b..f0db6139b 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -14,7 +14,7 @@ mapmanager = "1.8.0-SNAPSHOT" griefprevention = "17.0.0" griefdefender = "2.1.0-SNAPSHOT" residence = "4.5._13.1" -towny = "0.100.2.6" +towny = "0.100.2.7" plotsquared = "7.3.8" # Third party From c297cd6849c2a36a0b73d83e18dda2cbc5753dc7 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 6 May 2024 03:35:14 +0000 Subject: [PATCH 53/90] Update dependency org.checkerframework:checker-qual to v3.43.0 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index f0db6139b..a309f127c 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -23,7 +23,7 @@ sparsebitset = "1.3" parallelgzip = "1.0.5" adventure = "4.16.0" adventure-bukkit = "4.3.2" -checkerqual = "3.42.0" +checkerqual = "3.43.0" truezip = "6.8.4" auto-value = "1.10.4" findbugs = "3.0.2" From 991d93d8ce3f0603f9ffb5e36bcf0bf866ddac73 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 6 May 2024 03:35:09 +0000 Subject: [PATCH 54/90] Update dependency io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin to v1.7.0 --- buildSrc/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index ad4afd071..68ac32256 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -24,7 +24,7 @@ dependencies { implementation(gradleApi()) implementation("org.ajoberstar.grgit:grgit-gradle:5.2.2") implementation("com.github.johnrengelman:shadow:8.1.1") - implementation("io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin:1.6.2") + implementation("io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin:1.7.0") } kotlin { From 9bc09c6a4c1e9e90344eec5671c0622a641a3e3c Mon Sep 17 00:00:00 2001 From: Hannes Greule Date: Sun, 12 May 2024 10:41:48 +0200 Subject: [PATCH 55/90] Integrate WE Schematic Share system (#2619) * Integrate WE Schematic Share system (cherry picked from commit 303f5a76b2df70d63480f2126c9ef4b228eb3c59) * disable feature for now --------- Co-authored-by: Madeline Miller --- .../worldedit/command/SchematicCommands.java | 117 ++++++++++++++++-- .../util/paste/ActorCallbackPaste.java | 22 ++++ .../worldedit/util/paste/EngineHubPaste.java | 23 +++- .../worldedit/util/paste/PasteMetadata.java | 26 ++++ .../sk89q/worldedit/util/paste/Paster.java | 6 +- 5 files changed, 181 insertions(+), 13 deletions(-) create mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/PasteMetadata.java diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java index 3bd62f02b..e711e61ee 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java @@ -26,6 +26,7 @@ import com.fastasyncworldedit.core.extent.clipboard.MultiClipboardHolder; import com.fastasyncworldedit.core.extent.clipboard.URIClipboardHolder; import com.fastasyncworldedit.core.extent.clipboard.io.schematic.MinecraftStructure; import com.fastasyncworldedit.core.util.MainUtil; +import com.google.common.collect.ImmutableList; import com.google.common.collect.Multimap; import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; @@ -60,15 +61,19 @@ import com.sk89q.worldedit.util.formatting.text.format.TextColor; import com.sk89q.worldedit.util.io.Closer; import com.sk89q.worldedit.util.io.file.FilenameException; import org.apache.logging.log4j.Logger; +import com.sk89q.worldedit.util.paste.EngineHubPaste; +import com.sk89q.worldedit.util.paste.PasteMetadata; import org.enginehub.piston.annotation.Command; import org.enginehub.piston.annotation.CommandContainer; import org.enginehub.piston.annotation.param.Arg; import org.enginehub.piston.annotation.param.ArgFlag; import org.enginehub.piston.annotation.param.Switch; +import org.enginehub.piston.exception.CommandException; import org.enginehub.piston.exception.StopExecutionException; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; +import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -79,9 +84,12 @@ import java.net.URISyntaxException; import java.net.URL; import java.nio.channels.Channels; import java.nio.channels.ReadableByteChannel; +import java.io.OutputStream; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; +import java.util.Base64; import java.util.Arrays; import java.util.Collection; import java.util.Collections; @@ -536,6 +544,42 @@ public class SchematicCommands { .buildAndExec(worldEdit.getExecutorService()); } + @Command( + name = "share", + desc = "Share your clipboard as a schematic online" + ) + @CommandPermissions({ "worldedit.clipboard.share", "worldedit.schematic.share" }) + public void share(Actor actor, LocalSession session, + @Arg(desc = "Schematic name. Defaults to name-millis", def = "") + String schematicName, + @Arg(desc = "Format name.", def = "sponge") + String formatName) throws WorldEditException { + if (true) { + throw new UnsupportedOperationException("This feature is currently not implemented"); + } + if (worldEdit.getPlatformManager().queryCapability(Capability.GAME_HOOKS).getDataVersion() == -1) { + actor.printError(TranslatableComponent.of("worldedit.schematic.unsupported-minecraft-version")); + return; + } + + ClipboardFormat format = ClipboardFormats.findByAlias(formatName); + if (format == null) { + actor.printError(TranslatableComponent.of("worldedit.schematic.unknown-format", TextComponent.of(formatName))); + return; + } + + ClipboardHolder holder = session.getClipboard(); + + SchematicShareTask task = new SchematicShareTask(actor, format, holder, schematicName); + AsyncCommandBuilder.wrap(task, actor) + .registerWithSupervisor(worldEdit.getSupervisor(), "Sharing schematic") + .setDelayMessage(TranslatableComponent.of("worldedit.schematic.save.saving")) + .setWorkingMessage(TranslatableComponent.of("worldedit.schematic.save.still-saving")) + .onSuccess("Shared", (url -> actor.printInfo(TextComponent.of(url.toExternalForm() + ".schem").clickEvent(ClickEvent.openUrl(url.toExternalForm() + ".schem"))))) + .onFailure("Failed to share schematic", worldEdit.getPlatformManager().getPlatformCommandManager().getExceptionConverter()) + .buildAndExec(worldEdit.getExecutorService()); + } + @Command( name = "formats", aliases = {"listformats", "f"}, @@ -804,14 +848,48 @@ public class SchematicCommands { } - private static class SchematicSaveTask implements Callable { + private abstract static class SchematicOutputTask implements Callable { + protected final Actor actor; + protected final ClipboardFormat format; + protected final ClipboardHolder holder; - private final Actor actor; - private final ClipboardFormat format; - private final ClipboardHolder holder; + SchematicOutputTask( + Actor actor, + ClipboardFormat format, + ClipboardHolder holder + ) { + this.actor = actor; + this.format = format; + this.holder = holder; + } + + protected void writeToOutputStream(OutputStream outputStream) throws Exception { + Clipboard clipboard = holder.getClipboard(); + Transform transform = holder.getTransform(); + Clipboard target; + // If we have a transform, bake it into the copy + if (transform.isIdentity()) { + target = clipboard; + } else { + FlattenedClipboardTransform result = FlattenedClipboardTransform.transform(clipboard, transform); + target = new BlockArrayClipboard(result.getTransformedRegion()); + target.setOrigin(clipboard.getOrigin()); + Operations.completeLegacy(result.copyTo(target)); + } + + try (Closer closer = Closer.create()) { + OutputStream stream = closer.register(outputStream); + BufferedOutputStream bos = closer.register(new BufferedOutputStream(stream)); + ClipboardWriter writer = closer.register(format.getWriter(bos)); + writer.write(target); + } + } + } + + private static class SchematicSaveTask extends SchematicOutputTask { + private File file; private final boolean overwrite; private final File rootDir; - private File file; SchematicSaveTask( Actor actor, @@ -821,11 +899,9 @@ public class SchematicCommands { ClipboardHolder holder, boolean overwrite ) { - this.actor = actor; + super(actor, format, holder); this.file = file; this.rootDir = rootDir; - this.format = format; - this.holder = holder; this.overwrite = overwrite; } @@ -984,7 +1060,32 @@ public class SchematicCommands { //FAWE end return null; } + } + private static class SchematicShareTask extends SchematicOutputTask { + private final String name; + + SchematicShareTask(Actor actor, ClipboardFormat format, ClipboardHolder holder, String name) { + super(actor, format, holder); + this.name = name; + } + + @Override + public URL call() throws Exception { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + try { + writeToOutputStream(baos); + } catch (Exception e) { + throw new CommandException(TextComponent.of(e.getMessage()), e, ImmutableList.of()); + } + + EngineHubPaste pasteService = new EngineHubPaste(); + PasteMetadata metadata = new PasteMetadata(); + metadata.author = this.actor.getName(); + metadata.extension = "schem"; + metadata.name = name == null ? actor.getName() + "-" + System.currentTimeMillis() : name; + return pasteService.paste(new String(Base64.getEncoder().encode(baos.toByteArray()), StandardCharsets.UTF_8), metadata).call(); + } } private static class SchematicListTask implements Callable { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/ActorCallbackPaste.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/ActorCallbackPaste.java index 680dbed0d..152dcfea3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/ActorCallbackPaste.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/ActorCallbackPaste.java @@ -83,4 +83,26 @@ public final class ActorCallbackPaste { .buildAndExec(Pasters.getExecutor()); } + + /** + * Submit data to a pastebin service and inform the sender of + * success or failure. + * + * @param supervisor The supervisor instance + * @param sender The sender + * @param content The content + * @param pasteMetadata The paste metadata + * @param successMessage The message builder, given the URL as an arg + */ + public static void pastebin(Supervisor supervisor, final Actor sender, String content, PasteMetadata pasteMetadata, final TranslatableComponent.Builder successMessage) { + Callable task = paster.paste(content, pasteMetadata); + + AsyncCommandBuilder.wrap(task, sender) + .registerWithSupervisor(supervisor, "Submitting content to a pastebin service.") + .setDelayMessage(TranslatableComponent.of("worldedit.pastebin.uploading")) + .onSuccess((String) null, url -> sender.printInfo(successMessage.args(TextComponent.of(url.toString())).build())) + .onFailure("Failed to submit paste", null) + .buildAndExec(Pasters.getExecutor()); + } + } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/EngineHubPaste.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/EngineHubPaste.java index f9bf84375..037cea727 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/EngineHubPaste.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/EngineHubPaste.java @@ -33,23 +33,38 @@ public class EngineHubPaste implements Paster { private static final Gson GSON = new Gson(); @Override - public Callable paste(String content) { - return new PasteTask(content); + public Callable paste(String content, PasteMetadata metadata) { + return new PasteTask(content, metadata); } private static final class PasteTask implements Callable { private final String content; + private final PasteMetadata metadata; - private PasteTask(String content) { + private PasteTask(String content, PasteMetadata metadata) { this.content = content; + this.metadata = metadata; } @Override public URL call() throws IOException, InterruptedException { URL initialUrl = HttpRequest.url("https://paste.enginehub.org/signed_paste"); - SignedPasteResponse response = GSON.fromJson(HttpRequest.get(initialUrl) + HttpRequest requestBuilder = HttpRequest.get(initialUrl); + + requestBuilder.header("x-paste-meta-from", "EngineHub"); + if (metadata.name != null) { + requestBuilder.header("x-paste-meta-name", metadata.name); + } + if (metadata.author != null) { + requestBuilder.header("x-paste-meta-author", metadata.author); + } + if (metadata.extension != null) { + requestBuilder.header("x-paste-meta-extension", metadata.extension); + } + + SignedPasteResponse response = GSON.fromJson(requestBuilder .execute() .expectResponseCode(200) .returnContent() diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/PasteMetadata.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/PasteMetadata.java new file mode 100644 index 000000000..5654e6ae5 --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/PasteMetadata.java @@ -0,0 +1,26 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.util.paste; + +public class PasteMetadata { + public String name; + public String extension; + public String author; +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/Paster.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/Paster.java index 0b7652b91..ccd5780b0 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/Paster.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/Paster.java @@ -24,6 +24,10 @@ import java.util.concurrent.Callable; public interface Paster { - Callable paste(String content); + default Callable paste(String content) { + return paste(content, new PasteMetadata()); + } + + Callable paste(String content, PasteMetadata metadata); } From 1d9e8b60abd630854f2b72affbb58abc7c50dba2 Mon Sep 17 00:00:00 2001 From: Jordan Date: Sun, 12 May 2024 11:05:00 +0100 Subject: [PATCH 56/90] fix: add missing blocktypes and some minor cleanup (#2722) - fixes #2713 --- .../worldedit/world/block/BlockTypes.java | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) 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 4b3204be4..513a00557 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 @@ -483,6 +483,10 @@ public final class BlockTypes { @Nullable public static final BlockType COPPER_GRATE = init(); @Nullable + public static final BlockType COPPER_ORE = init(); + @Nullable + public static final BlockType COPPER_TRAPDOOR = init(); + @Nullable public static final BlockType CORNFLOWER = init(); @Nullable public static final BlockType CRACKED_DEEPSLATE_BRICKS = init(); @@ -495,6 +499,8 @@ public final class BlockTypes { @Nullable public static final BlockType CRACKED_STONE_BRICKS = init(); @Nullable + public static final BlockType CRAFTER = init(); + @Nullable public static final BlockType CRAFTING_TABLE = init(); @Nullable public static final BlockType CREEPER_HEAD = init(); @@ -685,8 +691,6 @@ public final class BlockTypes { @Nullable public static final BlockType DEEPSLATE_COPPER_ORE = init(); @Nullable - public static final BlockType COPPER_TRAPDOOR = init(); - @Nullable public static final BlockType DEEPSLATE_DIAMOND_ORE = init(); @Nullable public static final BlockType DEEPSLATE_EMERALD_ORE = init(); @@ -747,8 +751,6 @@ public final class BlockTypes { @Nullable public static final BlockType ENDER_CHEST = init(); @Nullable - public static final BlockType EXPOSED_CHISELED_COPPER = init(); - @Nullable public static final BlockType END_GATEWAY = init(); @Nullable public static final BlockType END_PORTAL = init(); @@ -767,6 +769,8 @@ public final class BlockTypes { @Nullable public static final BlockType END_STONE_BRICK_WALL = init(); @Nullable + public static final BlockType EXPOSED_CHISELED_COPPER = init(); + @Nullable public static final BlockType EXPOSED_COPPER = init(); @Nullable public static final BlockType EXPOSED_COPPER_BULB = init(); @@ -836,6 +840,9 @@ public final class BlockTypes { public static final BlockType GRASS = init(); @Nullable public static final BlockType GRASS_BLOCK = init(); + @Deprecated + @Nullable + public static final BlockType GRASS_PATH = init(); @Nullable public static final BlockType GRAVEL = init(); @Nullable @@ -925,8 +932,6 @@ public final class BlockTypes { @Nullable public static final BlockType INFESTED_CRACKED_STONE_BRICKS = init(); @Nullable - public static final BlockType CRAFTER = init(); - @Nullable public static final BlockType INFESTED_DEEPSLATE = init(); @Nullable public static final BlockType INFESTED_MOSSY_STONE_BRICKS = init(); @@ -1954,10 +1959,12 @@ public final class BlockTypes { @Nullable public static final BlockType TWISTING_VINES = init(); @Nullable - public static final BlockType VERDANT_FROGLIGHT = init(); - @Nullable public static final BlockType TWISTING_VINES_PLANT = init(); @Nullable + public static final BlockType VAULT = init(); + @Nullable + public static final BlockType VERDANT_FROGLIGHT = init(); + @Nullable public static final BlockType VINE = init(); @Nullable public static final BlockType VOID_AIR = init(); @@ -2026,7 +2033,7 @@ public final class BlockTypes { public static final BlockType WAXED_CUT_COPPER_SLAB = init(); @Nullable public static final BlockType WAXED_CUT_COPPER_STAIRS = init(); - @ Nullable + @Nullable public static final BlockType WAXED_EXPOSED_CHISELED_COPPER = init(); @Nullable public static final BlockType WAXED_EXPOSED_COPPER = init(); From 69dbf760a84c33ce90be8600adcf7568195e8615 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 13 May 2024 01:53:18 +0000 Subject: [PATCH 57/90] Update dependency com.palmergames.bukkit.towny:towny to v0.100.2.8 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index a309f127c..99f1ff6fc 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -14,7 +14,7 @@ mapmanager = "1.8.0-SNAPSHOT" griefprevention = "17.0.0" griefdefender = "2.1.0-SNAPSHOT" residence = "4.5._13.1" -towny = "0.100.2.7" +towny = "0.100.2.8" plotsquared = "7.3.8" # Third party From ae4d0236cc4c7f8ef899bae600c5f180a507703e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 13 May 2024 01:53:27 +0000 Subject: [PATCH 58/90] Update dependency io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin to v1.7.1 --- buildSrc/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 68ac32256..ef4a18fe7 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -24,7 +24,7 @@ dependencies { implementation(gradleApi()) implementation("org.ajoberstar.grgit:grgit-gradle:5.2.2") implementation("com.github.johnrengelman:shadow:8.1.1") - implementation("io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin:1.7.0") + implementation("io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin:1.7.1") } kotlin { From c9b2f441c1837df0e68031d5f122a9521cf5d188 Mon Sep 17 00:00:00 2001 From: Jordan Date: Tue, 14 May 2024 20:30:34 +0100 Subject: [PATCH 59/90] feat: only unstuck a player if configured to do so (#2723) - also add unstuck to a couple of other commands - closes #2675 --- .../core/configuration/Settings.java | 11 +++++++++++ .../worldedit/command/GenerationCommands.java | 14 ++++++++++---- .../sk89q/worldedit/command/RegionCommands.java | 6 +++++- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Settings.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Settings.java index 8c8077d66..63f37fd6b 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Settings.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Settings.java @@ -79,6 +79,8 @@ public class Settings extends Config { @Create public REGION_RESTRICTIONS_OPTIONS REGION_RESTRICTIONS_OPTIONS; @Create + public GENERAL GENERAL; + @Create public ConfigBlock LIMITS; private Settings() { @@ -752,4 +754,13 @@ public class Settings extends Config { } + public static class GENERAL { + + @Comment({ + "If the player should be relocated/unstuck when a generation command would bury them", + }) + public boolean UNSTUCK_ON_GENERATE = true; + + } + } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java index dbd698b24..d3d456965 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java @@ -184,6 +184,9 @@ public class GenerationCommands { BlockVector3 pos = session.getPlacementPosition(actor); int affected = editSession.makeCylinder(pos, pattern, radiusX, radiusZ, height, !hollow); + if (actor instanceof Player && Settings.settings().GENERAL.UNSTUCK_ON_GENERATE) { + ((Player) actor).findFreePosition(); + } actor.print(Caption.of("worldedit.cyl.created", TextComponent.of(affected))); return affected; } @@ -227,6 +230,9 @@ public class GenerationCommands { BlockVector3 pos = session.getPlacementPosition(actor); int affected = editSession.makeCone(pos, pattern, radiusX, radiusZ, height, !hollow, thickness); + if (actor instanceof Player && Settings.settings().GENERAL.UNSTUCK_ON_GENERATE) { + ((Player) actor).findFreePosition(); + } actor.printInfo(Caption.of("worldedit.cone.created", TextComponent.of(affected))); return affected; } @@ -293,7 +299,7 @@ public class GenerationCommands { } int affected = editSession.makeSphere(pos, pattern, radiusX, radiusY, radiusZ, !hollow); - if (actor instanceof Player) { + if (actor instanceof Player && Settings.settings().GENERAL.UNSTUCK_ON_GENERATE) { ((Player) actor).findFreePosition(); } actor.print(Caption.of("worldedit.sphere.created", TextComponent.of(affected))); @@ -379,7 +385,7 @@ public class GenerationCommands { worldEdit.checkMaxRadius(size); BlockVector3 pos = session.getPlacementPosition(actor); int affected = editSession.makePyramid(pos, pattern, size, !hollow); - if (actor instanceof Player) { + if (actor instanceof Player && Settings.settings().GENERAL.UNSTUCK_ON_GENERATE) { ((Player) actor).findFreePosition(); } actor.print(Caption.of("worldedit.pyramid.created", TextComponent.of(affected))); @@ -457,7 +463,7 @@ public class GenerationCommands { hollow, session.getTimeout() ); - if (actor instanceof Player) { + if (actor instanceof Player && Settings.settings().GENERAL.UNSTUCK_ON_GENERATE) { ((Player) actor).findFreePosition(); } actor.print(Caption.of("worldedit.generate.created", TextComponent.of(affected))); @@ -741,7 +747,7 @@ public class GenerationCommands { radius.divide(max), sphericity / 100 ); - if (actor instanceof Player) { + if (actor instanceof Player && Settings.settings().GENERAL.UNSTUCK_ON_GENERATE) { ((Player) actor).findFreePosition(); } actor.print(Caption.of("worldedit.sphere.created", TextComponent.of(affected))); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java index a72cba4b3..73cb34274 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java @@ -22,6 +22,7 @@ package com.sk89q.worldedit.command; import com.fastasyncworldedit.core.FaweAPI; import com.fastasyncworldedit.core.FaweCache; import com.fastasyncworldedit.core.configuration.Caption; +import com.fastasyncworldedit.core.configuration.Settings; import com.fastasyncworldedit.core.extent.processor.lighting.RelightMode; import com.fastasyncworldedit.core.limit.FaweLimit; import com.fastasyncworldedit.core.util.MaskTraverser; @@ -715,6 +716,9 @@ public class RegionCommands { session.setSourceMask(mask); //FAWE end } + if (actor instanceof Player && Settings.settings().GENERAL.UNSTUCK_ON_GENERATE) { + ((Player) actor).findFreePosition(); + } if (success) { actor.print(Caption.of("worldedit.regen.regenerated")); } else { @@ -788,7 +792,7 @@ public class RegionCommands { String.join(" ", expression), session.getTimeout() ); - if (actor instanceof Player) { + if (actor instanceof Player && Settings.settings().GENERAL.UNSTUCK_ON_GENERATE) { ((Player) actor).findFreePosition(); } actor.print(Caption.of("worldedit.deform.deformed", TextComponent.of(affected))); From a353c12df017bc810748a90fa6c113737db32ead Mon Sep 17 00:00:00 2001 From: Hannes Greule Date: Sun, 19 May 2024 13:32:18 +0200 Subject: [PATCH 60/90] Support for 1.20.5/6 (#2721) * 1.20.6 Signed-off-by: Alexander Brandes * work Signed-off-by: Alexander Brandes * More work Signed-off-by: Alexander Brandes * chore: address more removed fields and methods, make it run * chore: don't allocate unnecessary arrays (by maps) * chore: the comment might still be noteworthy * chore: no need to synchronize twice * fix obfuscation changes * remove unneeded deprecation * make regen work without throwing exceptions - but slow * fix: error when adapting BaseItemStacks without nbt * fix annoying paper api breakage --------- Signed-off-by: Alexander Brandes Co-authored-by: Alexander Brandes Co-authored-by: Pierre Maurice Schwang --- .github/ISSUE_TEMPLATE/bug_report.yml | 3 +- .github/workflows/build-pr.yml | 2 +- .github/workflows/build.yml | 2 +- .github/workflows/codeql.yml | 2 +- .github/workflows/upload-release-assets.yml | 2 +- COMPILING.adoc | 6 +- Jenkinsfile | 2 +- build.gradle.kts | 2 +- buildSrc/build.gradle.kts | 14 +- buildSrc/src/main/kotlin/CommonConfig.kt | 2 +- buildSrc/src/main/kotlin/CommonJavaConfig.kt | 4 +- buildSrc/src/main/kotlin/LibsConfig.kt | 4 +- gradle/libs.versions.toml | 2 +- settings.gradle.kts | 2 +- .../v1_20_R3/PaperweightPlatformAdapter.java | 1 - .../build.gradle.kts | 4 +- .../v1_20_R4}/PaperweightAdapter.java | 458 ++++--- .../v1_20_R4}/PaperweightDataConverters.java | 1114 +++++++---------- .../v1_20_R4}/PaperweightFakePlayer.java | 27 +- .../PaperweightWorldNativeAccess.java | 61 +- .../v1_20_R4}/PaperweightBlockMaterial.java | 53 +- .../v1_20_R4}/PaperweightFaweAdapter.java | 181 ++- .../PaperweightFaweWorldNativeAccess.java | 17 +- .../fawe/v1_20_R4}/PaperweightGetBlocks.java | 123 +- .../v1_20_R4}/PaperweightGetBlocks_Copy.java | 26 +- .../v1_20_R4}/PaperweightMapChunkUtil.java | 8 +- .../v1_20_R4}/PaperweightPlatformAdapter.java | 186 ++- .../v1_20_R4}/PaperweightPostProcessor.java | 2 +- .../PaperweightStarlightRelighter.java | 8 +- .../PaperweightStarlightRelighterFactory.java | 4 +- .../nbt/PaperweightLazyCompoundTag.java | 2 +- .../v1_20_R4}/regen/PaperweightRegen.java | 252 ++-- worldedit-bukkit/build.gradle.kts | 3 +- .../bukkit/adapter/Regenerator.java | 130 +- .../bukkit/listener/ChunkListener.java | 2 +- .../bukkit/util/CommandRegistration.java | 8 +- worldedit-core/doctools/build.gradle.kts | 6 +- .../sk89q/worldedit/WorldEditManifest.java | 5 +- .../sk89q/worldedit/entity/BaseEntity.java | 2 + .../extent/validation/BlockChangeLimiter.java | 1 + .../util/io/ForwardSeekableInputStream.java | 8 +- .../sk89q/worldedit/util/net/HttpRequest.java | 10 +- .../worldedit/util/paste/EngineHubPaste.java | 3 +- .../util/task/FutureForwardingTask.java | 13 +- .../world/block/BlockCategories.java | 9 + .../worldedit/world/block/BlockType.java | 1 + .../worldedit/world/block/BlockTypes.java | 2 + .../worldedit/world/chunk/AnvilChunk13.java | 2 +- .../worldedit/world/entity/EntityTypes.java | 8 + .../worldedit/world/item/ItemCategories.java | 54 +- .../sk89q/worldedit/world/item/ItemType.java | 4 +- .../sk89q/worldedit/world/item/ItemTypes.java | 39 + 52 files changed, 1527 insertions(+), 1359 deletions(-) rename worldedit-bukkit/adapters/{adapter-1_18_2 => adapter-1_20_5}/build.gradle.kts (78%) rename worldedit-bukkit/adapters/{adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_18_R2 => adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext.fawe/v1_20_R4}/PaperweightAdapter.java (77%) rename worldedit-bukkit/adapters/{adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_18_R2 => adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext.fawe/v1_20_R4}/PaperweightDataConverters.java (94%) rename worldedit-bukkit/adapters/{adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_18_R2 => adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext.fawe/v1_20_R4}/PaperweightFakePlayer.java (78%) rename worldedit-bukkit/adapters/{adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_18_R2 => adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext.fawe/v1_20_R4}/PaperweightWorldNativeAccess.java (74%) rename worldedit-bukkit/adapters/{adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2 => adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4}/PaperweightBlockMaterial.java (69%) rename worldedit-bukkit/adapters/{adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2 => adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4}/PaperweightFaweAdapter.java (82%) rename worldedit-bukkit/adapters/{adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2 => adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4}/PaperweightFaweWorldNativeAccess.java (94%) rename worldedit-bukkit/adapters/{adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2 => adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4}/PaperweightGetBlocks.java (94%) rename worldedit-bukkit/adapters/{adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2 => adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4}/PaperweightGetBlocks_Copy.java (86%) rename worldedit-bukkit/adapters/{adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2 => adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4}/PaperweightMapChunkUtil.java (88%) rename worldedit-bukkit/adapters/{adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2 => adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4}/PaperweightPlatformAdapter.java (80%) rename worldedit-bukkit/adapters/{adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2 => adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4}/PaperweightPostProcessor.java (99%) rename worldedit-bukkit/adapters/{adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2 => adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4}/PaperweightStarlightRelighter.java (90%) rename worldedit-bukkit/adapters/{adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2 => adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4}/PaperweightStarlightRelighterFactory.java (88%) rename worldedit-bukkit/adapters/{adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2 => adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4}/nbt/PaperweightLazyCompoundTag.java (98%) rename worldedit-bukkit/adapters/{adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2 => adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4}/regen/PaperweightRegen.java (69%) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index bc78076bd..1de1aa8df 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -27,10 +27,9 @@ body: description: Which server version version you using? If your server version is not listed, it is not supported. Update to a supported version first. multiple: false options: - - '1.20.4' + - '1.20.5/6' - '1.20' - '1.19.4' - - '1.18.2' validations: required: true diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index fbb90ab03..e6ad24a7f 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -17,7 +17,7 @@ jobs: with: distribution: temurin cache: gradle - java-version: 17 + java-version: 21 - name: Build on ${{ matrix.os }} run: ./gradlew build -s - name: Archive artifacts diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d6072de2f..5b44758dd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,7 +17,7 @@ jobs: with: distribution: temurin cache: gradle - java-version: 17 + java-version: 21 - name: Clean Build run: ./gradlew clean build --no-daemon - name: Determine release status diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index b7e9c61ed..0cd6f4443 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -25,7 +25,7 @@ jobs: with: distribution: temurin cache: gradle - java-version: 17 + java-version: 21 - name: Initialize CodeQL uses: github/codeql-action/init@v3 with: diff --git a/.github/workflows/upload-release-assets.yml b/.github/workflows/upload-release-assets.yml index bff53a6b2..22d6c6083 100644 --- a/.github/workflows/upload-release-assets.yml +++ b/.github/workflows/upload-release-assets.yml @@ -15,7 +15,7 @@ jobs: with: distribution: temurin cache: gradle - java-version: 17 + java-version: 21 - name: Clean Build run: ./gradlew clean build --no-daemon - name: Upload Release Assets diff --git a/COMPILING.adoc b/COMPILING.adoc index 87b21b685..bdd30ba62 100644 --- a/COMPILING.adoc +++ b/COMPILING.adoc @@ -3,12 +3,12 @@ = Compiling -You can compile FastAsyncWorldEdit as long as you have some version of Java greater than or equal to 17 installed. Gradle will download JDK 17 specifically if needed, +You can compile FastAsyncWorldEdit as long as you have some version of Java greater than or equal to 21 installed. Gradle will download JDK 21 specifically if needed, but it needs some version of Java to bootstrap from. -Note that if you have JRE 8 installed, Gradle will currently attempt to use that to compile, which will not work. It is easiest to uninstall JRE 8 and replace it with JDK 17. +Note that if you have JRE 8 installed, Gradle will currently attempt to use that to compile, which will not work. It is easiest to uninstall JRE 8 and replace it with JDK 21. -You can get the JDK 17 link:https://adoptium.net/[here] from Adoptium. +You can get the JDK 21 link:https://adoptium.net/[here] from Adoptium. The build process uses Gradle, which you do *not* need to download. FastAsyncWorldEdit is a multi-module project with three active modules: diff --git a/Jenkinsfile b/Jenkinsfile index 61000e9fb..94db4eda2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,7 +7,7 @@ pipeline { stage('Build') { steps { withEnv([ - "PATH+JAVA=${tool 'Temurin-17.0.7_7'}/bin" + "PATH+JAVA=${tool 'Temurin-21.0.3_9'}/bin" ]) { sh './gradlew clean build' } diff --git a/build.gradle.kts b/build.gradle.kts index 3a5d41523..aed748cdb 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -83,7 +83,7 @@ allprojects { } applyCommonConfiguration() -val supportedVersions = listOf("1.18.2", "1.19.4", "1.20", "1.20.4") +val supportedVersions = listOf("1.19.4", "1.20", "1.20.4", "1.20.5", "1.20.6") tasks { supportedVersions.forEach { diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index ef4a18fe7..f116fd23e 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -25,10 +25,22 @@ dependencies { implementation("org.ajoberstar.grgit:grgit-gradle:5.2.2") implementation("com.github.johnrengelman:shadow:8.1.1") implementation("io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin:1.7.1") + constraints { + val asmVersion = "[9.7,)" + implementation("org.ow2.asm:asm:$asmVersion") { + because("Need Java 21 support in shadow") + } + implementation("org.ow2.asm:asm-commons:$asmVersion") { + because("Need Java 21 support in shadow") + } + implementation("org.vafer:jdependency:[2.10,)") { + because("Need Java 21 support in shadow") + } + } } kotlin { jvmToolchain { - (this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(17)) + (this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(21)) } } diff --git a/buildSrc/src/main/kotlin/CommonConfig.kt b/buildSrc/src/main/kotlin/CommonConfig.kt index 6a6d552aa..e8fd3db87 100644 --- a/buildSrc/src/main/kotlin/CommonConfig.kt +++ b/buildSrc/src/main/kotlin/CommonConfig.kt @@ -33,7 +33,7 @@ fun Project.applyCommonConfiguration() { plugins.withId("java") { the().toolchain { - languageVersion.set(JavaLanguageVersion.of(17)) + languageVersion.set(JavaLanguageVersion.of(21)) } } diff --git a/buildSrc/src/main/kotlin/CommonJavaConfig.kt b/buildSrc/src/main/kotlin/CommonJavaConfig.kt index 8a111a2e7..f915c2e0c 100644 --- a/buildSrc/src/main/kotlin/CommonJavaConfig.kt +++ b/buildSrc/src/main/kotlin/CommonJavaConfig.kt @@ -21,7 +21,7 @@ fun Project.applyCommonJavaConfiguration(sourcesJar: Boolean, banSlf4j: Boolean .matching { it.name == "compileJava" || it.name == "compileTestJava" } .configureEach { val disabledLint = listOf( - "processing", "path", "fallthrough", "serial" + "processing", "path", "fallthrough", "serial", "overloads", "this-escape", ) options.release.set(17) options.compilerArgs.addAll(listOf("-Xlint:all") + disabledLint.map { "-Xlint:-$it" }) @@ -31,7 +31,7 @@ fun Project.applyCommonJavaConfiguration(sourcesJar: Boolean, banSlf4j: Boolean } configurations.all { - attributes.attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 17) + attributes.attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 21) } tasks.withType().configureEach { diff --git a/buildSrc/src/main/kotlin/LibsConfig.kt b/buildSrc/src/main/kotlin/LibsConfig.kt index 5d6e7892b..2c957880a 100644 --- a/buildSrc/src/main/kotlin/LibsConfig.kt +++ b/buildSrc/src/main/kotlin/LibsConfig.kt @@ -122,7 +122,7 @@ fun Project.applyLibrariesConfiguration() { attribute(Category.CATEGORY_ATTRIBUTE, project.objects.named(Category.LIBRARY)) attribute(Bundling.BUNDLING_ATTRIBUTE, project.objects.named(Bundling.SHADOWED)) attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, project.objects.named(LibraryElements.JAR)) - attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 17) + attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 21) } outgoing.artifact(tasks.named("jar")) } @@ -137,7 +137,7 @@ fun Project.applyLibrariesConfiguration() { attribute(Category.CATEGORY_ATTRIBUTE, project.objects.named(Category.LIBRARY)) attribute(Bundling.BUNDLING_ATTRIBUTE, project.objects.named(Bundling.SHADOWED)) attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, project.objects.named(LibraryElements.JAR)) - attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 17) + attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 21) } outgoing.artifact(tasks.named("jar")) } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 99f1ff6fc..c02ba9098 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,6 @@ [versions] # Minecraft expectations -paper = "1.20.4-R0.1-SNAPSHOT" +paper = "1.20.6-R0.1-SNAPSHOT" fastutil = "8.5.9" guava = "31.1-jre" log4j = "2.19.0" diff --git a/settings.gradle.kts b/settings.gradle.kts index 74cba1396..48318b908 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -2,7 +2,7 @@ rootProject.name = "FastAsyncWorldEdit" include("worldedit-libs") -listOf("1_18_2", "1_19_4", "1_20", "1_20_2", "1_20_4").forEach { +listOf("1_19_4", "1_20", "1_20_2", "1_20_4", "1_20_5").forEach { include("worldedit-bukkit:adapters:adapter-$it") } diff --git a/worldedit-bukkit/adapters/adapter-1_20_4/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R3/PaperweightPlatformAdapter.java b/worldedit-bukkit/adapters/adapter-1_20_4/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R3/PaperweightPlatformAdapter.java index 147ec5be7..23de00ade 100644 --- a/worldedit-bukkit/adapters/adapter-1_20_4/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R3/PaperweightPlatformAdapter.java +++ b/worldedit-bukkit/adapters/adapter-1_20_4/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R3/PaperweightPlatformAdapter.java @@ -58,7 +58,6 @@ import net.minecraft.world.level.entity.PersistentEntitySectionManager; import org.apache.logging.log4j.Logger; import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v1_20_R3.CraftChunk; -import sun.misc.Unsafe; import javax.annotation.Nonnull; import javax.annotation.Nullable; diff --git a/worldedit-bukkit/adapters/adapter-1_18_2/build.gradle.kts b/worldedit-bukkit/adapters/adapter-1_20_5/build.gradle.kts similarity index 78% rename from worldedit-bukkit/adapters/adapter-1_18_2/build.gradle.kts rename to worldedit-bukkit/adapters/adapter-1_20_5/build.gradle.kts index 3713af207..e1a518cbb 100644 --- a/worldedit-bukkit/adapters/adapter-1_18_2/build.gradle.kts +++ b/worldedit-bukkit/adapters/adapter-1_20_5/build.gradle.kts @@ -11,7 +11,7 @@ repositories { } dependencies { - // url=https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/1.18.2-R0.1-SNAPSHOT - the().paperDevBundle("1.18.2-R0.1-20220920.010157-167") + // url=https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/1.20.6-R0.1-SNAPSHOT/ + the().paperDevBundle("1.20.6-R0.1-20240516.001739-55") compileOnly(libs.paperlib) } diff --git a/worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_18_R2/PaperweightAdapter.java b/worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext.fawe/v1_20_R4/PaperweightAdapter.java similarity index 77% rename from worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_18_R2/PaperweightAdapter.java rename to worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext.fawe/v1_20_R4/PaperweightAdapter.java index 1edc3be1d..e629c4611 100644 --- a/worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_18_R2/PaperweightAdapter.java +++ b/worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext.fawe/v1_20_R4/PaperweightAdapter.java @@ -17,24 +17,23 @@ * along with this program. If not, see . */ -package com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_18_R2; +package com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_20_R4; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Maps; import com.google.common.collect.Sets; import com.google.common.util.concurrent.Futures; -import com.mojang.datafixers.util.Either; +import com.mojang.serialization.Codec; import com.mojang.serialization.Lifecycle; +import com.sk89q.jnbt.NBTConstants; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.blocks.BaseItem; import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; import com.sk89q.worldedit.bukkit.adapter.Refraction; -import com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_18_R2.PaperweightPlatformAdapter; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.extension.platform.Watchdog; import com.sk89q.worldedit.extent.Extent; @@ -81,14 +80,20 @@ import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.item.ItemType; import net.minecraft.Util; import net.minecraft.core.BlockPos; -import net.minecraft.core.Registry; +import net.minecraft.core.Holder; +import net.minecraft.core.RegistryAccess; +import net.minecraft.core.component.DataComponentPatch; +import net.minecraft.core.registries.Registries; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtOps; +import net.minecraft.nbt.Tag; import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket; import net.minecraft.network.protocol.game.ClientboundEntityEventPacket; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.MinecraftServer; import net.minecraft.server.dedicated.DedicatedServer; -import net.minecraft.server.level.ChunkHolder; +import net.minecraft.server.level.ChunkResult; import net.minecraft.server.level.ServerChunkCache; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.progress.ChunkProgressListener; @@ -112,10 +117,10 @@ import net.minecraft.world.level.block.entity.StructureBlockEntity; import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.properties.DirectionProperty; import net.minecraft.world.level.chunk.ChunkAccess; -import net.minecraft.world.level.chunk.ChunkStatus; import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraft.world.level.chunk.status.ChunkStatus; import net.minecraft.world.level.dimension.LevelStem; -import net.minecraft.world.level.levelgen.WorldGenSettings; +import net.minecraft.world.level.levelgen.WorldOptions; import net.minecraft.world.level.storage.LevelStorageSource; import net.minecraft.world.level.storage.PrimaryLevelData; import net.minecraft.world.phys.BlockHitResult; @@ -124,13 +129,13 @@ import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World.Environment; import org.bukkit.block.data.BlockData; -import org.bukkit.craftbukkit.v1_18_R2.CraftServer; -import org.bukkit.craftbukkit.v1_18_R2.CraftWorld; -import org.bukkit.craftbukkit.v1_18_R2.block.data.CraftBlockData; -import org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer; -import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack; -import org.bukkit.craftbukkit.v1_18_R2.util.CraftMagicNumbers; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.craftbukkit.block.data.CraftBlockData; +import org.bukkit.craftbukkit.entity.CraftEntity; +import org.bukkit.craftbukkit.entity.CraftPlayer; +import org.bukkit.craftbukkit.inventory.CraftItemStack; +import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.entity.Player; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; import org.bukkit.generator.ChunkGenerator; @@ -155,7 +160,6 @@ import java.util.Set; import java.util.TreeMap; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; -import java.util.concurrent.ForkJoinPool; import java.util.logging.Level; import java.util.logging.Logger; import java.util.stream.Collectors; @@ -166,33 +170,28 @@ import static com.google.common.base.Preconditions.checkState; public final class PaperweightAdapter implements BukkitImplAdapter { - private static final Set SUPPORTED_SIDE_EFFECTS = Sets.immutableEnumSet( - SideEffect.NEIGHBORS, - SideEffect.LIGHTING, - SideEffect.VALIDATION, - SideEffect.ENTITY_AI, - SideEffect.EVENTS, - SideEffect.UPDATE - ); + private static final Codec COMPONENTS_CODEC = DataComponentPatch.CODEC.optionalFieldOf( + "components", DataComponentPatch.EMPTY + ).codec(); + + private final Logger logger = Logger.getLogger(getClass().getCanonicalName()); + private final Field serverWorldsField; private final Method getChunkFutureMethod; private final Field chunkProviderExecutorField; - private final Logger LOGGER = Logger.getLogger(getClass().getCanonicalName()); + private final Watchdog watchdog; // ------------------------------------------------------------------------ // Code that may break between versions of Minecraft // ------------------------------------------------------------------------ - private final Watchdog watchdog; - private final LoadingCache fakePlayers - = CacheBuilder.newBuilder().weakKeys().softValues().build(CacheLoader.from(PaperweightFakePlayer::new)); public PaperweightAdapter() throws NoSuchFieldException, NoSuchMethodException { // A simple test CraftServer.class.cast(Bukkit.getServer()); int dataVersion = CraftMagicNumbers.INSTANCE.getDataVersion(); - if (dataVersion != 2975) { - throw new UnsupportedClassVersionError("Not 1.18.2!"); + if (dataVersion != 3837 && dataVersion != 3839) { + throw new UnsupportedClassVersionError("Not 1.20.(5/6)!"); } serverWorldsField = CraftServer.class.getDeclaredField("worlds"); @@ -209,7 +208,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter> biomeTypeToNMSCache = new HashMap<>(); + private static final HashMap, BiomeType> biomeTypeFromNMSCache = new HashMap<>(); + @Override public WorldNativeAccess createWorldNativeAccess(org.bukkit.World world) { - return new PaperweightWorldNativeAccess( - this, - new WeakReference<>(((CraftWorld) world).getHandle()) - ); + return new PaperweightWorldNativeAccess(this, new WeakReference<>(((CraftWorld) world).getHandle())); + } + + private static net.minecraft.core.Direction adapt(Direction face) { + switch (face) { + case NORTH: + return net.minecraft.core.Direction.NORTH; + case SOUTH: + return net.minecraft.core.Direction.SOUTH; + case WEST: + return net.minecraft.core.Direction.WEST; + case EAST: + return net.minecraft.core.Direction.EAST; + case DOWN: + return net.minecraft.core.Direction.DOWN; + case UP: + default: + return net.minecraft.core.Direction.UP; + } } @SuppressWarnings({"rawtypes", "unchecked"}) @@ -429,16 +446,19 @@ public final class PaperweightAdapter implements BukkitImplAdapter (CompoundBinaryTag) toNativeBinary(tag)) ); - //FAWE end } @Nullable @@ -471,6 +491,22 @@ public final class PaperweightAdapter implements BukkitImplAdapter> PROPERTY_CACHE = CacheBuilder.newBuilder().build(new CacheLoader>() { - @Override - public Property load(net.minecraft.world.level.block.state.properties.Property state) throws Exception { - if (state instanceof net.minecraft.world.level.block.state.properties.BooleanProperty) { - return new BooleanProperty(state.getName(), ImmutableList.copyOf(state.getPossibleValues())); - } else if (state instanceof DirectionProperty) { - return new DirectionalProperty(state.getName(), - (List) state.getPossibleValues().stream().map(e -> Direction.valueOf(((StringRepresentable) e).getSerializedName().toUpperCase(Locale.ROOT))).collect(Collectors.toList())); - } else if (state instanceof net.minecraft.world.level.block.state.properties.EnumProperty) { - return new EnumProperty(state.getName(), - (List) state.getPossibleValues().stream().map(e -> ((StringRepresentable) e).getSerializedName()).collect(Collectors.toList())); - } else if (state instanceof net.minecraft.world.level.block.state.properties.IntegerProperty) { - return new IntegerProperty(state.getName(), ImmutableList.copyOf(state.getPossibleValues())); - } else { - throw new IllegalArgumentException("FastAsyncWorldEdit needs an update to support " + state.getClass().getSimpleName()); - } - } - }); + private static final LoadingCache> PROPERTY_CACHE = CacheBuilder + .newBuilder() + .build(new CacheLoader>() { + @Override + public Property load(net.minecraft.world.level.block.state.properties.Property state) throws Exception { + if (state instanceof net.minecraft.world.level.block.state.properties.BooleanProperty) { + return new BooleanProperty(state.getName(), ImmutableList.copyOf(state.getPossibleValues())); + } else if (state instanceof DirectionProperty) { + return new DirectionalProperty( + state.getName(), + (List) state + .getPossibleValues() + .stream() + .map(e -> Direction.valueOf(((StringRepresentable) e) + .getSerializedName() + .toUpperCase(Locale.ROOT))) + .collect(Collectors.toList()) + ); + } else if (state instanceof net.minecraft.world.level.block.state.properties.EnumProperty) { + return new EnumProperty( + state.getName(), + (List) state + .getPossibleValues() + .stream() + .map(e -> ((StringRepresentable) e).getSerializedName()) + .collect(Collectors.toList()) + ); + } else if (state instanceof net.minecraft.world.level.block.state.properties.IntegerProperty) { + return new IntegerProperty(state.getName(), ImmutableList.copyOf(state.getPossibleValues())); + } else { + throw new IllegalArgumentException("WorldEdit needs an update to support " + state + .getClass() + .getSimpleName()); + } + } + }); - @SuppressWarnings({ "rawtypes" }) + @SuppressWarnings({"rawtypes"}) @Override public Map> getProperties(BlockType blockType) { Map> properties = new TreeMap<>(); @@ -520,50 +574,68 @@ public final class PaperweightAdapter implements BukkitImplAdapter CompoundTag @Override public void sendFakeNBT(Player player, BlockVector3 pos, CompoundBinaryTag nbtData) { - ((CraftPlayer) player).getHandle().networkManager.send(ClientboundBlockEntityDataPacket.create( - new StructureBlockEntity( - new BlockPos(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ()), - Blocks.STRUCTURE_BLOCK.defaultBlockState() - ), - __ -> (net.minecraft.nbt.CompoundTag) fromNativeBinary(nbtData) + var structureBlock = new StructureBlockEntity( + new BlockPos(pos.getX(), pos.getY(), pos.getZ()), + Blocks.STRUCTURE_BLOCK.defaultBlockState() + ); + structureBlock.setLevel(((CraftPlayer) player).getHandle().level()); + ((CraftPlayer) player).getHandle().connection.send(ClientboundBlockEntityDataPacket.create( + structureBlock, + (blockEntity, registryAccess) -> (net.minecraft.nbt.CompoundTag) fromNativeBinary(nbtData) )); } - //FAWE end @Override public void sendFakeOP(Player player) { - ((CraftPlayer) player).getHandle().networkManager.send(new ClientboundEntityEventPacket( + ((CraftPlayer) player).getHandle().connection.send(new ClientboundEntityEventPacket( ((CraftPlayer) player).getHandle(), (byte) 28 )); } @Override public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) { - ItemStack stack = new ItemStack(Registry.ITEM.get(ResourceLocation.tryParse(item.getType().getId())), item.getAmount()); - stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(item.getNbtData()))); + final RegistryAccess.Frozen registryAccess = DedicatedServer.getServer().registryAccess(); + ItemStack stack = new ItemStack( + registryAccess.registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().getId())), + item.getAmount() + ); + final CompoundTag nbt = (net.minecraft.nbt.CompoundTag) fromNative(item.getNbtData()); + final DataComponentPatch patch = COMPONENTS_CODEC + .parse(registryAccess.createSerializationContext(NbtOps.INSTANCE), nbt) + .getOrThrow(); + stack.applyComponents(patch); return CraftItemStack.asCraftMirror(stack); } @Override public BaseItemStack adapt(org.bukkit.inventory.ItemStack itemStack) { + final RegistryAccess.Frozen registryAccess = DedicatedServer.getServer().registryAccess(); final ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack); - final BaseItemStack weStack = new BaseItemStack(BukkitAdapter.asItemType(itemStack.getType()), itemStack.getAmount()); - //FAWE start - CBT > CT - weStack.setNbt(((CompoundBinaryTag) toNativeBinary(nmsStack.getTag()))); - //FAWE end - return weStack; + final Tag tag = COMPONENTS_CODEC.encodeStart( + registryAccess.createSerializationContext(NbtOps.INSTANCE), + nmsStack.getComponentsPatch() + ).getOrThrow(); + return new BaseItemStack( + BukkitAdapter.asItemType(itemStack.getType()), + LazyReference.from(() -> (CompoundBinaryTag) toNativeBinary(tag)), + itemStack.getAmount() + ); } + private final LoadingCache fakePlayers + = CacheBuilder.newBuilder().weakKeys().softValues().build(CacheLoader.from(PaperweightFakePlayer::new)); + @Override public boolean simulateItemUse(org.bukkit.World world, BlockVector3 position, BaseItem item, Direction face) { CraftWorld craftWorld = (CraftWorld) world; ServerLevel worldServer = craftWorld.getHandle(); - ItemStack stack = CraftItemStack.asNMSCopy(BukkitAdapter.adapt(item instanceof BaseItemStack - ? ((BaseItemStack) item) : new BaseItemStack(item.getType(), item.getNbtData(), 1))); - stack.setTag((net.minecraft.nbt.CompoundTag) fromNative(item.getNbtData())); + ItemStack stack = CraftItemStack.asNMSCopy(adapt( + item instanceof BaseItemStack + ? ((BaseItemStack) item) + : new BaseItemStack(item.getType(), item.getNbtReference(), 1) + )); PaperweightFakePlayer fakePlayer; try { @@ -572,20 +644,20 @@ public final class PaperweightAdapter implements BukkitImplAdapter worldDimKey = getWorldDimKey(env); try (LevelStorageSource.LevelStorageAccess session = levelStorage.createAccess("faweregentempworld", worldDimKey)) { ServerLevel originalWorld = ((CraftWorld) bukkitWorld).getHandle(); PrimaryLevelData levelProperties = (PrimaryLevelData) originalWorld.getServer() .getWorldData().overworldData(); - WorldGenSettings originalOpts = levelProperties.worldGenSettings(); + WorldOptions originalOpts = levelProperties.worldGenOptions(); long seed = options.getSeed().orElse(originalWorld.getSeed()); - WorldGenSettings newOpts = options.getSeed().isPresent() - ? originalOpts.withSeed(levelProperties.isHardcore(), OptionalLong.of(seed)) + WorldOptions newOpts = options.getSeed().isPresent() + ? originalOpts.withSeed(OptionalLong.of(seed)) : originalOpts; LevelSettings newWorldSettings = new LevelSettings( @@ -642,23 +714,40 @@ public final class PaperweightAdapter implements BukkitImplAdapter>) + ((CompletableFuture>) getChunkFutureMethod.invoke(chunkManager, chunk.getX(), chunk.getZ(), ChunkStatus.FEATURES, true)) - .thenApply(either -> either.left().orElse(null)) + .thenApply(either -> either.orElse(null)) ); } catch (IllegalAccessException | InvocationTargetException e) { throw new IllegalStateException("Couldn't load chunk for regen.", e); @@ -769,6 +856,15 @@ public final class PaperweightAdapter implements BukkitImplAdapter SUPPORTED_SIDE_EFFECTS = Sets.immutableEnumSet( + SideEffect.NEIGHBORS, + SideEffect.LIGHTING, + SideEffect.VALIDATION, + SideEffect.ENTITY_AI, + SideEffect.EVENTS, + SideEffect.UPDATE + ); + @Override public Set getSupportedSideEffects() { return SUPPORTED_SIDE_EFFECTS; @@ -797,7 +893,6 @@ public final class PaperweightAdapter implements BukkitImplAdapter values = ListBinaryTag.builder(); + ListBinaryTag.Builder values = ListBinaryTag.builder(); for (net.minecraft.nbt.Tag tag : foreign) { values.add(toNativeBinary(tag)); @@ -895,8 +990,9 @@ public final class PaperweightAdapter implements BukkitImplAdapter. */ -package com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_18_R2; +package com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_20_R4; import com.google.common.collect.Lists; import com.google.common.collect.Maps; @@ -29,18 +29,21 @@ import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; import com.google.gson.JsonParseException; +import com.mojang.datafixers.DSL; import com.mojang.datafixers.DSL.TypeReference; import com.mojang.datafixers.DataFixer; import com.mojang.datafixers.DataFixerBuilder; import com.mojang.datafixers.schemas.Schema; import com.mojang.serialization.Dynamic; +import com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_20_R4.PaperweightAdapter; import com.sk89q.worldedit.util.nbt.CompoundBinaryTag; import net.minecraft.core.Direction; import net.minecraft.nbt.NbtOps; +import net.minecraft.nbt.StringTag; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; -import net.minecraft.network.chat.TextComponent; import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.MinecraftServer; import net.minecraft.util.GsonHelper; import net.minecraft.util.StringUtil; import net.minecraft.util.datafix.DataFixers; @@ -66,252 +69,19 @@ import javax.annotation.Nullable; /** * Handles converting all Pre 1.13.2 data using the Legacy DataFix System (ported to 1.13.2) - *

+ * * We register a DFU Fixer per Legacy Data Version and apply the fixes using legacy strategy * which is safer, faster and cleaner code. - *

+ * * The pre DFU code did not fail when the Source version was unknown. - *

+ * * This class also provides util methods for converting compounds to wrap the update call to * receive the source version in the compound */ -@SuppressWarnings({"rawtypes", "unchecked"}) -class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.worldedit.world.DataFixer { +@SuppressWarnings({ "rawtypes", "unchecked" }) +public class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.worldedit.world.DataFixer { - private static final NbtOps OPS_NBT = NbtOps.INSTANCE; - private static final int LEGACY_VERSION = 1343; - private static final Map DFU_TO_LEGACY = new HashMap<>(); - private static final Map OLD_ID_TO_KEY_MAP = new HashMap<>(); - static PaperweightDataConverters INSTANCE; - private static int DATA_VERSION; - - static { - final Map map = OLD_ID_TO_KEY_MAP; - map.put("EntityItem", new ResourceLocation("item")); - map.put("EntityExperienceOrb", new ResourceLocation("xp_orb")); - map.put("EntityAreaEffectCloud", new ResourceLocation("area_effect_cloud")); - map.put("EntityGuardianElder", new ResourceLocation("elder_guardian")); - map.put("EntitySkeletonWither", new ResourceLocation("wither_skeleton")); - map.put("EntitySkeletonStray", new ResourceLocation("stray")); - map.put("EntityEgg", new ResourceLocation("egg")); - map.put("EntityLeash", new ResourceLocation("leash_knot")); - map.put("EntityPainting", new ResourceLocation("painting")); - map.put("EntityTippedArrow", new ResourceLocation("arrow")); - map.put("EntitySnowball", new ResourceLocation("snowball")); - map.put("EntityLargeFireball", new ResourceLocation("fireball")); - map.put("EntitySmallFireball", new ResourceLocation("small_fireball")); - map.put("EntityEnderPearl", new ResourceLocation("ender_pearl")); - map.put("EntityEnderSignal", new ResourceLocation("eye_of_ender_signal")); - map.put("EntityPotion", new ResourceLocation("potion")); - map.put("EntityThrownExpBottle", new ResourceLocation("xp_bottle")); - map.put("EntityItemFrame", new ResourceLocation("item_frame")); - map.put("EntityWitherSkull", new ResourceLocation("wither_skull")); - map.put("EntityTNTPrimed", new ResourceLocation("tnt")); - map.put("EntityFallingBlock", new ResourceLocation("falling_block")); - map.put("EntityFireworks", new ResourceLocation("fireworks_rocket")); - map.put("EntityZombieHusk", new ResourceLocation("husk")); - map.put("EntitySpectralArrow", new ResourceLocation("spectral_arrow")); - map.put("EntityShulkerBullet", new ResourceLocation("shulker_bullet")); - map.put("EntityDragonFireball", new ResourceLocation("dragon_fireball")); - map.put("EntityZombieVillager", new ResourceLocation("zombie_villager")); - map.put("EntityHorseSkeleton", new ResourceLocation("skeleton_horse")); - map.put("EntityHorseZombie", new ResourceLocation("zombie_horse")); - map.put("EntityArmorStand", new ResourceLocation("armor_stand")); - map.put("EntityHorseDonkey", new ResourceLocation("donkey")); - map.put("EntityHorseMule", new ResourceLocation("mule")); - map.put("EntityEvokerFangs", new ResourceLocation("evocation_fangs")); - map.put("EntityEvoker", new ResourceLocation("evocation_illager")); - map.put("EntityVex", new ResourceLocation("vex")); - map.put("EntityVindicator", new ResourceLocation("vindication_illager")); - map.put("EntityIllagerIllusioner", new ResourceLocation("illusion_illager")); - map.put("EntityMinecartCommandBlock", new ResourceLocation("commandblock_minecart")); - map.put("EntityBoat", new ResourceLocation("boat")); - map.put("EntityMinecartRideable", new ResourceLocation("minecart")); - map.put("EntityMinecartChest", new ResourceLocation("chest_minecart")); - map.put("EntityMinecartFurnace", new ResourceLocation("furnace_minecart")); - map.put("EntityMinecartTNT", new ResourceLocation("tnt_minecart")); - map.put("EntityMinecartHopper", new ResourceLocation("hopper_minecart")); - map.put("EntityMinecartMobSpawner", new ResourceLocation("spawner_minecart")); - map.put("EntityCreeper", new ResourceLocation("creeper")); - map.put("EntitySkeleton", new ResourceLocation("skeleton")); - map.put("EntitySpider", new ResourceLocation("spider")); - map.put("EntityGiantZombie", new ResourceLocation("giant")); - map.put("EntityZombie", new ResourceLocation("zombie")); - map.put("EntitySlime", new ResourceLocation("slime")); - map.put("EntityGhast", new ResourceLocation("ghast")); - map.put("EntityPigZombie", new ResourceLocation("zombie_pigman")); - map.put("EntityEnderman", new ResourceLocation("enderman")); - map.put("EntityCaveSpider", new ResourceLocation("cave_spider")); - map.put("EntitySilverfish", new ResourceLocation("silverfish")); - map.put("EntityBlaze", new ResourceLocation("blaze")); - map.put("EntityMagmaCube", new ResourceLocation("magma_cube")); - map.put("EntityEnderDragon", new ResourceLocation("ender_dragon")); - map.put("EntityWither", new ResourceLocation("wither")); - map.put("EntityBat", new ResourceLocation("bat")); - map.put("EntityWitch", new ResourceLocation("witch")); - map.put("EntityEndermite", new ResourceLocation("endermite")); - map.put("EntityGuardian", new ResourceLocation("guardian")); - map.put("EntityShulker", new ResourceLocation("shulker")); - map.put("EntityPig", new ResourceLocation("pig")); - map.put("EntitySheep", new ResourceLocation("sheep")); - map.put("EntityCow", new ResourceLocation("cow")); - map.put("EntityChicken", new ResourceLocation("chicken")); - map.put("EntitySquid", new ResourceLocation("squid")); - map.put("EntityWolf", new ResourceLocation("wolf")); - map.put("EntityMushroomCow", new ResourceLocation("mooshroom")); - map.put("EntitySnowman", new ResourceLocation("snowman")); - map.put("EntityOcelot", new ResourceLocation("ocelot")); - map.put("EntityIronGolem", new ResourceLocation("villager_golem")); - map.put("EntityHorse", new ResourceLocation("horse")); - map.put("EntityRabbit", new ResourceLocation("rabbit")); - map.put("EntityPolarBear", new ResourceLocation("polar_bear")); - map.put("EntityLlama", new ResourceLocation("llama")); - map.put("EntityLlamaSpit", new ResourceLocation("llama_spit")); - map.put("EntityParrot", new ResourceLocation("parrot")); - map.put("EntityVillager", new ResourceLocation("villager")); - map.put("EntityEnderCrystal", new ResourceLocation("ender_crystal")); - map.put("TileEntityFurnace", new ResourceLocation("furnace")); - map.put("TileEntityChest", new ResourceLocation("chest")); - map.put("TileEntityEnderChest", new ResourceLocation("ender_chest")); - map.put("TileEntityRecordPlayer", new ResourceLocation("jukebox")); - map.put("TileEntityDispenser", new ResourceLocation("dispenser")); - map.put("TileEntityDropper", new ResourceLocation("dropper")); - map.put("TileEntitySign", new ResourceLocation("sign")); - map.put("TileEntityMobSpawner", new ResourceLocation("mob_spawner")); - map.put("TileEntityNote", new ResourceLocation("noteblock")); - map.put("TileEntityPiston", new ResourceLocation("piston")); - map.put("TileEntityBrewingStand", new ResourceLocation("brewing_stand")); - map.put("TileEntityEnchantTable", new ResourceLocation("enchanting_table")); - map.put("TileEntityEnderPortal", new ResourceLocation("end_portal")); - map.put("TileEntityBeacon", new ResourceLocation("beacon")); - map.put("TileEntitySkull", new ResourceLocation("skull")); - map.put("TileEntityLightDetector", new ResourceLocation("daylight_detector")); - map.put("TileEntityHopper", new ResourceLocation("hopper")); - map.put("TileEntityComparator", new ResourceLocation("comparator")); - map.put("TileEntityFlowerPot", new ResourceLocation("flower_pot")); - map.put("TileEntityBanner", new ResourceLocation("banner")); - map.put("TileEntityStructure", new ResourceLocation("structure_block")); - map.put("TileEntityEndGateway", new ResourceLocation("end_gateway")); - map.put("TileEntityCommand", new ResourceLocation("command_block")); - map.put("TileEntityShulkerBox", new ResourceLocation("shulker_box")); - map.put("TileEntityBed", new ResourceLocation("bed")); - } - - private final PaperweightAdapter adapter; - private final Map> converters = new EnumMap<>(LegacyType.class); - private final Map> inspectors = new EnumMap<>(LegacyType.class); - // Set on build - private DataFixer fixer; - - PaperweightDataConverters(int dataVersion, PaperweightAdapter adapter) { - super(dataVersion); - DATA_VERSION = dataVersion; - INSTANCE = this; - this.adapter = adapter; - registerConverters(); - registerInspectors(); - } - - private static net.minecraft.nbt.CompoundTag stateToNBT(String blockState) { - int propIdx = blockState.indexOf('['); - net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag(); - if (propIdx < 0) { - tag.putString("Name", blockState); - } else { - tag.putString("Name", blockState.substring(0, propIdx)); - net.minecraft.nbt.CompoundTag propTag = new net.minecraft.nbt.CompoundTag(); - String props = blockState.substring(propIdx + 1, blockState.length() - 1); - String[] propArr = props.split(","); - for (String pair : propArr) { - final String[] split = pair.split("="); - propTag.putString(split[0], split[1]); - } - tag.put("Properties", propTag); - } - return tag; - } - - private static String fixName(String key, int srcVer, TypeReference type) { - return INSTANCE.fixer.update(type, new Dynamic<>(OPS_NBT, net.minecraft.nbt.StringTag.valueOf(key)), srcVer, DATA_VERSION) - .getValue().getAsString(); - } - - public static net.minecraft.nbt.CompoundTag convert(LegacyType type, net.minecraft.nbt.CompoundTag cmp) { - return convert(type.getDFUType(), cmp); - } - - public static net.minecraft.nbt.CompoundTag convert(LegacyType type, net.minecraft.nbt.CompoundTag cmp, int sourceVer) { - return convert(type.getDFUType(), cmp, sourceVer); - } - - public static net.minecraft.nbt.CompoundTag convert( - LegacyType type, - net.minecraft.nbt.CompoundTag cmp, - int sourceVer, - int targetVer - ) { - return convert(type.getDFUType(), cmp, sourceVer, targetVer); - } - - public static net.minecraft.nbt.CompoundTag convert(TypeReference type, net.minecraft.nbt.CompoundTag cmp) { - int i = cmp.contains("DataVersion", 99) ? cmp.getInt("DataVersion") : -1; - return convert(type, cmp, i); - } - - public static net.minecraft.nbt.CompoundTag convert(TypeReference type, net.minecraft.nbt.CompoundTag cmp, int sourceVer) { - return convert(type, cmp, sourceVer, DATA_VERSION); - } - - public static net.minecraft.nbt.CompoundTag convert( - TypeReference type, - net.minecraft.nbt.CompoundTag cmp, - int sourceVer, - int targetVer - ) { - if (sourceVer >= targetVer) { - return cmp; - } - return (net.minecraft.nbt.CompoundTag) INSTANCE.fixer - .update(type, new Dynamic<>(OPS_NBT, cmp), sourceVer, targetVer) - .getValue(); - } - - private static ResourceLocation getKey(String type) { - final ResourceLocation key = OLD_ID_TO_KEY_MAP.get(type); - if (key == null) { - throw new IllegalArgumentException("Unknown mapping for " + type); - } - return key; - } - - private static void convertCompound( - LegacyType type, - net.minecraft.nbt.CompoundTag cmp, - String key, - int sourceVer, - int targetVer - ) { - cmp.put(key, convert(type, cmp.getCompound(key), sourceVer, targetVer)); - } - - private static void convertItem(net.minecraft.nbt.CompoundTag nbttagcompound, String key, int sourceVer, int targetVer) { - if (nbttagcompound.contains(key, 10)) { - convertCompound(LegacyType.ITEM_INSTANCE, nbttagcompound, key, sourceVer, targetVer); - } - } - - private static void convertItems(net.minecraft.nbt.CompoundTag nbttagcompound, String key, int sourceVer, int targetVer) { - if (nbttagcompound.contains(key, 9)) { - net.minecraft.nbt.ListTag nbttaglist = nbttagcompound.getList(key, 10); - - for (int j = 0; j < nbttaglist.size(); ++j) { - nbttaglist.set(j, convert(LegacyType.ITEM_INSTANCE, nbttaglist.getCompound(j), sourceVer, targetVer)); - } - } - - } - - //FAWE start - CBT > CT + //FAWE start - BinaryTag @SuppressWarnings("unchecked") @Override public T fixUp(FixType type, T original, int srcVer) { @@ -353,12 +123,7 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo private String fixBlockState(String blockState, int srcVer) { net.minecraft.nbt.CompoundTag stateNBT = stateToNBT(blockState); Dynamic dynamic = new Dynamic<>(OPS_NBT, stateNBT); - net.minecraft.nbt.CompoundTag fixed = (net.minecraft.nbt.CompoundTag) INSTANCE.fixer.update( - References.BLOCK_STATE, - dynamic, - srcVer, - DATA_VERSION - ).getValue(); + net.minecraft.nbt.CompoundTag fixed = (net.minecraft.nbt.CompoundTag) INSTANCE.fixer.update(References.BLOCK_STATE, dynamic, srcVer, DATA_VERSION).getValue(); return nbtToState(fixed); } @@ -368,16 +133,31 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo if (tagCompound.contains("Properties", 10)) { sb.append('['); net.minecraft.nbt.CompoundTag props = tagCompound.getCompound("Properties"); - sb.append(props - .getAllKeys() - .stream() - .map(k -> k + "=" + props.getString(k).replace("\"", "")) - .collect(Collectors.joining(","))); + sb.append(props.getAllKeys().stream().map(k -> k + "=" + props.getString(k).replace("\"", "")).collect(Collectors.joining(","))); sb.append(']'); } return sb.toString(); } + private static net.minecraft.nbt.CompoundTag stateToNBT(String blockState) { + int propIdx = blockState.indexOf('['); + net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag(); + if (propIdx < 0) { + tag.putString("Name", blockState); + } else { + tag.putString("Name", blockState.substring(0, propIdx)); + net.minecraft.nbt.CompoundTag propTag = new net.minecraft.nbt.CompoundTag(); + String props = blockState.substring(propIdx + 1, blockState.length() - 1); + String[] propArr = props.split(","); + for (String pair : propArr) { + final String[] split = pair.split("="); + propTag.putString(split[0], split[1]); + } + tag.put("Properties", propTag); + } + return tag; + } + private String fixBiome(String key, int srcVer) { return fixName(key, srcVer, References.BIOME); } @@ -386,12 +166,158 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo return fixName(key, srcVer, References.ITEM_NAME); } + private static String fixName(String key, int srcVer, TypeReference type) { + return INSTANCE.fixer.update(type, new Dynamic<>(OPS_NBT, net.minecraft.nbt.StringTag.valueOf(key)), srcVer, DATA_VERSION) + .getValue().getAsString(); + } + + private final PaperweightAdapter adapter; + + private static final NbtOps OPS_NBT = NbtOps.INSTANCE; + private static final int LEGACY_VERSION = 1343; + private static int DATA_VERSION; + public static PaperweightDataConverters INSTANCE; + + private final Map> converters = new EnumMap<>(LegacyType.class); + private final Map> inspectors = new EnumMap<>(LegacyType.class); + + // Set on build + private DataFixer fixer; + private static final Map DFU_TO_LEGACY = new HashMap<>(); + + public enum LegacyType { + LEVEL(References.LEVEL), + PLAYER(References.PLAYER), + CHUNK(References.CHUNK), + BLOCK_ENTITY(References.BLOCK_ENTITY), + ENTITY(References.ENTITY), + ITEM_INSTANCE(References.ITEM_STACK), + OPTIONS(References.OPTIONS), + STRUCTURE(References.STRUCTURE); + + private final TypeReference type; + + LegacyType(TypeReference type) { + this.type = type; + DFU_TO_LEGACY.put(type.typeName(), this); + } + + public TypeReference getDFUType() { + return type; + } + } + + public PaperweightDataConverters(int dataVersion, PaperweightAdapter adapter) { + super(dataVersion); + DATA_VERSION = dataVersion; + INSTANCE = this; + this.adapter = adapter; + registerConverters(); + registerInspectors(); + } + + // Called after fixers are built and ready for FIXING @Override - public DataFixer build(final Executor executor) { + public DataFixer buildUnoptimized() { return this.fixer = new WrappedDataFixer(DataFixers.getDataFixer()); } + @Override + public DataFixer buildOptimized(final Set requiredTypes, Executor executor) { + return buildUnoptimized(); + } + + @SuppressWarnings("unchecked") + private class WrappedDataFixer implements DataFixer { + private final DataFixer realFixer; + + WrappedDataFixer(DataFixer realFixer) { + this.realFixer = realFixer; + } + + @Override + public Dynamic update(TypeReference type, Dynamic dynamic, int sourceVer, int targetVer) { + LegacyType legacyType = DFU_TO_LEGACY.get(type.typeName()); + if (sourceVer < LEGACY_VERSION && legacyType != null) { + net.minecraft.nbt.CompoundTag cmp = (net.minecraft.nbt.CompoundTag) dynamic.getValue(); + int desiredVersion = Math.min(targetVer, LEGACY_VERSION); + + cmp = convert(legacyType, cmp, sourceVer, desiredVersion); + sourceVer = desiredVersion; + dynamic = new Dynamic(OPS_NBT, cmp); + } + return realFixer.update(type, dynamic, sourceVer, targetVer); + } + + private net.minecraft.nbt.CompoundTag convert(LegacyType type, net.minecraft.nbt.CompoundTag cmp, int sourceVer, int desiredVersion) { + List converters = PaperweightDataConverters.this.converters.get(type); + if (converters != null && !converters.isEmpty()) { + for (DataConverter converter : converters) { + int dataVersion = converter.getDataVersion(); + if (dataVersion > sourceVer && dataVersion <= desiredVersion) { + cmp = converter.convert(cmp); + } + } + } + + List inspectors = PaperweightDataConverters.this.inspectors.get(type); + if (inspectors != null && !inspectors.isEmpty()) { + for (DataInspector inspector : inspectors) { + cmp = inspector.inspect(cmp, sourceVer, desiredVersion); + } + } + + return cmp; + } + + @Override + public Schema getSchema(int i) { + return realFixer.getSchema(i); + } + } + + public static net.minecraft.nbt.CompoundTag convert(LegacyType type, net.minecraft.nbt.CompoundTag cmp) { + return convert(type.getDFUType(), cmp); + } + + public static net.minecraft.nbt.CompoundTag convert(LegacyType type, net.minecraft.nbt.CompoundTag cmp, int sourceVer) { + return convert(type.getDFUType(), cmp, sourceVer); + } + + public static net.minecraft.nbt.CompoundTag convert(LegacyType type, net.minecraft.nbt.CompoundTag cmp, int sourceVer, int targetVer) { + return convert(type.getDFUType(), cmp, sourceVer, targetVer); + } + + public static net.minecraft.nbt.CompoundTag convert(TypeReference type, net.minecraft.nbt.CompoundTag cmp) { + int i = cmp.contains("DataVersion", 99) ? cmp.getInt("DataVersion") : -1; + return convert(type, cmp, i); + } + + public static net.minecraft.nbt.CompoundTag convert(TypeReference type, net.minecraft.nbt.CompoundTag cmp, int sourceVer) { + return convert(type, cmp, sourceVer, DATA_VERSION); + } + + public static net.minecraft.nbt.CompoundTag convert(TypeReference type, net.minecraft.nbt.CompoundTag cmp, int sourceVer, int targetVer) { + if (sourceVer >= targetVer) { + return cmp; + } + return (net.minecraft.nbt.CompoundTag) INSTANCE.fixer.update(type, new Dynamic<>(OPS_NBT, cmp), sourceVer, targetVer).getValue(); + } + + + public interface DataInspector { + net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp, int sourceVer, int targetVer); + } + + public interface DataConverter { + + int getDataVersion(); + + net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp); + } + + private void registerInspector(LegacyType type, DataInspector inspector) { this.inspectors.computeIfAbsent(type, k -> new ArrayList<>()).add(inspector); } @@ -544,39 +470,146 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo registerEntityItemList(type, "ArmorItems", "HandItems"); } - public enum LegacyType { - LEVEL(References.LEVEL), - PLAYER(References.PLAYER), - CHUNK(References.CHUNK), - BLOCK_ENTITY(References.BLOCK_ENTITY), - ENTITY(References.ENTITY), - ITEM_INSTANCE(References.ITEM_STACK), - OPTIONS(References.OPTIONS), - STRUCTURE(References.STRUCTURE); + private static final Map OLD_ID_TO_KEY_MAP = new HashMap<>(); - private final TypeReference type; + static { + final Map map = OLD_ID_TO_KEY_MAP; + map.put("EntityItem", new ResourceLocation("item")); + map.put("EntityExperienceOrb", new ResourceLocation("xp_orb")); + map.put("EntityAreaEffectCloud", new ResourceLocation("area_effect_cloud")); + map.put("EntityGuardianElder", new ResourceLocation("elder_guardian")); + map.put("EntitySkeletonWither", new ResourceLocation("wither_skeleton")); + map.put("EntitySkeletonStray", new ResourceLocation("stray")); + map.put("EntityEgg", new ResourceLocation("egg")); + map.put("EntityLeash", new ResourceLocation("leash_knot")); + map.put("EntityPainting", new ResourceLocation("painting")); + map.put("EntityTippedArrow", new ResourceLocation("arrow")); + map.put("EntitySnowball", new ResourceLocation("snowball")); + map.put("EntityLargeFireball", new ResourceLocation("fireball")); + map.put("EntitySmallFireball", new ResourceLocation("small_fireball")); + map.put("EntityEnderPearl", new ResourceLocation("ender_pearl")); + map.put("EntityEnderSignal", new ResourceLocation("eye_of_ender_signal")); + map.put("EntityPotion", new ResourceLocation("potion")); + map.put("EntityThrownExpBottle", new ResourceLocation("xp_bottle")); + map.put("EntityItemFrame", new ResourceLocation("item_frame")); + map.put("EntityWitherSkull", new ResourceLocation("wither_skull")); + map.put("EntityTNTPrimed", new ResourceLocation("tnt")); + map.put("EntityFallingBlock", new ResourceLocation("falling_block")); + map.put("EntityFireworks", new ResourceLocation("fireworks_rocket")); + map.put("EntityZombieHusk", new ResourceLocation("husk")); + map.put("EntitySpectralArrow", new ResourceLocation("spectral_arrow")); + map.put("EntityShulkerBullet", new ResourceLocation("shulker_bullet")); + map.put("EntityDragonFireball", new ResourceLocation("dragon_fireball")); + map.put("EntityZombieVillager", new ResourceLocation("zombie_villager")); + map.put("EntityHorseSkeleton", new ResourceLocation("skeleton_horse")); + map.put("EntityHorseZombie", new ResourceLocation("zombie_horse")); + map.put("EntityArmorStand", new ResourceLocation("armor_stand")); + map.put("EntityHorseDonkey", new ResourceLocation("donkey")); + map.put("EntityHorseMule", new ResourceLocation("mule")); + map.put("EntityEvokerFangs", new ResourceLocation("evocation_fangs")); + map.put("EntityEvoker", new ResourceLocation("evocation_illager")); + map.put("EntityVex", new ResourceLocation("vex")); + map.put("EntityVindicator", new ResourceLocation("vindication_illager")); + map.put("EntityIllagerIllusioner", new ResourceLocation("illusion_illager")); + map.put("EntityMinecartCommandBlock", new ResourceLocation("commandblock_minecart")); + map.put("EntityBoat", new ResourceLocation("boat")); + map.put("EntityMinecartRideable", new ResourceLocation("minecart")); + map.put("EntityMinecartChest", new ResourceLocation("chest_minecart")); + map.put("EntityMinecartFurnace", new ResourceLocation("furnace_minecart")); + map.put("EntityMinecartTNT", new ResourceLocation("tnt_minecart")); + map.put("EntityMinecartHopper", new ResourceLocation("hopper_minecart")); + map.put("EntityMinecartMobSpawner", new ResourceLocation("spawner_minecart")); + map.put("EntityCreeper", new ResourceLocation("creeper")); + map.put("EntitySkeleton", new ResourceLocation("skeleton")); + map.put("EntitySpider", new ResourceLocation("spider")); + map.put("EntityGiantZombie", new ResourceLocation("giant")); + map.put("EntityZombie", new ResourceLocation("zombie")); + map.put("EntitySlime", new ResourceLocation("slime")); + map.put("EntityGhast", new ResourceLocation("ghast")); + map.put("EntityPigZombie", new ResourceLocation("zombie_pigman")); + map.put("EntityEnderman", new ResourceLocation("enderman")); + map.put("EntityCaveSpider", new ResourceLocation("cave_spider")); + map.put("EntitySilverfish", new ResourceLocation("silverfish")); + map.put("EntityBlaze", new ResourceLocation("blaze")); + map.put("EntityMagmaCube", new ResourceLocation("magma_cube")); + map.put("EntityEnderDragon", new ResourceLocation("ender_dragon")); + map.put("EntityWither", new ResourceLocation("wither")); + map.put("EntityBat", new ResourceLocation("bat")); + map.put("EntityWitch", new ResourceLocation("witch")); + map.put("EntityEndermite", new ResourceLocation("endermite")); + map.put("EntityGuardian", new ResourceLocation("guardian")); + map.put("EntityShulker", new ResourceLocation("shulker")); + map.put("EntityPig", new ResourceLocation("pig")); + map.put("EntitySheep", new ResourceLocation("sheep")); + map.put("EntityCow", new ResourceLocation("cow")); + map.put("EntityChicken", new ResourceLocation("chicken")); + map.put("EntitySquid", new ResourceLocation("squid")); + map.put("EntityWolf", new ResourceLocation("wolf")); + map.put("EntityMushroomCow", new ResourceLocation("mooshroom")); + map.put("EntitySnowman", new ResourceLocation("snowman")); + map.put("EntityOcelot", new ResourceLocation("ocelot")); + map.put("EntityIronGolem", new ResourceLocation("villager_golem")); + map.put("EntityHorse", new ResourceLocation("horse")); + map.put("EntityRabbit", new ResourceLocation("rabbit")); + map.put("EntityPolarBear", new ResourceLocation("polar_bear")); + map.put("EntityLlama", new ResourceLocation("llama")); + map.put("EntityLlamaSpit", new ResourceLocation("llama_spit")); + map.put("EntityParrot", new ResourceLocation("parrot")); + map.put("EntityVillager", new ResourceLocation("villager")); + map.put("EntityEnderCrystal", new ResourceLocation("ender_crystal")); + map.put("TileEntityFurnace", new ResourceLocation("furnace")); + map.put("TileEntityChest", new ResourceLocation("chest")); + map.put("TileEntityEnderChest", new ResourceLocation("ender_chest")); + map.put("TileEntityRecordPlayer", new ResourceLocation("jukebox")); + map.put("TileEntityDispenser", new ResourceLocation("dispenser")); + map.put("TileEntityDropper", new ResourceLocation("dropper")); + map.put("TileEntitySign", new ResourceLocation("sign")); + map.put("TileEntityMobSpawner", new ResourceLocation("mob_spawner")); + map.put("TileEntityNote", new ResourceLocation("noteblock")); + map.put("TileEntityPiston", new ResourceLocation("piston")); + map.put("TileEntityBrewingStand", new ResourceLocation("brewing_stand")); + map.put("TileEntityEnchantTable", new ResourceLocation("enchanting_table")); + map.put("TileEntityEnderPortal", new ResourceLocation("end_portal")); + map.put("TileEntityBeacon", new ResourceLocation("beacon")); + map.put("TileEntitySkull", new ResourceLocation("skull")); + map.put("TileEntityLightDetector", new ResourceLocation("daylight_detector")); + map.put("TileEntityHopper", new ResourceLocation("hopper")); + map.put("TileEntityComparator", new ResourceLocation("comparator")); + map.put("TileEntityFlowerPot", new ResourceLocation("flower_pot")); + map.put("TileEntityBanner", new ResourceLocation("banner")); + map.put("TileEntityStructure", new ResourceLocation("structure_block")); + map.put("TileEntityEndGateway", new ResourceLocation("end_gateway")); + map.put("TileEntityCommand", new ResourceLocation("command_block")); + map.put("TileEntityShulkerBox", new ResourceLocation("shulker_box")); + map.put("TileEntityBed", new ResourceLocation("bed")); + } - LegacyType(TypeReference type) { - this.type = type; - DFU_TO_LEGACY.put(type.typeName(), this); + private static ResourceLocation getKey(String type) { + final ResourceLocation key = OLD_ID_TO_KEY_MAP.get(type); + if (key == null) { + throw new IllegalArgumentException("Unknown mapping for " + type); } + return key; + } - public TypeReference getDFUType() { - return type; + private static void convertCompound(LegacyType type, net.minecraft.nbt.CompoundTag cmp, String key, int sourceVer, int targetVer) { + cmp.put(key, convert(type, cmp.getCompound(key), sourceVer, targetVer)); + } + + private static void convertItem(net.minecraft.nbt.CompoundTag nbttagcompound, String key, int sourceVer, int targetVer) { + if (nbttagcompound.contains(key, 10)) { + convertCompound(LegacyType.ITEM_INSTANCE, nbttagcompound, key, sourceVer, targetVer); } } - public interface DataInspector { + private static void convertItems(net.minecraft.nbt.CompoundTag nbttagcompound, String key, int sourceVer, int targetVer) { + if (nbttagcompound.contains(key, 9)) { + net.minecraft.nbt.ListTag nbttaglist = nbttagcompound.getList(key, 10); - net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp, int sourceVer, int targetVer); - - } - - public interface DataConverter { - - int getDataVersion(); - - net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp); + for (int j = 0; j < nbttaglist.size(); ++j) { + nbttaglist.set(j, convert(LegacyType.ITEM_INSTANCE, nbttaglist.getCompound(j), sourceVer, targetVer)); + } + } } @@ -635,7 +668,6 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo return cmp; } - } private static class DataInspectorBlockEntity implements DataInspector { @@ -643,6 +675,50 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo private static final Map b = Maps.newHashMap(); private static final Map c = Maps.newHashMap(); + DataInspectorBlockEntity() { + } + + @Nullable + private static String convertEntityId(int i, String s) { + String key = new ResourceLocation(s).toString(); + if (i < 515 && DataInspectorBlockEntity.b.containsKey(key)) { + return DataInspectorBlockEntity.b.get(key); + } else { + return DataInspectorBlockEntity.c.get(key); + } + } + + public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp, int sourceVer, int targetVer) { + if (!cmp.contains("tag", 10)) { + return cmp; + } else { + net.minecraft.nbt.CompoundTag nbttagcompound1 = cmp.getCompound("tag"); + + if (nbttagcompound1.contains("BlockEntityTag", 10)) { + net.minecraft.nbt.CompoundTag nbttagcompound2 = nbttagcompound1.getCompound("BlockEntityTag"); + String s = cmp.getString("id"); + String s1 = convertEntityId(sourceVer, s); + boolean flag; + + if (s1 == null) { + // CraftBukkit - Remove unnecessary warning (occurs when deserializing a Shulker Box item) + // DataInspectorBlockEntity.a.warn("Unable to resolve BlockEntity for ItemInstance: {}", s); + flag = false; + } else { + flag = !nbttagcompound2.contains("id"); + nbttagcompound2.putString("id", s1); + } + + convert(LegacyType.BLOCK_ENTITY, nbttagcompound2, sourceVer, targetVer); + if (flag) { + nbttagcompound2.remove("id"); + } + } + + return cmp; + } + } + static { Map map = DataInspectorBlockEntity.b; @@ -734,56 +810,10 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo map.put("minecraft:end_gateway", "minecraft:end_gateway"); map.put("minecraft:shield", "minecraft:shield"); } - - DataInspectorBlockEntity() { - } - - @Nullable - private static String convertEntityId(int i, String s) { - String key = new ResourceLocation(s).toString(); - if (i < 515 && DataInspectorBlockEntity.b.containsKey(key)) { - return DataInspectorBlockEntity.b.get(key); - } else { - return DataInspectorBlockEntity.c.get(key); - } - } - - public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp, int sourceVer, int targetVer) { - if (!cmp.contains("tag", 10)) { - return cmp; - } else { - net.minecraft.nbt.CompoundTag nbttagcompound1 = cmp.getCompound("tag"); - - if (nbttagcompound1.contains("BlockEntityTag", 10)) { - net.minecraft.nbt.CompoundTag nbttagcompound2 = nbttagcompound1.getCompound("BlockEntityTag"); - String s = cmp.getString("id"); - String s1 = convertEntityId(sourceVer, s); - boolean flag; - - if (s1 == null) { - // CraftBukkit - Remove unnecessary warning (occurs when deserializing a Shulker Box item) - // DataInspectorBlockEntity.a.warn("Unable to resolve BlockEntity for ItemInstance: {}", s); - flag = false; - } else { - flag = !nbttagcompound2.contains("id"); - nbttagcompound2.putString("id", s1); - } - - convert(LegacyType.BLOCK_ENTITY, nbttagcompound2, sourceVer, targetVer); - if (flag) { - nbttagcompound2.remove("id"); - } - } - - return cmp; - } - } } private static class DataInspectorEntity implements DataInspector { - private static final Logger a = LogManager.getLogger(PaperweightDataConverters.class); - DataInspectorEntity() { } @@ -818,9 +848,9 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo return cmp; } - } + private abstract static class DataInspectorTagged implements DataInspector { private final ResourceLocation key; @@ -837,12 +867,7 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo return cmp; } - abstract net.minecraft.nbt.CompoundTag inspectChecked( - net.minecraft.nbt.CompoundTag nbttagcompound, - int sourceVer, - int targetVer - ); - + abstract net.minecraft.nbt.CompoundTag inspectChecked(net.minecraft.nbt.CompoundTag nbttagcompound, int sourceVer, int targetVer); } private static class DataInspectorItemList extends DataInspectorTagged { @@ -861,7 +886,6 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo return nbttagcompound; } - } private static class DataInspectorItem extends DataInspectorTagged { @@ -880,13 +904,31 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo return nbttagcompound; } - } private static class DataConverterMaterialId implements DataConverter { private static final String[] materials = new String[2268]; + DataConverterMaterialId() { + } + + public int getDataVersion() { + return 102; + } + + public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) { + if (cmp.contains("id", 99)) { + short short0 = cmp.getShort("id"); + + if (short0 > 0 && short0 < materials.length && materials[short0] != null) { + cmp.putString("id", materials[short0]); + } + } + + return cmp; + } + static { materials[1] = "minecraft:stone"; materials[2] = "minecraft:grass"; @@ -1244,25 +1286,6 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo materials[453] = "minecraft:knowledge_book"; // Paper end } - - DataConverterMaterialId() { - } - - public int getDataVersion() { - return 102; - } - - public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) { - if (cmp.contains("id", 99)) { - short short0 = cmp.getShort("id"); - - if (short0 > 0 && short0 < materials.length && materials[short0] != null) { - cmp.putString("id", materials[short0]); - } - } - - return cmp; - } } private static class DataConverterArmorStand implements DataConverter { @@ -1281,7 +1304,6 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo return cmp; } - } private static class DataConverterBanner implements DataConverter { @@ -1328,13 +1350,42 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo return cmp; } - } private static class DataConverterPotionId implements DataConverter { private static final String[] potions = new String[128]; + DataConverterPotionId() { + } + + public int getDataVersion() { + return 102; + } + + public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) { + if ("minecraft:potion".equals(cmp.getString("id"))) { + net.minecraft.nbt.CompoundTag nbttagcompound1 = cmp.getCompound("tag"); + short short0 = cmp.getShort("Damage"); + + if (!nbttagcompound1.contains("Potion", 8)) { + String s = DataConverterPotionId.potions[short0 & 127]; + + nbttagcompound1.putString("Potion", s == null ? "minecraft:water" : s); + cmp.put("tag", nbttagcompound1); + if ((short0 & 16384) == 16384) { + cmp.putString("id", "minecraft:splash_potion"); + } + } + + if (short0 != 0) { + cmp.putShort("Damage", (short) 0); + } + } + + return cmp; + } + static { DataConverterPotionId.potions[0] = "minecraft:water"; DataConverterPotionId.potions[1] = "minecraft:regeneration"; @@ -1465,26 +1516,32 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo DataConverterPotionId.potions[126] = "minecraft:long_invisibility"; DataConverterPotionId.potions[127] = null; } + } - DataConverterPotionId() { + private static class DataConverterSpawnEgg implements DataConverter { + + private static final String[] eggs = new String[256]; + + DataConverterSpawnEgg() { } public int getDataVersion() { - return 102; + return 105; } public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) { - if ("minecraft:potion".equals(cmp.getString("id"))) { + if ("minecraft:spawn_egg".equals(cmp.getString("id"))) { net.minecraft.nbt.CompoundTag nbttagcompound1 = cmp.getCompound("tag"); + net.minecraft.nbt.CompoundTag nbttagcompound2 = nbttagcompound1.getCompound("EntityTag"); short short0 = cmp.getShort("Damage"); - if (!nbttagcompound1.contains("Potion", 8)) { - String s = DataConverterPotionId.potions[short0 & 127]; + if (!nbttagcompound2.contains("id", 8)) { + String s = DataConverterSpawnEgg.eggs[short0 & 255]; - nbttagcompound1.putString("Potion", s == null ? "minecraft:water" : s); - cmp.put("tag", nbttagcompound1); - if ((short0 & 16384) == 16384) { - cmp.putString("id", "minecraft:splash_potion"); + if (s != null) { + nbttagcompound2.putString("id", s); + nbttagcompound1.put("EntityTag", nbttagcompound2); + cmp.put("tag", nbttagcompound1); } } @@ -1495,11 +1552,6 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo return cmp; } - } - - private static class DataConverterSpawnEgg implements DataConverter { - - private static final String[] eggs = new String[256]; static { @@ -1571,50 +1623,11 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo DataConverterSpawnEgg.eggs[120] = "Villager"; DataConverterSpawnEgg.eggs[200] = "EnderCrystal"; } - - DataConverterSpawnEgg() { - } - - public int getDataVersion() { - return 105; - } - - public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) { - if ("minecraft:spawn_egg".equals(cmp.getString("id"))) { - net.minecraft.nbt.CompoundTag nbttagcompound1 = cmp.getCompound("tag"); - net.minecraft.nbt.CompoundTag nbttagcompound2 = nbttagcompound1.getCompound("EntityTag"); - short short0 = cmp.getShort("Damage"); - - if (!nbttagcompound2.contains("id", 8)) { - String s = DataConverterSpawnEgg.eggs[short0 & 255]; - - if (s != null) { - nbttagcompound2.putString("id", s); - nbttagcompound1.put("EntityTag", nbttagcompound2); - cmp.put("tag", nbttagcompound1); - } - } - - if (short0 != 0) { - cmp.putShort("Damage", (short) 0); - } - } - - return cmp; - } } private static class DataConverterMinecart implements DataConverter { - private static final List a = Lists.newArrayList( - "MinecartRideable", - "MinecartChest", - "MinecartFurnace", - "MinecartTNT", - "MinecartSpawner", - "MinecartHopper", - "MinecartCommandBlock" - ); + private static final List a = Lists.newArrayList("MinecartRideable", "MinecartChest", "MinecartFurnace", "MinecartTNT", "MinecartSpawner", "MinecartHopper", "MinecartCommandBlock"); DataConverterMinecart() { } @@ -1638,7 +1651,6 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo return cmp; } - } private static class DataConverterMobSpawner implements DataConverter { @@ -1683,7 +1695,6 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo return cmp; } } - } private static class DataConverterUUID implements DataConverter { @@ -1702,47 +1713,11 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo return cmp; } - } private static class DataConverterHealth implements DataConverter { - private static final Set a = Sets.newHashSet( - "ArmorStand", - "Bat", - "Blaze", - "CaveSpider", - "Chicken", - "Cow", - "Creeper", - "EnderDragon", - "Enderman", - "Endermite", - "EntityHorse", - "Ghast", - "Giant", - "Guardian", - "LavaSlime", - "MushroomCow", - "Ozelot", - "Pig", - "PigZombie", - "Rabbit", - "Sheep", - "Shulker", - "Silverfish", - "Skeleton", - "Slime", - "SnowMan", - "Spider", - "Squid", - "Villager", - "VillagerGolem", - "Witch", - "WitherBoss", - "Wolf", - "Zombie" - ); + private static final Set a = Sets.newHashSet("ArmorStand", "Bat", "Blaze", "CaveSpider", "Chicken", "Cow", "Creeper", "EnderDragon", "Enderman", "Endermite", "EntityHorse", "Ghast", "Giant", "Guardian", "LavaSlime", "MushroomCow", "Ozelot", "Pig", "PigZombie", "Rabbit", "Sheep", "Shulker", "Silverfish", "Skeleton", "Slime", "SnowMan", "Spider", "Squid", "Villager", "VillagerGolem", "Witch", "WitherBoss", "Wolf", "Zombie"); DataConverterHealth() { } @@ -1771,7 +1746,6 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo return cmp; } - } private static class DataConverterSaddle implements DataConverter { @@ -1796,7 +1770,6 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo return cmp; } - } private static class DataConverterHanging implements DataConverter { @@ -1835,7 +1808,6 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo return cmp; } - } private static class DataConverterDropChances implements DataConverter { @@ -1859,15 +1831,13 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo if (cmp.contains("ArmorDropChances", 9)) { nbttaglist = cmp.getList("ArmorDropChances", 5); - if (nbttaglist.size() == 4 && nbttaglist.getFloat(0) == 0.0F && nbttaglist.getFloat(1) == 0.0F && nbttaglist.getFloat( - 2) == 0.0F && nbttaglist.getFloat(3) == 0.0F) { + if (nbttaglist.size() == 4 && nbttaglist.getFloat(0) == 0.0F && nbttaglist.getFloat(1) == 0.0F && nbttaglist.getFloat(2) == 0.0F && nbttaglist.getFloat(3) == 0.0F) { cmp.remove("ArmorDropChances"); } } return cmp; } - } private static class DataConverterRiding implements DataConverter { @@ -1903,7 +1873,6 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo nbttagcompound.remove("Riding"); return nbttagcompound1; } - } private static class DataConverterBook implements DataConverter { @@ -1928,39 +1897,42 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo if (!"null".equals(s) && !StringUtil.isNullOrEmpty(s)) { if ((s.charAt(0) != 34 || s.charAt(s.length() - 1) != 34) && (s.charAt(0) != 123 || s.charAt(s.length() - 1) != 125)) { - object = new TextComponent(s); + object = Component.literal(s); } else { try { object = GsonHelper.fromJson(DataConverterSignText.a, s, Component.class, true); if (object == null) { - object = new TextComponent(""); + object = Component.literal(""); } - } catch (JsonParseException ignored) { + } catch (JsonParseException jsonparseexception) { + ; } if (object == null) { try { - object = Component.Serializer.fromJson(s); - } catch (JsonParseException ignored) { + object = Component.Serializer.fromJson(s, MinecraftServer.getServer().registryAccess()); + } catch (JsonParseException jsonparseexception1) { + ; } } if (object == null) { try { - object = Component.Serializer.fromJsonLenient(s); - } catch (JsonParseException ignored) { + object = Component.Serializer.fromJsonLenient(s, MinecraftServer.getServer().registryAccess()); + } catch (JsonParseException jsonparseexception2) { + ; } } if (object == null) { - object = new TextComponent(s); + object = Component.literal(s); } } } else { - object = new TextComponent(""); + object = Component.literal(""); } - nbttaglist.set(i, net.minecraft.nbt.StringTag.valueOf(Component.Serializer.toJson(object))); + nbttaglist.set(i, StringTag.valueOf(Component.Serializer.toJson(object, MinecraftServer.getServer().registryAccess()))); } nbttagcompound1.put("pages", nbttaglist); @@ -1969,7 +1941,6 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo return cmp; } - } private static class DataConverterCookedFish implements DataConverter { @@ -1990,7 +1961,6 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo return cmp; } - } private static class DataConverterZombie implements DataConverter { @@ -2012,7 +1982,8 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo if (cmp.contains("VillagerProfession", 99)) { try { i = this.convert(cmp.getInt("VillagerProfession")); - } catch (RuntimeException ignored) { + } catch (RuntimeException runtimeexception) { + ; } } @@ -2032,7 +2003,6 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo private int convert(int i) { return i >= 0 && i < 6 ? i : -1; } - } private static class DataConverterVBO implements DataConverter { @@ -2048,7 +2018,6 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo cmp.putString("useVbo", "true"); return cmp; } - } private static class DataConverterGuardian implements DataConverter { @@ -2071,7 +2040,6 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo return cmp; } - } private static class DataConverterSkeleton implements DataConverter { @@ -2100,7 +2068,6 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo return cmp; } - } private static class DataConverterZombieType implements DataConverter { @@ -2139,7 +2106,6 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo return cmp; } - } private static class DataConverterHorse implements DataConverter { @@ -2182,13 +2148,29 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo return cmp; } - } private static class DataConverterTileEntity implements DataConverter { private static final Map a = Maps.newHashMap(); + DataConverterTileEntity() { + } + + public int getDataVersion() { + return 704; + } + + public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) { + String s = DataConverterTileEntity.a.get(cmp.getString("id")); + + if (s != null) { + cmp.putString("id", s); + } + + return cmp; + } + static { DataConverterTileEntity.a.put("Airportal", "minecraft:end_portal"); DataConverterTileEntity.a.put("Banner", "minecraft:banner"); @@ -2214,8 +2196,13 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo DataConverterTileEntity.a.put("Structure", "minecraft:structure_block"); DataConverterTileEntity.a.put("Trap", "minecraft:dispenser"); } + } - DataConverterTileEntity() { + private static class DataConverterEntity implements DataConverter { + + private static final Map a = Maps.newHashMap(); + + DataConverterEntity() { } public int getDataVersion() { @@ -2223,7 +2210,7 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo } public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) { - String s = DataConverterTileEntity.a.get(cmp.getString("id")); + String s = DataConverterEntity.a.get(cmp.getString("id")); if (s != null) { cmp.putString("id", s); @@ -2231,11 +2218,6 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo return cmp; } - } - - private static class DataConverterEntity implements DataConverter { - - private static final Map a = Maps.newHashMap(); static { DataConverterEntity.a.put("AreaEffectCloud", "minecraft:area_effect_cloud"); @@ -2314,23 +2296,6 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo DataConverterEntity.a.put("ZombieHorse", "minecraft:zombie_horse"); DataConverterEntity.a.put("ZombieVillager", "minecraft:zombie_villager"); } - - DataConverterEntity() { - } - - public int getDataVersion() { - return 704; - } - - public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) { - String s = DataConverterEntity.a.get(cmp.getString("id")); - - if (s != null) { - cmp.putString("id", s); - } - - return cmp; - } } private static class DataConverterPotionWater implements DataConverter { @@ -2345,8 +2310,7 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) { String s = cmp.getString("id"); - if ("minecraft:potion".equals(s) || "minecraft:splash_potion".equals(s) || "minecraft:lingering_potion".equals(s) || "minecraft:tipped_arrow".equals( - s)) { + if ("minecraft:potion".equals(s) || "minecraft:splash_potion".equals(s) || "minecraft:lingering_potion".equals(s) || "minecraft:tipped_arrow".equals(s)) { net.minecraft.nbt.CompoundTag nbttagcompound1 = cmp.getCompound("tag"); if (!nbttagcompound1.contains("Potion", 8)) { @@ -2360,7 +2324,6 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo return cmp; } - } private static class DataConverterShulker implements DataConverter { @@ -2379,12 +2342,11 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo return cmp; } - } private static class DataConverterShulkerBoxItem implements DataConverter { - public static final String[] a = new String[]{"minecraft:white_shulker_box", "minecraft:orange_shulker_box", "minecraft:magenta_shulker_box", "minecraft:light_blue_shulker_box", "minecraft:yellow_shulker_box", "minecraft:lime_shulker_box", "minecraft:pink_shulker_box", "minecraft:gray_shulker_box", "minecraft:silver_shulker_box", "minecraft:cyan_shulker_box", "minecraft:purple_shulker_box", "minecraft:blue_shulker_box", "minecraft:brown_shulker_box", "minecraft:green_shulker_box", "minecraft:red_shulker_box", "minecraft:black_shulker_box"}; + public static final String[] a = new String[] { "minecraft:white_shulker_box", "minecraft:orange_shulker_box", "minecraft:magenta_shulker_box", "minecraft:light_blue_shulker_box", "minecraft:yellow_shulker_box", "minecraft:lime_shulker_box", "minecraft:pink_shulker_box", "minecraft:gray_shulker_box", "minecraft:silver_shulker_box", "minecraft:cyan_shulker_box", "minecraft:purple_shulker_box", "minecraft:blue_shulker_box", "minecraft:brown_shulker_box", "minecraft:green_shulker_box", "minecraft:red_shulker_box", "minecraft:black_shulker_box" }; DataConverterShulkerBoxItem() { } @@ -2421,7 +2383,6 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo return cmp; } - } private static class DataConverterShulkerBoxBlock implements DataConverter { @@ -2440,7 +2401,6 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo return cmp; } - } private static class DataConverterLang implements DataConverter { @@ -2459,7 +2419,6 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo return cmp; } - } private static class DataConverterTotem implements DataConverter { @@ -2478,7 +2437,6 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo return cmp; } - } private static class DataConverterBedBlock implements DataConverter { @@ -2526,7 +2484,6 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo return cmp; } - } private static class DataConverterBedItem implements DataConverter { @@ -2545,26 +2502,22 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo return cmp; } - } private static class DataConverterSignText implements DataConverter { public static final Gson a = new GsonBuilder().registerTypeAdapter(Component.class, new JsonDeserializer() { - MutableComponent a(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws - JsonParseException { + MutableComponent a(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws JsonParseException { if (jsonelement.isJsonPrimitive()) { - return new TextComponent(jsonelement.getAsString()); + return Component.literal(jsonelement.getAsString()); } else if (jsonelement.isJsonArray()) { JsonArray jsonarray = jsonelement.getAsJsonArray(); MutableComponent ichatbasecomponent = null; + Iterator iterator = jsonarray.iterator(); - for (final JsonElement jsonelement1 : jsonarray) { - MutableComponent ichatbasecomponent1 = this.a( - jsonelement1, - jsonelement1.getClass(), - jsondeserializationcontext - ); + while (iterator.hasNext()) { + JsonElement jsonelement1 = (JsonElement) iterator.next(); + MutableComponent ichatbasecomponent1 = this.a(jsonelement1, jsonelement1.getClass(), jsondeserializationcontext); if (ichatbasecomponent == null) { ichatbasecomponent = ichatbasecomponent1; @@ -2579,11 +2532,7 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo } } - public Object deserialize( - JsonElement jsonelement, - Type type, - JsonDeserializationContext jsondeserializationcontext - ) throws JsonParseException { + public Object deserialize(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws JsonParseException { return this.a(jsonelement, type, jsondeserializationcontext); } }).create(); @@ -2612,45 +2561,46 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo if (!"null".equals(s1) && !StringUtil.isNullOrEmpty(s1)) { if ((s1.charAt(0) != 34 || s1.charAt(s1.length() - 1) != 34) && (s1.charAt(0) != 123 || s1.charAt(s1.length() - 1) != 125)) { - object = new TextComponent(s1); + object = Component.literal(s1); } else { try { object = GsonHelper.fromJson(DataConverterSignText.a, s1, Component.class, true); if (object == null) { - object = new TextComponent(""); + object = Component.literal(""); } - } catch (JsonParseException ignored) { + } catch (JsonParseException jsonparseexception) { + ; } if (object == null) { try { - object = Component.Serializer.fromJson(s1); - } catch (JsonParseException ignored) { + object = Component.Serializer.fromJson(s1, MinecraftServer.getServer().registryAccess()); + } catch (JsonParseException jsonparseexception1) { + ; } } if (object == null) { try { - object = Component.Serializer.fromJsonLenient(s1); - } catch (JsonParseException ignored) { + object = Component.Serializer.fromJsonLenient(s1, MinecraftServer.getServer().registryAccess()); + } catch (JsonParseException jsonparseexception2) { + ; } } if (object == null) { - object = new TextComponent(s1); + object = Component.literal(s1); } } } else { - object = new TextComponent(""); + object = Component.literal(""); } - nbttagcompound.putString(s, Component.Serializer.toJson(object)); + nbttagcompound.putString(s, Component.Serializer.toJson(object, MinecraftServer.getServer().registryAccess())); } - } private static class DataInspectorPlayerVehicle implements DataInspector { - @Override public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp, int sourceVer, int targetVer) { if (cmp.contains("RootVehicle", 10)) { @@ -2663,11 +2613,9 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo return cmp; } - } private static class DataInspectorLevelPlayer implements DataInspector { - @Override public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp, int sourceVer, int targetVer) { if (cmp.contains("Player", 10)) { @@ -2676,11 +2624,9 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo return cmp; } - } private static class DataInspectorStructure implements DataInspector { - @Override public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp, int sourceVer, int targetVer) { net.minecraft.nbt.ListTag nbttaglist; @@ -2711,11 +2657,9 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo return cmp; } - } private static class DataInspectorChunks implements DataInspector { - @Override public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp, int sourceVer, int targetVer) { if (cmp.contains("Level", 10)) { @@ -2727,14 +2671,7 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo nbttaglist = nbttagcompound1.getList("Entities", 10); for (j = 0; j < nbttaglist.size(); ++j) { - nbttaglist.set( - j, - convert(LegacyType.ENTITY, - (net.minecraft.nbt.CompoundTag) nbttaglist.get(j), - sourceVer, - targetVer - ) - ); + nbttaglist.set(j, convert(LegacyType.ENTITY, (net.minecraft.nbt.CompoundTag) nbttaglist.get(j), sourceVer, targetVer)); } } @@ -2742,25 +2679,16 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo nbttaglist = nbttagcompound1.getList("TileEntities", 10); for (j = 0; j < nbttaglist.size(); ++j) { - nbttaglist.set( - j, - convert(LegacyType.BLOCK_ENTITY, - (net.minecraft.nbt.CompoundTag) nbttaglist.get(j), - sourceVer, - targetVer - ) - ); + nbttaglist.set(j, convert(LegacyType.BLOCK_ENTITY, (net.minecraft.nbt.CompoundTag) nbttaglist.get(j), sourceVer, targetVer)); } } } return cmp; } - } private static class DataInspectorEntityPassengers implements DataInspector { - @Override public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp, int sourceVer, int targetVer) { if (cmp.contains("Passengers", 9)) { @@ -2773,11 +2701,9 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo return cmp; } - } private static class DataInspectorPlayer implements DataInspector { - @Override public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp, int sourceVer, int targetVer) { convertItems(cmp, "Inventory", sourceVer, targetVer); @@ -2792,11 +2718,9 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo return cmp; } - } private static class DataInspectorVillagers implements DataInspector { - ResourceLocation entityVillager = getKey("EntityVillager"); @Override @@ -2820,11 +2744,9 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo return cmp; } - } private static class DataInspectorMobSpawnerMinecart implements DataInspector { - ResourceLocation entityMinecartMobSpawner = getKey("EntityMinecartMobSpawner"); ResourceLocation tileEntityMobSpawner = getKey("TileEntityMobSpawner"); @@ -2839,11 +2761,9 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo return cmp; } - } private static class DataInspectorMobSpawnerMobs implements DataInspector { - ResourceLocation tileEntityMobSpawner = getKey("TileEntityMobSpawner"); @Override @@ -2864,11 +2784,9 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo return cmp; } - } private static class DataInspectorCommandBlock implements DataInspector { - ResourceLocation tileEntityCommand = getKey("TileEntityCommand"); @Override @@ -2881,63 +2799,5 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo return cmp; } - } - - @SuppressWarnings("unchecked") - private class WrappedDataFixer implements DataFixer { - - private final DataFixer realFixer; - - WrappedDataFixer(DataFixer realFixer) { - this.realFixer = realFixer; - } - - @Override - public Dynamic update(TypeReference type, Dynamic dynamic, int sourceVer, int targetVer) { - LegacyType legacyType = DFU_TO_LEGACY.get(type.typeName()); - if (sourceVer < LEGACY_VERSION && legacyType != null) { - net.minecraft.nbt.CompoundTag cmp = (net.minecraft.nbt.CompoundTag) dynamic.getValue(); - int desiredVersion = Math.min(targetVer, LEGACY_VERSION); - - cmp = convert(legacyType, cmp, sourceVer, desiredVersion); - sourceVer = desiredVersion; - dynamic = new Dynamic(OPS_NBT, cmp); - } - return realFixer.update(type, dynamic, sourceVer, targetVer); - } - - private net.minecraft.nbt.CompoundTag convert( - LegacyType type, - net.minecraft.nbt.CompoundTag cmp, - int sourceVer, - int desiredVersion - ) { - List converters = PaperweightDataConverters.this.converters.get(type); - if (converters != null && !converters.isEmpty()) { - for (DataConverter converter : converters) { - int dataVersion = converter.getDataVersion(); - if (dataVersion > sourceVer && dataVersion <= desiredVersion) { - cmp = converter.convert(cmp); - } - } - } - - List inspectors = PaperweightDataConverters.this.inspectors.get(type); - if (inspectors != null && !inspectors.isEmpty()) { - for (DataInspector inspector : inspectors) { - cmp = inspector.inspect(cmp, sourceVer, desiredVersion); - } - } - - return cmp; - } - - @Override - public Schema getSchema(int i) { - return realFixer.getSchema(i); - } - - } - } diff --git a/worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_18_R2/PaperweightFakePlayer.java b/worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext.fawe/v1_20_R4/PaperweightFakePlayer.java similarity index 78% rename from worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_18_R2/PaperweightFakePlayer.java rename to worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext.fawe/v1_20_R4/PaperweightFakePlayer.java index e5ff26672..792942843 100644 --- a/worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_18_R2/PaperweightFakePlayer.java +++ b/worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext.fawe/v1_20_R4/PaperweightFakePlayer.java @@ -17,18 +17,19 @@ * along with this program. If not, see . */ -package com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_18_R2; +package com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_20_R4; import com.mojang.authlib.GameProfile; -import net.minecraft.network.chat.ChatType; import net.minecraft.network.chat.Component; -import net.minecraft.network.protocol.game.ServerboundClientInformationPacket; +import net.minecraft.server.level.ClientInformation; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.stats.Stat; import net.minecraft.world.MenuProvider; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.HumanoidArm; +import net.minecraft.world.entity.player.ChatVisiblity; import net.minecraft.world.level.block.entity.SignBlockEntity; import net.minecraft.world.phys.Vec3; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; @@ -37,15 +38,14 @@ import java.util.OptionalInt; import java.util.UUID; class PaperweightFakePlayer extends ServerPlayer { - - private static final GameProfile FAKE_WORLDEDIT_PROFILE = new GameProfile( - UUID.nameUUIDFromBytes("worldedit".getBytes()), - "[WorldEdit]" - ); + private static final GameProfile FAKE_WORLDEDIT_PROFILE = new GameProfile(UUID.nameUUIDFromBytes("worldedit".getBytes()), "[WorldEdit]"); private static final Vec3 ORIGIN = new Vec3(0.0D, 0.0D, 0.0D); + private static final ClientInformation FAKE_CLIENT_INFO = new ClientInformation( + "en_US", 16, ChatVisiblity.FULL, true, 0, HumanoidArm.LEFT, false, false + ); PaperweightFakePlayer(ServerLevel world) { - super(world.getServer(), world, FAKE_WORLDEDIT_PROFILE); + super(world.getServer(), world, FAKE_WORLDEDIT_PROFILE, FAKE_CLIENT_INFO); } @Override @@ -72,17 +72,13 @@ class PaperweightFakePlayer extends ServerPlayer { } @Override - public void updateOptions(ServerboundClientInformationPacket packet) { + public void updateOptions(ClientInformation clientOptions) { } @Override public void displayClientMessage(Component message, boolean actionBar) { } - @Override - public void sendMessage(Component message, ChatType type, UUID sender) { - } - @Override public void awardStat(Stat stat, int amount) { } @@ -97,7 +93,6 @@ class PaperweightFakePlayer extends ServerPlayer { } @Override - public void openTextEdit(SignBlockEntity sign) { + public void openTextEdit(SignBlockEntity sign, boolean front) { } - } diff --git a/worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_18_R2/PaperweightWorldNativeAccess.java b/worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext.fawe/v1_20_R4/PaperweightWorldNativeAccess.java similarity index 74% rename from worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_18_R2/PaperweightWorldNativeAccess.java rename to worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext.fawe/v1_20_R4/PaperweightWorldNativeAccess.java index e9656539a..f7e5cee3f 100644 --- a/worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_18_R2/PaperweightWorldNativeAccess.java +++ b/worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext.fawe/v1_20_R4/PaperweightWorldNativeAccess.java @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_18_R2; +package com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_20_R4; import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.internal.block.BlockStateIdAccess; @@ -27,21 +27,19 @@ import com.sk89q.worldedit.util.SideEffectSet; import com.sk89q.worldedit.util.nbt.CompoundBinaryTag; import com.sk89q.worldedit.world.block.BlockState; import net.minecraft.core.BlockPos; -import net.minecraft.server.level.ChunkHolder; +import net.minecraft.server.level.FullChunkStatus; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.chunk.LevelChunk; -import org.bukkit.craftbukkit.v1_18_R2.CraftWorld; -import org.bukkit.craftbukkit.v1_18_R2.block.data.CraftBlockData; +import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.craftbukkit.block.data.CraftBlockData; import org.bukkit.event.block.BlockPhysicsEvent; import java.lang.ref.WeakReference; import java.util.Objects; import javax.annotation.Nullable; -public class PaperweightWorldNativeAccess implements - WorldNativeAccess { - +public class PaperweightWorldNativeAccess implements WorldNativeAccess { private static final int UPDATE = 1; private static final int NOTIFY = 2; @@ -83,19 +81,12 @@ public class PaperweightWorldNativeAccess implements @Nullable @Override - public net.minecraft.world.level.block.state.BlockState setBlockState( - LevelChunk chunk, - BlockPos position, - net.minecraft.world.level.block.state.BlockState state - ) { + public net.minecraft.world.level.block.state.BlockState setBlockState(LevelChunk chunk, BlockPos position, net.minecraft.world.level.block.state.BlockState state) { return chunk.setBlockState(position, state, false, this.sideEffectSet.shouldApply(SideEffect.UPDATE)); } @Override - public net.minecraft.world.level.block.state.BlockState getValidBlockForPosition( - net.minecraft.world.level.block.state.BlockState block, - BlockPos position - ) { + public net.minecraft.world.level.block.state.BlockState getValidBlockForPosition(net.minecraft.world.level.block.state.BlockState block, BlockPos position) { return Block.updateFromNeighbourShapes(block, getWorld(), position); } @@ -115,12 +106,7 @@ public class PaperweightWorldNativeAccess implements } @Override - public void notifyBlockUpdate( - LevelChunk chunk, - BlockPos position, - net.minecraft.world.level.block.state.BlockState oldState, - net.minecraft.world.level.block.state.BlockState newState - ) { + public void notifyBlockUpdate(LevelChunk chunk, BlockPos position, net.minecraft.world.level.block.state.BlockState oldState, net.minecraft.world.level.block.state.BlockState newState) { if (chunk.getSections()[getWorld().getSectionIndex(position.getY())] != null) { getWorld().sendBlockUpdated(position, oldState, newState, UPDATE | NOTIFY); } @@ -128,7 +114,7 @@ public class PaperweightWorldNativeAccess implements @Override public boolean isChunkTicking(LevelChunk chunk) { - return chunk.getFullStatus().isOrAfter(ChunkHolder.FullChunkStatus.TICKING); + return chunk.getFullStatus().isOrAfter(FullChunkStatus.BLOCK_TICKING); } @Override @@ -139,11 +125,7 @@ public class PaperweightWorldNativeAccess implements } @Override - public void notifyNeighbors( - BlockPos pos, - net.minecraft.world.level.block.state.BlockState oldState, - net.minecraft.world.level.block.state.BlockState newState - ) { + public void notifyNeighbors(BlockPos pos, net.minecraft.world.level.block.state.BlockState oldState, net.minecraft.world.level.block.state.BlockState newState) { ServerLevel world = getWorld(); if (sideEffectSet.shouldApply(SideEffect.EVENTS)) { world.updateNeighborsAt(pos, oldState.getBlock()); @@ -162,27 +144,20 @@ public class PaperweightWorldNativeAccess implements } } + // Not sure why neighborChanged is deprecated private void fireNeighborChanged(BlockPos pos, ServerLevel world, Block block, BlockPos neighborPos) { - world.getBlockState(neighborPos).neighborChanged(world, neighborPos, block, pos, false); + world.getBlockState(neighborPos).handleNeighborChanged(world, neighborPos, block, pos, false); } @Override - public void updateNeighbors( - BlockPos pos, - net.minecraft.world.level.block.state.BlockState oldState, - net.minecraft.world.level.block.state.BlockState newState, - int recursionLimit - ) { + public void updateNeighbors(BlockPos pos, net.minecraft.world.level.block.state.BlockState oldState, net.minecraft.world.level.block.state.BlockState newState, int recursionLimit) { ServerLevel world = getWorld(); // a == updateNeighbors // b == updateDiagonalNeighbors oldState.updateIndirectNeighbourShapes(world, pos, NOTIFY, recursionLimit); if (sideEffectSet.shouldApply(SideEffect.EVENTS)) { CraftWorld craftWorld = world.getWorld(); - BlockPhysicsEvent event = new BlockPhysicsEvent( - craftWorld.getBlockAt(pos.getX(), pos.getY(), pos.getZ()), - CraftBlockData.fromData(newState) - ); + BlockPhysicsEvent event = new BlockPhysicsEvent(craftWorld.getBlockAt(pos.getX(), pos.getY(), pos.getZ()), CraftBlockData.fromData(newState)); world.getCraftServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return; @@ -193,19 +168,13 @@ public class PaperweightWorldNativeAccess implements } @Override - public void onBlockStateChange( - BlockPos pos, - net.minecraft.world.level.block.state.BlockState oldState, - net.minecraft.world.level.block.state.BlockState newState - ) { + public void onBlockStateChange(BlockPos pos, net.minecraft.world.level.block.state.BlockState oldState, net.minecraft.world.level.block.state.BlockState newState) { getWorld().onBlockStateChange(pos, oldState, newState); } - //FAWE start @Override public void flush() { } - //FAWE end } diff --git a/worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2/PaperweightBlockMaterial.java b/worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4/PaperweightBlockMaterial.java similarity index 69% rename from worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2/PaperweightBlockMaterial.java rename to worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4/PaperweightBlockMaterial.java index b5da62e0f..9c2292451 100644 --- a/worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2/PaperweightBlockMaterial.java +++ b/worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4/PaperweightBlockMaterial.java @@ -1,28 +1,24 @@ -package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_18_R2; +package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R4; import com.google.common.base.Suppliers; import com.sk89q.jnbt.CompoundTag; -import com.sk89q.util.ReflectionUtil; -import com.sk89q.worldedit.bukkit.adapter.Refraction; -import com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_18_R2.nbt.PaperweightLazyCompoundTag; +import com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R4.nbt.PaperweightLazyCompoundTag; import com.sk89q.worldedit.world.registry.BlockMaterial; import net.minecraft.core.BlockPos; +import net.minecraft.server.dedicated.DedicatedServer; import net.minecraft.world.level.EmptyBlockGetter; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.EntityBlock; import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.material.Fluids; import net.minecraft.world.level.material.PushReaction; -import org.bukkit.craftbukkit.v1_18_R2.block.data.CraftBlockData; +import org.bukkit.craftbukkit.block.data.CraftBlockData; public class PaperweightBlockMaterial implements BlockMaterial { private final Block block; private final BlockState blockState; - private final Material material; - private final boolean isTranslucent; private final CraftBlockData craftBlockData; private final org.bukkit.Material craftMaterial; private final int opacity; @@ -35,22 +31,16 @@ public class PaperweightBlockMaterial implements BlockMaterial { public PaperweightBlockMaterial(Block block, BlockState blockState) { this.block = block; this.blockState = blockState; - this.material = blockState.getMaterial(); this.craftBlockData = CraftBlockData.fromData(blockState); this.craftMaterial = craftBlockData.getMaterial(); - BlockBehaviour.Properties blockInfo = ReflectionUtil.getField(BlockBehaviour.class, block, Refraction.pickName( - "properties", "aO")); - this.isTranslucent = !(boolean) ReflectionUtil.getField(BlockBehaviour.Properties.class, blockInfo, - Refraction.pickName("canOcclude", "n") - ); opacity = blockState.getLightBlock(EmptyBlockGetter.INSTANCE, BlockPos.ZERO); BlockEntity tileEntity = !(block instanceof EntityBlock) ? null : ((EntityBlock) block).newBlockEntity( BlockPos.ZERO, blockState ); - tile = tileEntity == null - ? null - : new PaperweightLazyCompoundTag(Suppliers.memoize(tileEntity::saveWithId)); + tile = tileEntity == null ? null : new PaperweightLazyCompoundTag( + Suppliers.memoize(() -> tileEntity.saveWithId(DedicatedServer.getServer().registryAccess())) + ); } public Block getBlock() { @@ -65,10 +55,6 @@ public class PaperweightBlockMaterial implements BlockMaterial { return craftBlockData; } - public Material getMaterial() { - return material; - } - @Override public boolean isAir() { return blockState.isAir(); @@ -81,7 +67,7 @@ public class PaperweightBlockMaterial implements BlockMaterial { @Override public boolean isOpaque() { - return material.isSolidBlocking(); + return blockState.canOcclude(); } @Override @@ -91,12 +77,13 @@ public class PaperweightBlockMaterial implements BlockMaterial { @Override public boolean isLiquid() { - return material.isLiquid(); + return !blockState.getFluidState().is(Fluids.EMPTY); } @Override public boolean isSolid() { - return material.isSolid(); + // No access to world -> EmptyBlockGetter + return blockState.isSolidRender(EmptyBlockGetter.INSTANCE, BlockPos.ZERO); } @Override @@ -126,27 +113,27 @@ public class PaperweightBlockMaterial implements BlockMaterial { @Override public boolean isFragileWhenPushed() { - return material.getPushReaction() == PushReaction.DESTROY; + return blockState.getPistonPushReaction() == PushReaction.DESTROY; } @Override public boolean isUnpushable() { - return material.getPushReaction() == PushReaction.BLOCK; + return blockState.getPistonPushReaction() == PushReaction.BLOCK; } @Override public boolean isTicksRandomly() { - return block.isRandomlyTicking(blockState); + return blockState.isRandomlyTicking(); } @Override public boolean isMovementBlocker() { - return material.isSolid(); + return craftMaterial.isSolid(); } @Override public boolean isBurnable() { - return material.isFlammable(); + return craftMaterial.isBurnable(); } @Override @@ -157,12 +144,12 @@ public class PaperweightBlockMaterial implements BlockMaterial { @Override public boolean isReplacedDuringPlacement() { - return material.isReplaceable(); + return blockState.canBeReplaced(); } @Override public boolean isTranslucent() { - return isTranslucent; + return !blockState.canOcclude(); } @Override @@ -183,7 +170,7 @@ public class PaperweightBlockMaterial implements BlockMaterial { @Override public int getMapColor() { // rgb field - return material.getColor().col; + return block.defaultMapColor().col; } } diff --git a/worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2/PaperweightFaweAdapter.java b/worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4/PaperweightFaweAdapter.java similarity index 82% rename from worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2/PaperweightFaweAdapter.java rename to worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4/PaperweightFaweAdapter.java index 8b96e2ea6..b263c9ced 100644 --- a/worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2/PaperweightFaweAdapter.java +++ b/worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4/PaperweightFaweAdapter.java @@ -1,4 +1,4 @@ -package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_18_R2; +package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R4; import com.fastasyncworldedit.bukkit.adapter.FaweAdapter; import com.fastasyncworldedit.bukkit.adapter.NMSRelighterFactory; @@ -12,14 +12,13 @@ import com.fastasyncworldedit.core.util.NbtUtils; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import com.mojang.serialization.Codec; import com.sk89q.jnbt.Tag; import com.sk89q.worldedit.blocks.BaseItemStack; -import com.sk89q.worldedit.blocks.TileEntityBlock; import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; -import com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_18_R2.PaperweightAdapter; -import com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_18_R2.nbt.PaperweightLazyCompoundTag; -import com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_18_R2.regen.PaperweightRegen; +import com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R4.nbt.PaperweightLazyCompoundTag; +import com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R4.regen.PaperweightRegen; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.internal.block.BlockStateIdAccess; @@ -35,6 +34,7 @@ import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.util.SideEffect; import com.sk89q.worldedit.util.SideEffectSet; +import com.sk89q.worldedit.util.concurrency.LazyReference; import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.nbt.BinaryTag; import com.sk89q.worldedit.util.nbt.CompoundBinaryTag; @@ -45,7 +45,6 @@ import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; -import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypesCache; import com.sk89q.worldedit.world.entity.EntityType; import com.sk89q.worldedit.world.item.ItemType; @@ -53,44 +52,48 @@ import com.sk89q.worldedit.world.registry.BlockMaterial; import io.papermc.lib.PaperLib; import net.minecraft.core.BlockPos; import net.minecraft.core.Registry; +import net.minecraft.core.RegistryAccess; import net.minecraft.core.WritableRegistry; -import net.minecraft.nbt.IntTag; +import net.minecraft.core.component.DataComponentPatch; +import net.minecraft.core.registries.Registries; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtOps; import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.MinecraftServer; +import net.minecraft.server.dedicated.DedicatedServer; import net.minecraft.server.level.ChunkHolder; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.util.StringRepresentable; import net.minecraft.world.entity.Entity; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.block.state.properties.DirectionProperty; import net.minecraft.world.level.chunk.LevelChunk; -import net.minecraft.world.level.chunk.LevelChunkSection; import org.apache.logging.log4j.Logger; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.NamespacedKey; import org.bukkit.World; import org.bukkit.block.data.BlockData; -import org.bukkit.craftbukkit.v1_18_R2.CraftChunk; -import org.bukkit.craftbukkit.v1_18_R2.CraftServer; -import org.bukkit.craftbukkit.v1_18_R2.CraftWorld; -import org.bukkit.craftbukkit.v1_18_R2.block.data.CraftBlockData; -import org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity; -import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer; -import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack; -import org.bukkit.craftbukkit.v1_18_R2.util.CraftNamespacedKey; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.craftbukkit.block.data.CraftBlockData; +import org.bukkit.craftbukkit.entity.CraftEntity; +import org.bukkit.craftbukkit.entity.CraftPlayer; +import org.bukkit.craftbukkit.inventory.CraftItemStack; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.entity.Player; import javax.annotation.Nullable; import java.lang.ref.WeakReference; import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -104,11 +107,24 @@ import java.util.function.Supplier; import java.util.stream.Collectors; import java.util.stream.Stream; +import static net.minecraft.core.registries.Registries.BIOME; + public final class PaperweightFaweAdapter extends FaweAdapter { private static final Logger LOGGER = LogManagerCompat.getLogger(); + private static Method CHUNK_HOLDER_WAS_ACCESSIBLE_SINCE_LAST_SAVE; + private static final Codec COMPONENTS_CODEC = DataComponentPatch.CODEC.optionalFieldOf( + "components", DataComponentPatch.EMPTY + ).codec(); - private final PaperweightAdapter parent; + static { + try { + CHUNK_HOLDER_WAS_ACCESSIBLE_SINCE_LAST_SAVE = ChunkHolder.class.getDeclaredMethod("wasAccessibleSinceLastSave"); + } catch (NoSuchMethodException ignored) { // may not be present in newer paper versions + } + } + + private final com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_20_R4.PaperweightAdapter parent; // ------------------------------------------------------------------------ // Code that may break between versions of Minecraft // ------------------------------------------------------------------------ @@ -119,7 +135,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter>> allBlockProperties = null; public PaperweightFaweAdapter() throws NoSuchFieldException, NoSuchMethodException { - this.parent = new PaperweightAdapter(); + this.parent = new com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_20_R4.PaperweightAdapter(); } @Nullable @@ -128,6 +144,10 @@ public final class PaperweightFaweAdapter extends FaweAdapter getParent() { return parent; @@ -219,7 +239,8 @@ public final class PaperweightFaweAdapter extends FaweAdapter> 4; - LevelChunkSection section = levelChunkSections[y4]; - - net.minecraft.world.level.block.state.BlockState existing; - if (section == null) { - existing = ((PaperweightBlockMaterial) BlockTypes.AIR.getDefaultState().getMaterial()).getState(); - } else { - existing = section.getBlockState(x & 15, y & 15, z & 15); - } - - levelChunk.removeBlockEntity(blockPos); // Force delete the old tile entity - - CompoundBinaryTag compoundTag = state instanceof BaseBlock ? state.getNbt() : null; - if (compoundTag != null || existing instanceof TileEntityBlock) { - level.setBlock(blockPos, blockState, 0); - // remove tile - if (compoundTag != null) { - // We will assume that the tile entity was created for us, - // though we do not do this on the Forge version - BlockEntity blockEntity = level.getBlockEntity(blockPos); - if (blockEntity != null) { - net.minecraft.nbt.CompoundTag tag = (net.minecraft.nbt.CompoundTag) fromNativeBinary(compoundTag); - tag.put("x", IntTag.valueOf(x)); - tag.put("y", IntTag.valueOf(y)); - tag.put("z", IntTag.valueOf(z)); - blockEntity.load(tag); // readTagIntoTileEntity - load data - } - } - } else { - if (existing == blockState) { - return true; - } - levelChunk.setBlockState(blockPos, blockState, false); - } - if (update) { - level.getMinecraftWorld().sendBlockUpdated(blockPos, existing, blockState, 0); - } - return true; - } - @Override public WorldNativeAccess createWorldNativeAccess(org.bukkit.World world) { return new PaperweightFaweWorldNativeAccess(this, new WeakReference<>(getServerLevel(world))); @@ -343,7 +316,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter saveTag = () -> { final net.minecraft.nbt.CompoundTag minecraftTag = new net.minecraft.nbt.CompoundTag(); - PaperweightPlatformAdapter.readEntityIntoTag(mcEntity, minecraftTag); + readEntityIntoTag(mcEntity, minecraftTag); //add Id for AbstractChangeSet to work final CompoundBinaryTag tag = (CompoundBinaryTag) toNativeBinary(minecraftTag); final Map tags = NbtUtils.getCompoundBinaryTagValues(tag); @@ -474,7 +447,8 @@ public final class PaperweightFaweAdapter extends FaweAdapter stream = /*players.a(new ChunkCoordIntPair(packet.getChunkX(), packet.getChunkZ()), flag) */ Stream.empty(); @@ -516,11 +490,18 @@ public final class PaperweightFaweAdapter extends FaweAdapter getEntities(org.bukkit.World world) { - // Quickly add each entity to a list copy. - List mcEntities = new ArrayList<>(); - getServerLevel(world).entityManager.getEntityGetter().getAll().forEach(mcEntities::add); - - List list = new ArrayList<>(); - mcEntities.forEach((mcEnt) -> { - org.bukkit.entity.Entity bukkitEntity = mcEnt.getBukkitEntity(); - if (bukkitEntity.isValid()) { - list.add(bukkitEntity); - } - - }); - return list; - } - @Override public BaseItemStack adapt(org.bukkit.inventory.ItemStack itemStack) { + final RegistryAccess.Frozen registryAccess = DedicatedServer.getServer().registryAccess(); final ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack); - final BaseItemStack weStack = new BaseItemStack(BukkitAdapter.asItemType(itemStack.getType()), itemStack.getAmount()); - weStack.setNbt(((CompoundBinaryTag) toNativeBinary(nmsStack.getTag()))); - return weStack; + final net.minecraft.nbt.Tag tag = COMPONENTS_CODEC.encodeStart( + registryAccess.createSerializationContext(NbtOps.INSTANCE), + nmsStack.getComponentsPatch() + ).getOrThrow(); + return new BaseItemStack( + BukkitAdapter.asItemType(itemStack.getType()), + LazyReference.from(() -> (CompoundBinaryTag) toNativeBinary(tag)), + itemStack.getAmount() + ); } @Override @@ -577,17 +548,12 @@ public final class PaperweightFaweAdapter extends FaweAdapter registry = MinecraftServer .getServer() .registryAccess() - .ownedRegistryOrThrow(Registry.BIOME_REGISTRY); + .registryOrThrow(BIOME); ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.getId()); Biome biome = registry.get(resourceLocation); return registry.getId(biome); @@ -616,8 +582,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter biomeRegistry = (WritableRegistry) ((CraftServer) Bukkit.getServer()) .getServer() .registryAccess() - .ownedRegistryOrThrow( - Registry.BIOME_REGISTRY); + .registryOrThrow(BIOME); List keys = biomeRegistry.stream() .map(biomeRegistry::getKey).filter(Objects::nonNull).toList(); List namespacedKeys = new ArrayList<>(); @@ -659,4 +624,16 @@ public final class PaperweightFaweAdapter extends FaweAdapter currentTick; if (nextTick || cachedChanges.size() >= 1024) { if (nextTick) { @@ -140,7 +141,7 @@ public class PaperweightFaweWorldNativeAccess implements WorldNativeAccess posNms2We = v -> BlockVector3.at(v.getX(), v.getY(), v.getZ()); - private static final Function nmsTile2We = - tileEntity -> new PaperweightLazyCompoundTag(Suppliers.memoize(tileEntity::saveWithId)); + private static final Function nmsTile2We = tileEntity -> new PaperweightLazyCompoundTag( + Suppliers.memoize(() -> tileEntity.saveWithId(DedicatedServer.getServer().registryAccess())) + ); private final PaperweightFaweAdapter adapter = ((PaperweightFaweAdapter) WorldEditPlugin .getInstance() .getBukkitImplAdapter()); @@ -130,7 +114,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc this.maxSectionPosition = maxHeight >> 4; this.skyLight = new DataLayer[getSectionCount()]; this.blockLight = new DataLayer[getSectionCount()]; - this.biomeRegistry = serverLevel.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY); + this.biomeRegistry = serverLevel.registryAccess().registryOrThrow(BIOME); this.biomeHolderIdMap = biomeRegistry.asHolderIdMap(); } @@ -260,7 +244,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc if (blockEntity == null) { return null; } - return new PaperweightLazyCompoundTag(Suppliers.memoize(blockEntity::saveWithId)); + return new PaperweightLazyCompoundTag(Suppliers.memoize(() -> blockEntity.saveWithId(DedicatedServer.getServer().registryAccess()))); } @Override @@ -289,8 +273,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc ((LevelLightEngine) serverLevel.getChunkSource().getLightEngine()).queueSectionData( LightLayer.BLOCK, sectionPos, - dataLayer, - true + dataLayer ); } skyLight[alayer] = dataLayer; @@ -317,7 +300,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc Arrays.fill(LAYER_COUNT, (byte) 15); dataLayer = new DataLayer(LAYER_COUNT); ((LevelLightEngine) serverLevel.getChunkSource().getLightEngine()).queueSectionData(LightLayer.BLOCK, sectionPos, - dataLayer, true + dataLayer ); } blockLight[alayer] = dataLayer; @@ -334,7 +317,15 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc @Override public CompoundTag getEntity(UUID uuid) { - Entity entity = serverLevel.getEntity(uuid); + ensureLoaded(serverLevel, chunkX, chunkZ); + List entities = PaperweightPlatformAdapter.getEntities(getChunk()); + Entity entity = null; + for (Entity e : entities) { + if (e.getUUID().equals(uuid)) { + entity = e; + break; + } + } if (entity != null) { org.bukkit.entity.Entity bukkitEnt = entity.getBukkitEntity(); return BukkitAdapter.adapt(bukkitEnt).getState().getNbtData(); @@ -349,6 +340,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc @Override public Set getEntities() { + ensureLoaded(serverLevel, chunkX, chunkZ); List entities = PaperweightPlatformAdapter.getEntities(getChunk()); if (entities.isEmpty()) { return Collections.emptySet(); @@ -385,7 +377,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc public Iterator iterator() { Iterable result = entities.stream().map(input -> { net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag(); - PaperweightPlatformAdapter.readEntityIntoTag(input, tag); + input.save(tag); return (CompoundTag) adapter.toNative(tag); }).collect(Collectors.toList()); return result.iterator(); @@ -474,7 +466,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc synchronized (super.sectionLocks[getSectionIndex]) { LevelChunkSection existingSection = levelChunkSections[getSectionIndex]; if (createCopy && existingSection != null) { - copy.storeBiomes(getSectionIndex, existingSection.getBiomes().copy()); + copy.storeBiomes(getSectionIndex, existingSection.getBiomes()); } if (existingSection == null) { @@ -507,8 +499,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc } } } else { - PalettedContainer> biomeData = existingSection.getBiomes(); - setBiomesToPalettedContainer(biomes[setSectionIndex], biomeData); + setBiomesToPalettedContainer(biomes, setSectionIndex, existingSection.getBiomes()); } } } @@ -543,7 +534,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc System.arraycopy(tmpLoad, 0, copyArr, 0, 4096); copy.storeSection(getSectionIndex, copyArr); if (biomes != null && existingSection != null) { - copy.storeBiomes(getSectionIndex, existingSection.getBiomes().copy()); + copy.storeBiomes(getSectionIndex, existingSection.getBiomes()); } } @@ -555,8 +546,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc .getBukkitImplAdapter() .getInternalBiomeId( BiomeTypes.PLAINS)), - PalettedContainer.Strategy.SECTION_BIOMES, - null + PalettedContainer.Strategy.SECTION_BIOMES ) : PaperweightPlatformAdapter.getBiomePalettedContainer(biomes[setSectionIndex], biomeHolderIdMap); newSection = PaperweightPlatformAdapter.newChunkSection( layerNo, @@ -616,11 +606,11 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc sectionLock.writeLock().unlock(); } - PalettedContainer> biomeData = existingSection.getBiomes(); - - if (biomes != null && biomes[setSectionIndex] != null) { - setBiomesToPalettedContainer(biomes[setSectionIndex], biomeData); - } + PalettedContainer> biomeData = setBiomesToPalettedContainer( + biomes, + setSectionIndex, + existingSection.getBiomes() + ); newSection = PaperweightPlatformAdapter.newChunkSection( @@ -705,7 +695,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc } if (Settings.settings().EXPERIMENTAL.REMOVE_ENTITY_FROM_WORLD_ON_CHUNK_FAIL) { for (UUID uuid : entityRemoves) { - Entity entity = nmsWorld.entityManager.getEntityGetter().get(uuid); + Entity entity = nmsWorld.getEntities().get(uuid); if (entity != null) { removeEntity(entity); } @@ -800,7 +790,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc tag.put("x", IntTag.valueOf(x)); tag.put("y", IntTag.valueOf(y)); tag.put("z", IntTag.valueOf(z)); - tileEntity.load(tag); + tileEntity.loadWithComponents(tag, DedicatedServer.getServer().registryAccess()); } } } @@ -1076,8 +1066,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc ((LevelLightEngine) serverLevel.getChunkSource().getLightEngine()).queueSectionData( lightLayer, sectionPos, - dataLayer, - true + dataLayer ); } synchronized (dataLayer) { @@ -1095,22 +1084,35 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc } } - private void setBiomesToPalettedContainer( - final BiomeType[] biomes, - PalettedContainer> data + private PalettedContainer> setBiomesToPalettedContainer( + final BiomeType[][] biomes, + final int sectionIndex, + final PalettedContainerRO> data ) { - int index = 0; - if (biomes == null) { - return; + PalettedContainer> biomeData; + if (data instanceof PalettedContainer> palettedContainer) { + biomeData = palettedContainer; + } else { + LOGGER.warn( + "Cannot correctly set biomes to world, existing biomes may be lost. Expected class " + + "type {} but got {}", + PalettedContainer.class.getSimpleName(), + data.getClass().getSimpleName() + ); + biomeData = data.recreate(); } - for (int y = 0; y < 4; y++) { + BiomeType[] sectionBiomes; + if (biomes == null || (sectionBiomes = biomes[sectionIndex]) == null) { + return biomeData; + } + for (int y = 0, index = 0; y < 4; y++) { for (int z = 0; z < 4; z++) { for (int x = 0; x < 4; x++, index++) { - BiomeType biomeType = biomes[index]; + BiomeType biomeType = sectionBiomes[index]; if (biomeType == null) { continue; } - data.set( + biomeData.set( x, y, z, @@ -1122,6 +1124,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc } } } + return biomeData; } @Override diff --git a/worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2/PaperweightGetBlocks_Copy.java b/worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4/PaperweightGetBlocks_Copy.java similarity index 86% rename from worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2/PaperweightGetBlocks_Copy.java rename to worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4/PaperweightGetBlocks_Copy.java index b007ea3b4..c0a7bda52 100644 --- a/worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2/PaperweightGetBlocks_Copy.java +++ b/worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4/PaperweightGetBlocks_Copy.java @@ -1,4 +1,4 @@ -package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_18_R2; +package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R4; import com.fastasyncworldedit.core.extent.processor.heightmap.HeightMapType; import com.fastasyncworldedit.core.queue.IBlocks; @@ -8,19 +8,23 @@ import com.google.common.base.Suppliers; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; -import com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_18_R2.nbt.PaperweightLazyCompoundTag; +import com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R4.nbt.PaperweightLazyCompoundTag; +import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockTypesCache; import net.minecraft.core.Holder; +import net.minecraft.server.dedicated.DedicatedServer; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.chunk.PalettedContainer; +import net.minecraft.world.level.chunk.PalettedContainerRO; +import org.apache.logging.log4j.Logger; import javax.annotation.Nullable; import java.util.Arrays; @@ -33,6 +37,8 @@ import java.util.concurrent.Future; public class PaperweightGetBlocks_Copy implements IChunkGet { + private static final Logger LOGGER = LogManagerCompat.getLogger(); + private final Map tiles = new HashMap<>(); private final Set entities = new HashSet<>(); private final char[][] blocks; @@ -57,7 +63,7 @@ public class PaperweightGetBlocks_Copy implements IChunkGet { blockEntity.getBlockPos().getY(), blockEntity.getBlockPos().getZ() ), - new PaperweightLazyCompoundTag(Suppliers.memoize(blockEntity::saveWithId)) + new PaperweightLazyCompoundTag(Suppliers.memoize(() -> blockEntity.saveWithId(DedicatedServer.getServer().registryAccess()))) ); } @@ -76,7 +82,7 @@ public class PaperweightGetBlocks_Copy implements IChunkGet { protected void storeEntity(Entity entity) { BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter(); net.minecraft.nbt.CompoundTag compoundTag = new net.minecraft.nbt.CompoundTag(); - PaperweightPlatformAdapter.readEntityIntoTag(entity, compoundTag); + entity.save(compoundTag); entities.add((CompoundTag) adapter.toNative(compoundTag)); } @@ -166,11 +172,19 @@ public class PaperweightGetBlocks_Copy implements IChunkGet { blocks[layer] = data; } - protected void storeBiomes(int layer, PalettedContainer> biomeData) { + protected void storeBiomes(int layer, PalettedContainerRO> biomeData) { if (biomes == null) { biomes = new PalettedContainer[getSectionCount()]; } - biomes[layer] = biomeData; + if (biomeData instanceof PalettedContainer> palettedContainer) { + biomes[layer] = palettedContainer.copy(); + } else { + LOGGER.error( + "Cannot correctly save biomes to history. Expected class type {} but got {}", + PalettedContainer.class.getSimpleName(), + biomeData.getClass().getSimpleName() + ); + } } @Override diff --git a/worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2/PaperweightMapChunkUtil.java b/worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4/PaperweightMapChunkUtil.java similarity index 88% rename from worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2/PaperweightMapChunkUtil.java rename to worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4/PaperweightMapChunkUtil.java index 9189ca251..9e226b088 100644 --- a/worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2/PaperweightMapChunkUtil.java +++ b/worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4/PaperweightMapChunkUtil.java @@ -1,4 +1,4 @@ -package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_18_R2; +package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R4; import com.fastasyncworldedit.bukkit.adapter.MapChunkUtil; import com.sk89q.worldedit.bukkit.adapter.Refraction; @@ -10,10 +10,10 @@ public class PaperweightMapChunkUtil extends MapChunkUtil serverLevel + io.papermc.paper.util.MCUtil.MAIN_EXECUTOR.execute(() -> serverLevel .getChunkSource() - .addRegionTicket(TicketType.PLUGIN, new ChunkPos(chunkX, chunkZ), 0, Unit.INSTANCE)); + .addRegionTicket(TicketType.UNLOAD_COOLDOWN, new ChunkPos(chunkX, chunkZ), 0, Unit.INSTANCE)); } public static ChunkHolder getPlayerChunk(ServerLevel nmsWorld, final int chunkX, final int chunkZ) { @@ -286,20 +338,21 @@ public final class PaperweightPlatformAdapter extends NMSAdapter { return; } ChunkPos coordIntPair = new ChunkPos(chunkX, chunkZ); - // UNLOADED_CHUNK - Optional optional = ((Either) chunkHolder - .getTickingChunkFuture() - .getNow(ChunkHolder.UNLOADED_LEVEL_CHUNK)).left(); + LevelChunk levelChunk; if (PaperLib.isPaper()) { // getChunkAtIfLoadedImmediately is paper only - optional = optional.or(() -> Optional.ofNullable(nmsWorld + levelChunk = nmsWorld .getChunkSource() - .getChunkAtIfLoadedImmediately(chunkX, chunkZ))); + .getChunkAtIfLoadedImmediately(chunkX, chunkZ); + } else { + levelChunk = ((Optional) ((Either) chunkHolder + .getTickingChunkFuture() // method is not present with new paper chunk system + .getNow(ChunkHolder.UNLOADED_LEVEL_CHUNK)).left()) + .orElse(null); } - if (optional.isEmpty()) { + if (levelChunk == null) { return; } - LevelChunk levelChunk = optional.get(); TaskManager.taskManager().task(() -> { ClientboundLevelChunkWithLightPacket packet; if (PaperLib.isPaper()) { @@ -307,9 +360,8 @@ public final class PaperweightPlatformAdapter extends NMSAdapter { levelChunk, nmsWorld.getChunkSource().getLightEngine(), null, - null, - true, - false // last false is to not bother with x-ray + null + // last false is to not bother with x-ray ); } else { // deprecated on paper - deprecation suppressed @@ -317,8 +369,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter { levelChunk, nmsWorld.getChunkSource().getLightEngine(), null, - null, - true + null ); } nearbyPlayers(nmsWorld, coordIntPair).forEach(p -> p.connection.send(packet)); @@ -424,12 +475,11 @@ public final class PaperweightPlatformAdapter extends NMSAdapter { .getBukkitImplAdapter() .getInternalBiomeId( BiomeTypes.PLAINS)), - PalettedContainer.Strategy.SECTION_BIOMES, - null + PalettedContainer.Strategy.SECTION_BIOMES ); } - return new LevelChunkSection(layer, blockStatePalettedContainer, biomes); + return new LevelChunkSection(blockStatePalettedContainer, biomes); } catch (final Throwable e) { throw e; } finally { @@ -447,15 +497,14 @@ public final class PaperweightPlatformAdapter extends NMSAdapter { @Nullable PalettedContainer> biomes ) { if (biomes == null) { - return new LevelChunkSection(layer, biomeRegistry); + return new LevelChunkSection(biomeRegistry); } PalettedContainer dataPaletteBlocks = new PalettedContainer<>( Block.BLOCK_STATE_REGISTRY, Blocks.AIR.defaultBlockState(), - PalettedContainer.Strategy.SECTION_STATES, - null + PalettedContainer.Strategy.SECTION_STATES ); - return new LevelChunkSection(layer, dataPaletteBlocks, biomes); + return new LevelChunkSection(dataPaletteBlocks, biomes); } /** @@ -492,8 +541,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter { PalettedContainer> biomePalettedContainer = new PalettedContainer<>( biomeRegistry, biomeRegistry.byIdOrThrow(adapter.getInternalBiomeId(BiomeTypes.PLAINS)), - PalettedContainer.Strategy.SECTION_BIOMES, - null + PalettedContainer.Strategy.SECTION_BIOMES ); final Palette> biomePalette; @@ -571,7 +619,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter { } public static BiomeType adapt(Holder biome, LevelAccessor levelAccessor) { - final Registry biomeRegistry = levelAccessor.registryAccess().ownedRegistryOrThrow(Registry.BIOME_REGISTRY); + final Registry biomeRegistry = levelAccessor.registryAccess().registryOrThrow(BIOME); if (biomeRegistry.getKey(biome.value()) == null) { return biomeRegistry.asHolderIdMap().getId(biome) == -1 ? BiomeTypes.OCEAN : null; @@ -581,13 +629,11 @@ public final class PaperweightPlatformAdapter extends NMSAdapter { static void removeBeacon(BlockEntity beacon, LevelChunk levelChunk) { try { - // Do the method ourselves to avoid trying to reflect generic method parameters - // similar to removeGameEventListener if (levelChunk.loaded || levelChunk.level.isClientSide()) { BlockEntity blockEntity = levelChunk.blockEntities.remove(beacon.getBlockPos()); if (blockEntity != null) { if (!levelChunk.level.isClientSide) { - methodRemoveGameEventListener.invoke(levelChunk, beacon); + methodRemoveGameEventListener.invoke(levelChunk, beacon, levelChunk.level); } fieldRemove.set(beacon, true); } @@ -599,30 +645,32 @@ public final class PaperweightPlatformAdapter extends NMSAdapter { } static List getEntities(LevelChunk chunk) { - return chunk.level.entityManager.getEntities(chunk.getPos()); - } - - public static void readEntityIntoTag(Entity entity, net.minecraft.nbt.CompoundTag compoundTag) { - boolean isVillager = entity instanceof AbstractVillager && !Fawe.isMainThread(); - boolean unset = false; - if (isVillager) { - try { - if (fieldOffers.get(entity) != null) { - fieldOffers.set(entity, OFFERS); - unset = true; + ExceptionCollector collector = new ExceptionCollector<>(); + if (PaperLib.isPaper()) { + if (POST_CHUNK_REWRITE) { + try { + //noinspection unchecked + return (List) PAPER_CHUNK_GEN_ALL_ENTITIES.invoke(chunk.level.getEntityLookup().getChunk(chunk.locX, chunk.locZ)); + } catch (IllegalAccessException | InvocationTargetException e) { + throw new RuntimeException("Failed to lookup entities [POST_CHUNK_REWRITE=true]", e); } - } catch (IllegalAccessException e) { - throw new RuntimeException("Failed to set offers field to villager to avoid async catcher.", e); } - } - entity.save(compoundTag); - if (unset) { try { - fieldOffers.set(entity, null); + EntityList entityList = (EntityList) LEVEL_CHUNK_ENTITIES.get(chunk); + return List.of(entityList.getRawData()); } catch (IllegalAccessException e) { - throw new RuntimeException("Failed to set offers field to null again on villager.", e); + collector.add(new RuntimeException("Failed to lookup entities [POST_CHUNK_REWRITE=false]", e)); + // fall through } } + try { + //noinspection unchecked + return ((PersistentEntitySectionManager) (SERVER_LEVEL_ENTITY_MANAGER.get(chunk.level))).getEntities(chunk.getPos()); + } catch (IllegalAccessException e) { + collector.add(new RuntimeException("Failed to lookup entities [PAPER=false]", e)); + } + collector.throwIfPresent(); + return List.of(); } record FakeIdMapBlock(int size) implements IdMap { diff --git a/worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2/PaperweightPostProcessor.java b/worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4/PaperweightPostProcessor.java similarity index 99% rename from worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2/PaperweightPostProcessor.java rename to worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4/PaperweightPostProcessor.java index abc8d6150..bc094a916 100644 --- a/worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2/PaperweightPostProcessor.java +++ b/worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4/PaperweightPostProcessor.java @@ -1,4 +1,4 @@ -package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_18_R2; +package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R4; import com.fastasyncworldedit.core.configuration.Settings; import com.fastasyncworldedit.core.extent.processor.ProcessorScope; diff --git a/worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2/PaperweightStarlightRelighter.java b/worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4/PaperweightStarlightRelighter.java similarity index 90% rename from worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2/PaperweightStarlightRelighter.java rename to worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4/PaperweightStarlightRelighter.java index c832fc98a..476978b57 100644 --- a/worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2/PaperweightStarlightRelighter.java +++ b/worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4/PaperweightStarlightRelighter.java @@ -1,14 +1,14 @@ -package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_18_R2; +package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R4; import com.fastasyncworldedit.bukkit.adapter.StarlightRelighter; import com.fastasyncworldedit.core.configuration.Settings; import com.fastasyncworldedit.core.queue.IQueueExtent; -import net.minecraft.server.MCUtil; +import net.minecraft.server.level.ChunkMap; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.TicketType; import net.minecraft.util.Unit; import net.minecraft.world.level.ChunkPos; -import net.minecraft.world.level.chunk.ChunkStatus; +import net.minecraft.world.level.chunk.status.ChunkStatus; import java.util.Set; import java.util.concurrent.CompletableFuture; @@ -18,7 +18,7 @@ import java.util.function.IntConsumer; public class PaperweightStarlightRelighter extends StarlightRelighter { private static final TicketType FAWE_TICKET = TicketType.create("fawe_ticket", (a, b) -> 0); - private static final int LIGHT_LEVEL = MCUtil.getTicketLevelFor(ChunkStatus.LIGHT); + private static final int LIGHT_LEVEL = ChunkMap.MAX_VIEW_DISTANCE + ChunkStatus.getDistance(ChunkStatus.LIGHT); public PaperweightStarlightRelighter(ServerLevel serverLevel, IQueueExtent queue) { super(serverLevel, queue); diff --git a/worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2/PaperweightStarlightRelighterFactory.java b/worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4/PaperweightStarlightRelighterFactory.java similarity index 88% rename from worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2/PaperweightStarlightRelighterFactory.java rename to worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4/PaperweightStarlightRelighterFactory.java index 735bcc677..1425088b8 100644 --- a/worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2/PaperweightStarlightRelighterFactory.java +++ b/worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4/PaperweightStarlightRelighterFactory.java @@ -1,4 +1,4 @@ -package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_18_R2; +package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R4; import com.fastasyncworldedit.core.extent.processor.lighting.NullRelighter; import com.fastasyncworldedit.core.extent.processor.lighting.RelightMode; @@ -7,7 +7,7 @@ import com.fastasyncworldedit.core.extent.processor.lighting.RelighterFactory; import com.fastasyncworldedit.core.queue.IQueueExtent; import com.sk89q.worldedit.world.World; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_18_R2.CraftWorld; +import org.bukkit.craftbukkit.CraftWorld; import javax.annotation.Nonnull; diff --git a/worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2/nbt/PaperweightLazyCompoundTag.java b/worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4/nbt/PaperweightLazyCompoundTag.java similarity index 98% rename from worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2/nbt/PaperweightLazyCompoundTag.java rename to worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4/nbt/PaperweightLazyCompoundTag.java index a890d66a4..11d3c940a 100644 --- a/worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2/nbt/PaperweightLazyCompoundTag.java +++ b/worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4/nbt/PaperweightLazyCompoundTag.java @@ -1,4 +1,4 @@ -package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_18_R2.nbt; +package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R4.nbt; import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.LazyCompoundTag; diff --git a/worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2/regen/PaperweightRegen.java b/worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4/regen/PaperweightRegen.java similarity index 69% rename from worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2/regen/PaperweightRegen.java rename to worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4/regen/PaperweightRegen.java index 8403d531d..e21e7eef7 100644 --- a/worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2/regen/PaperweightRegen.java +++ b/worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4/regen/PaperweightRegen.java @@ -1,17 +1,15 @@ -package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_18_R2.regen; +package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R4.regen; import com.fastasyncworldedit.bukkit.adapter.Regenerator; import com.fastasyncworldedit.core.Fawe; import com.fastasyncworldedit.core.queue.IChunkCache; import com.fastasyncworldedit.core.queue.IChunkGet; -import com.fastasyncworldedit.core.util.ReflectionUtils; import com.fastasyncworldedit.core.util.TaskManager; import com.google.common.collect.ImmutableList; -import com.mojang.datafixers.util.Either; import com.mojang.serialization.Lifecycle; import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.adapter.Refraction; -import com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_18_R2.PaperweightGetBlocks; +import com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R4.PaperweightGetBlocks; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.regions.Region; @@ -20,14 +18,19 @@ import com.sk89q.worldedit.world.RegenOptions; import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap; import net.minecraft.core.Holder; import net.minecraft.core.Registry; -import net.minecraft.data.BuiltinRegistries; +import net.minecraft.core.registries.Registries; import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceKey; import net.minecraft.server.MinecraftServer; +import net.minecraft.server.dedicated.DedicatedServer; +import net.minecraft.server.level.ChunkMap; +import net.minecraft.server.level.ChunkTaskPriorityQueueSorter.Message; import net.minecraft.server.level.ServerChunkCache; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ThreadedLevelLightEngine; import net.minecraft.server.level.progress.ChunkProgressListener; +import net.minecraft.util.thread.ProcessorHandle; +import net.minecraft.util.thread.ProcessorMailbox; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelHeightAccessor; @@ -37,31 +40,34 @@ import net.minecraft.world.level.biome.BiomeSource; import net.minecraft.world.level.biome.FixedBiomeSource; import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.ChunkGenerator; -import net.minecraft.world.level.chunk.ChunkStatus; +import net.minecraft.world.level.chunk.ChunkGeneratorStructureState; import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.chunk.ProtoChunk; import net.minecraft.world.level.chunk.UpgradeData; +import net.minecraft.world.level.chunk.status.ChunkStatus; +import net.minecraft.world.level.chunk.status.WorldGenContext; import net.minecraft.world.level.dimension.LevelStem; import net.minecraft.world.level.levelgen.FlatLevelSource; import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator; import net.minecraft.world.level.levelgen.NoiseGeneratorSettings; -import net.minecraft.world.level.levelgen.WorldGenSettings; +import net.minecraft.world.level.levelgen.WorldOptions; import net.minecraft.world.level.levelgen.blending.BlendingData; import net.minecraft.world.level.levelgen.flat.FlatLevelGeneratorSettings; import net.minecraft.world.level.levelgen.structure.placement.ConcentricRingsStructurePlacement; -import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager; import net.minecraft.world.level.storage.LevelStorageSource; import net.minecraft.world.level.storage.PrimaryLevelData; import org.apache.logging.log4j.Logger; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_18_R2.CraftServer; -import org.bukkit.craftbukkit.v1_18_R2.CraftWorld; -import org.bukkit.craftbukkit.v1_18_R2.generator.CustomChunkGenerator; +import org.bukkit.Chunk; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.craftbukkit.generator.CustomChunkGenerator; import org.bukkit.generator.BiomeProvider; import org.bukkit.generator.BlockPopulator; +import org.jetbrains.annotations.NotNull; import javax.annotation.Nullable; -import java.io.IOException; import java.lang.reflect.Field; import java.nio.file.Path; import java.util.Collections; @@ -74,6 +80,8 @@ import java.util.concurrent.CompletableFuture; import java.util.function.BooleanSupplier; import java.util.function.Supplier; +import static net.minecraft.core.registries.Registries.BIOME; + public class PaperweightRegen extends Regenerator { private static final Logger LOGGER = LogManagerCompat.getLogger(); @@ -85,6 +93,7 @@ public class PaperweightRegen extends Regenerator) () -> new ServerLevel( @@ -232,66 +254,70 @@ public class PaperweightRegen extends Regenerator singleBiome = options.hasBiomeType() ? BuiltinRegistries.BIOME.asHolderIdMap().byId( - WorldEditPlugin.getInstance().getBukkitImplAdapter().getInternalBiomeId(options.getBiomeType()) - ) : null; + + private final Holder singleBiome = options.hasBiomeType() ? DedicatedServer.getServer().registryAccess() + .registryOrThrow(BIOME).asHolderIdMap().byIdOrThrow( + WorldEditPlugin.getInstance().getBukkitImplAdapter().getInternalBiomeId(options.getBiomeType()) + ) : null; @Override - public void tick(BooleanSupplier shouldKeepTicking) { //no ticking + public void tick(@NotNull BooleanSupplier shouldKeepTicking) { //no ticking } @Override - public Holder getUncachedNoiseBiome(int biomeX, int biomeY, int biomeZ) { + public @NotNull Holder getUncachedNoiseBiome(int biomeX, int biomeY, int biomeZ) { if (options.hasBiomeType()) { return singleBiome; } - return PaperweightRegen.this.chunkGenerator.getBiomeSource().getNoiseBiome(biomeX, biomeY, biomeZ, - PaperweightRegen.this.chunkGenerator.climateSampler() + return PaperweightRegen.this.chunkGenerator.getBiomeSource().getNoiseBiome( + biomeX, biomeY, biomeZ, getChunkSource().randomState().sampler() ); } + }).get(); freshWorld.noSave = true; removeWorldFromWorldsMap(); newWorldData.checkName(originalServerWorld.serverLevelData.getLevelName()); //rename to original world name if (paperConfigField != null) { - paperConfigField.set(freshWorld, originalServerWorld.paperConfig); + paperConfigField.set(freshWorld, originalServerWorld.paperConfig()); } - //generator ChunkGenerator originalGenerator = originalChunkProvider.getGenerator(); if (originalGenerator instanceof FlatLevelSource flatLevelSource) { FlatLevelGeneratorSettings generatorSettingFlat = flatLevelSource.settings(); - chunkGenerator = new FlatLevelSource(originalGenerator.structureSets, generatorSettingFlat); + chunkGenerator = new FlatLevelSource(generatorSettingFlat); } else if (originalGenerator instanceof NoiseBasedChunkGenerator noiseBasedChunkGenerator) { - Holder generatorSettingBaseSupplier = - (Holder) generatorSettingBaseSupplierField - .get(originalGenerator); + Holder generatorSettingBaseSupplier = (Holder) + generatorSettingBaseSupplierField.get(noiseBasedChunkGenerator); BiomeSource biomeSource; if (options.hasBiomeType()) { - biomeSource = new FixedBiomeSource(BuiltinRegistries.BIOME - .asHolderIdMap() - .byId(WorldEditPlugin.getInstance().getBukkitImplAdapter().getInternalBiomeId(options.getBiomeType()))); + biomeSource = new FixedBiomeSource( + DedicatedServer.getServer().registryAccess() + .registryOrThrow(BIOME).asHolderIdMap().byIdOrThrow( + WorldEditPlugin.getInstance().getBukkitImplAdapter().getInternalBiomeId(options.getBiomeType()) + ) + ); } else { biomeSource = originalGenerator.getBiomeSource(); } - chunkGenerator = new NoiseBasedChunkGenerator(originalGenerator.structureSets, noiseBasedChunkGenerator.noises, - biomeSource, seed, + chunkGenerator = new NoiseBasedChunkGenerator( + biomeSource, generatorSettingBaseSupplier ); } else if (originalGenerator instanceof CustomChunkGenerator customChunkGenerator) { - chunkGenerator = customChunkGenerator.delegate; + chunkGenerator = customChunkGenerator.getDelegate(); } else { LOGGER.error("Unsupported generator type {}", originalGenerator.getClass().getName()); return false; @@ -300,22 +326,8 @@ public class PaperweightRegen extends Regenerator>> ringPositions = - (Map>>) ringPositionsField.get( - originalGenerator); - Map>> copy = new Object2ObjectArrayMap<>(ringPositions); - ringPositionsField.set(chunkGenerator, copy); - hasGeneratedPositionsField.setBoolean(chunkGenerator, true); - } - } - - - chunkGenerator.conf = originalServerWorld.spigotConfig; freshChunkProvider = new ServerChunkCache( freshWorld, session, @@ -333,7 +345,7 @@ public class PaperweightRegen extends Regenerator>> origPositions = + (Map>>) ringPositionsField.get(state); + Map>> copy = new Object2ObjectArrayMap<>( + origPositions); + ChunkGeneratorStructureState newState = (ChunkGeneratorStructureState) generatorStructureStateField.get( + freshChunkProvider.chunkMap); + ringPositionsField.set(newState, copy); + hasGeneratedPositionsField.setBoolean(newState, true); + } + } + + chunkSourceField.set(freshWorld, freshChunkProvider); //let's start then - structureManager = server.getStructureManager(); - threadedLevelLightEngine = freshChunkProvider.getLightEngine(); + structureTemplateManager = server.getStructureManager(); + threadedLevelLightEngine = new NoOpLightEngine(freshChunkProvider); + this.worldGenContext = new WorldGenContext(freshWorld, chunkGenerator, structureTemplateManager, + threadedLevelLightEngine + ); return true; } @@ -362,7 +395,7 @@ public class PaperweightRegen extends Regenerator { try { freshChunkProvider.close(false); - } catch (IOException e) { + } catch (Exception e) { throw new RuntimeException(e); } }); @@ -385,7 +418,7 @@ public class PaperweightRegen extends Regenerator blockPopulator.populate(freshWorld.getWorld(), random, levelChunk.getBukkitChunk())); + TaskManager.taskManager().task(() -> { + final CraftWorld world = freshWorld.getWorld(); + final Chunk chunk = world.getChunkAt(levelChunk.locX, levelChunk.locZ); + blockPopulator.populate(world, random, chunk); + }); } @Override @@ -427,14 +464,12 @@ public class PaperweightRegen extends Regenerator { - try { - Map map = (Map) serverWorldsField.get(Bukkit.getServer()); - map.remove("faweregentempworld"); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } - }); + try { + Map map = (Map) serverWorldsField.get(Bukkit.getServer()); + map.remove("faweregentempworld"); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } } private ResourceKey getWorldDimKey(org.bukkit.World.Environment env) { @@ -451,11 +486,15 @@ public class PaperweightRegen extends Regenerator getEntities() { + public @NotNull List getEntities() { return Collections.emptyList(); } @@ -516,23 +554,41 @@ public class PaperweightRegen extends Regenerator processChunk(List accessibleChunks) { return chunkStatus.generate( - Runnable::run, // TODO revisit, we might profit from this somehow? - freshWorld, - chunkGenerator, - structureManager, - threadedLevelLightEngine, - c -> CompletableFuture.completedFuture(Either.left(c)), - accessibleChunks, - true + worldGenContext, + Runnable::run, + CompletableFuture::completedFuture, + accessibleChunks ); } } + /** + * A light engine that does nothing. As light is calculated after pasting anyway, we can avoid + * work this way. + */ + static class NoOpLightEngine extends ThreadedLevelLightEngine { + + private static final ProcessorMailbox MAILBOX = ProcessorMailbox.create(task -> { + }, "fawe-no-op"); + private static final ProcessorHandle> HANDLE = ProcessorHandle.of("fawe-no-op", m -> { + }); + + public NoOpLightEngine(final ServerChunkCache chunkProvider) { + super(chunkProvider, chunkProvider.chunkMap, false, MAILBOX, HANDLE); + } + + @Override + public @NotNull CompletableFuture lightChunk(final @NotNull ChunkAccess chunk, final boolean excludeBlocks) { + return CompletableFuture.completedFuture(chunk); + } + + } + } diff --git a/worldedit-bukkit/build.gradle.kts b/worldedit-bukkit/build.gradle.kts index 8705c931c..3af5fa04e 100644 --- a/worldedit-bukkit/build.gradle.kts +++ b/worldedit-bukkit/build.gradle.kts @@ -36,6 +36,7 @@ repositories { name = "Glaremasters" url = uri("https://repo.glaremasters.me/repository/towny/") } + maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") // TODO Remove when 4.17.0 is released flatDir { dir(File("src/main/resources")) } } @@ -210,7 +211,7 @@ tasks { versionNumber.set("${project.version}") versionType.set("release") uploadFile.set(file("build/libs/${rootProject.name}-Bukkit-${project.version}.jar")) - gameVersions.addAll(listOf("1.20.4", "1.20.3", "1.20.2", "1.20.1", "1.20", "1.19.4", "1.18.2")) + gameVersions.addAll(listOf("1.20.6", "1.20.5", "1.20.3", "1.20.2", "1.20.1", "1.20", "1.19.4")) loaders.addAll(listOf("paper", "spigot")) changelog.set("The changelog is available on GitHub: https://github.com/IntellectualSites/" + "FastAsyncWorldEdit/releases/tag/${project.version}") diff --git a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/Regenerator.java b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/Regenerator.java index 607bc75bf..2a006d141 100644 --- a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/Regenerator.java +++ b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/Regenerator.java @@ -5,6 +5,7 @@ import com.fastasyncworldedit.core.queue.IChunkCache; import com.fastasyncworldedit.core.queue.IChunkGet; import com.fastasyncworldedit.core.queue.implementation.SingleThreadQueueExtent; import com.fastasyncworldedit.core.util.MathMan; +import com.google.common.collect.Lists; import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.bukkit.BukkitAdapter; @@ -24,11 +25,16 @@ import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; import it.unimi.dsi.fastutil.longs.LongArrayList; import it.unimi.dsi.fastutil.longs.LongList; +import jdk.jfr.Category; +import jdk.jfr.Event; +import jdk.jfr.Label; +import jdk.jfr.Name; import org.apache.logging.log4j.Logger; import org.bukkit.generator.BiomeProvider; import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.WorldInfo; +import java.util.AbstractList; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -36,6 +42,7 @@ import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Random; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutorService; @@ -62,7 +69,7 @@ public abstract class Regenerator chunkStatuses = new LinkedHashMap<>(); + protected final LinkedHashMap chunkStatuses = new LinkedHashMap<>(); // TODO (j21): use SequencedMap private final Long2ObjectLinkedOpenHashMap protoChunks = new Long2ObjectLinkedOpenHashMap<>(); private final Long2ObjectOpenHashMap chunks = new Long2ObjectOpenHashMap<>(); protected boolean generateConcurrent = true; @@ -172,51 +179,70 @@ public abstract class Regenerator chunkCoordsForRadius = new Int2ObjectOpenHashMap<>(); - chunkStatuses.keySet().stream().mapToInt(ChunkStatusWrapper::requiredNeighborChunkRadius0).distinct().forEach(radius -> { - if (radius == -1) { //ignore ChunkStatus.EMPTY - return; - } - int border = 10 - radius; //9 = 8 + 1, 8: max border radius used in chunk stages, 1: need 1 extra chunk for chunk - // features to generate at the border of the region - chunkCoordsForRadius.put(radius, getChunkCoordsRegen(region, border)); - }); + // to get the chunks we need to generate in the nth chunk status, we need to know how many chunks + // we need to generate in the n + 1 th chunk status. Summing up the margin solves that + LinkedHashMap chunkCoordsForChunkStatus = new LinkedHashMap<>(); + int borderSum = 1; + // TODO (j21): use SequencedMap#sequencedKeySet().reversed() + final List reversedKeys = Lists.reverse(new ArrayList<>(chunkStatuses.keySet())); + for (final ChunkStatus status : reversedKeys) { + chunkCoordsForChunkStatus.put(status, getChunkCoordsRegen(region, borderSum)); + borderSum += status.requiredNeighborChunkRadius(); + } //create chunks - for (long xz : chunkCoordsForRadius.get(0)) { + // TODO (j21): use SequencedMap#firstEntry().getKey() + for (long xz : chunkCoordsForChunkStatus.get(chunkStatuses.keySet().iterator().next())) { ProtoChunk chunk = createProtoChunk(MathMan.unpairIntX(xz), MathMan.unpairIntY(xz)); protoChunks.put(xz, chunk); } - //generate lists for RegionLimitedWorldAccess, need to be square with odd length (e.g. 17x17), 17 = 1 middle chunk + 8 border chunks * 2 - Int2ObjectOpenHashMap>> worldLimits = new Int2ObjectOpenHashMap<>(); - chunkStatuses.keySet().stream().mapToInt(ChunkStatusWrapper::requiredNeighborChunkRadius0).distinct().forEach(radius -> { - if (radius == -1) { //ignore ChunkStatus.EMPTY - return; + // a memory-efficient, lightweight "list" that calculates index -> ChunkAccess + // as needed when accessed + class LazyChunkList extends AbstractList { + private final int size; + private final int minX; + private final int minZ; + private final int sizeSqrt; + + LazyChunkList(int radius, int centerX, int centerZ) { + this.sizeSqrt = radius + 1 + radius; // length of one side + this.size = this.sizeSqrt * this.sizeSqrt; + this.minX = centerX - radius; + this.minZ = centerZ - radius; } - Long2ObjectOpenHashMap> map = new Long2ObjectOpenHashMap<>(); - for (long xz : chunkCoordsForRadius.get(radius)) { - int x = MathMan.unpairIntX(xz); - int z = MathMan.unpairIntY(xz); - List l = new ArrayList<>((radius + 1 + radius) * (radius + 1 + radius)); - for (int zz = z - radius; zz <= z + radius; zz++) { //order is important, first z then x - for (int xx = x - radius; xx <= x + radius; xx++) { - l.add(protoChunks.get(MathMan.pairInt(xx, zz))); - } - } - map.put(xz, l); + @Override + public IChunkAccess get(final int index) { + Objects.checkIndex(index, size); + int absX = (index % sizeSqrt) + minX; + int absZ = (index / sizeSqrt) + minZ; + return protoChunks.get(MathMan.pairInt(absX, absZ)); } - worldLimits.put(radius, map); - }); + + @Override + public int size() { + return size; + } + + } + @Label("Regeneration") + @Category("FAWE") + @Name("fawe.regen") + class RegenerationEvent extends Event { + private String chunkStatus; + private int chunksToProcess; + } //run generation tasks excluding FULL chunk status for (Map.Entry entry : chunkStatuses.entrySet()) { ChunkStatus chunkStatus = entry.getKey(); - int radius = chunkStatus.requiredNeighborChunkRadius0(); + final RegenerationEvent event = new RegenerationEvent(); + event.begin(); + event.chunkStatus = chunkStatus.name(); + int radius = Math.max(1, chunkStatus.requiredNeighborChunkRadius0()); - long[] coords = chunkCoordsForRadius.get(radius); - Long2ObjectOpenHashMap> limitsForRadius = worldLimits.get(radius); + long[] coords = chunkCoordsForChunkStatus.get(chunkStatus); + event.chunksToProcess = coords.length; if (this.generateConcurrent && entry.getValue() == Concurrency.RADIUS) { SequentialTasks> tasks = getChunkStatusTaskRows(coords, radius); for (ConcurrentTasks para : tasks) { @@ -224,7 +250,8 @@ public abstract class Regenerator { for (long xz : row) { - chunkStatus.processChunkSave(xz, limitsForRadius.get(xz)); + chunkStatus.processChunkSave(xz, new LazyChunkList(radius, MathMan.unpairIntX(xz), + MathMan.unpairIntY(xz))); } }); } @@ -234,7 +261,8 @@ public abstract class Regenerator scheduled = new ArrayList<>(coords.length); for (long xz : coords) { - scheduled.add(() -> chunkStatus.processChunkSave(xz, limitsForRadius.get(xz))); + scheduled.add(() -> chunkStatus.processChunkSave(xz, new LazyChunkList(radius, MathMan.unpairIntX(xz), + MathMan.unpairIntY(xz)))); } runAndWait(scheduled); } else { // Concurrency.NONE or generateConcurrent == false @@ -242,28 +270,33 @@ public abstract class Regenerator { for (long xz : coords) { - chunkStatus.processChunkSave(xz, limitsForRadius.get(xz)); + chunkStatus.processChunkSave(xz, new LazyChunkList(radius, MathMan.unpairIntX(xz), + MathMan.unpairIntY(xz))); } }).get(); // wait until finished this step } + event.commit(); } //convert to proper chunks - for (long xz : chunkCoordsForRadius.get(0)) { + // TODO (j21): use SequencedMap#firstEntry().getValue() + for (long xz : chunkCoordsForChunkStatus.values().iterator().next()) { ProtoChunk proto = protoChunks.get(xz); chunks.put(xz, createChunk(proto)); } //final chunkstatus ChunkStatus FULL = getFullChunkStatus(); - for (long xz : chunkCoordsForRadius.get(0)) { //FULL.requiredNeighbourChunkRadius() == 0! + // TODO (j21): use SequencedMap#firstEntry().getValue() + for (long xz : chunkCoordsForChunkStatus.values().iterator().next()) { //FULL.requiredNeighbourChunkRadius() == 0! Chunk chunk = chunks.get(xz); FULL.processChunkSave(xz, List.of(chunk)); } //populate List populators = getBlockPopulators(); - for (long xz : chunkCoordsForRadius.get(0)) { + // TODO (j21): use SequencedMap#firstEntry().getValue() + for (long xz : chunkCoordsForChunkStatus.values().iterator().next()) { int x = MathMan.unpairIntX(xz); int z = MathMan.unpairIntY(xz); @@ -277,8 +310,10 @@ public abstract class Regenerator byZ = new Int2ObjectOpenHashMap<>(); - int expectedListLength = (coordsCount + 1) / (maxZ - minZ); + int expectedListLength = (coordsCount + 1) / (maxZ - minZ + 2); //init lists for (int i = minZ; i <= maxZ; i++) { @@ -581,13 +616,16 @@ public abstract class Regenerator extends Tasks { diff --git a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/listener/ChunkListener.java b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/listener/ChunkListener.java index 7b9599084..91ec973bb 100644 --- a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/listener/ChunkListener.java +++ b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/listener/ChunkListener.java @@ -135,7 +135,7 @@ public abstract class ChunkListener implements Listener { @Deprecated(since = "2.0.0") public void cleanup(Chunk chunk) { for (Entity entity : chunk.getEntities()) { - if (entity.getType() == EntityType.DROPPED_ITEM) { + if (entity.getType() == EntityType.ITEM) { entity.remove(); } } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/bukkit/util/CommandRegistration.java b/worldedit-bukkit/src/main/java/com/sk89q/bukkit/util/CommandRegistration.java index 424325127..c650975c3 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/bukkit/util/CommandRegistration.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/bukkit/util/CommandRegistration.java @@ -20,6 +20,7 @@ package com.sk89q.bukkit.util; import com.sk89q.util.ReflectionUtil; +import io.papermc.lib.PaperLib; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -96,12 +97,11 @@ public class CommandRegistration { return fallbackCommands; } - CommandMap commandMap = ReflectionUtil.getField(plugin.getServer().getPluginManager(), "commandMap"); + CommandMap commandMap = PaperLib.isPaper() ? Bukkit.getCommandMap() : ReflectionUtil.getField(plugin.getServer().getPluginManager(), "commandMap"); if (commandMap == null) { Bukkit.getServer().getLogger().severe(plugin.getDescription().getName() - + ": Could not retrieve server CommandMap, using fallback instead!"); - fallbackCommands = commandMap = new SimpleCommandMap(Bukkit.getServer()); - Bukkit.getServer().getPluginManager().registerEvents(new FallbackRegistrationListener(fallbackCommands), plugin); + + ": Could not retrieve server CommandMap"); + throw new IllegalStateException("Failed to retrieve command map, make sure you are running supported server software"); } else { serverCommandMap = commandMap; } diff --git a/worldedit-core/doctools/build.gradle.kts b/worldedit-core/doctools/build.gradle.kts index 6f2123f20..cf1cf33de 100644 --- a/worldedit-core/doctools/build.gradle.kts +++ b/worldedit-core/doctools/build.gradle.kts @@ -1,16 +1,12 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { - kotlin("jvm") version "1.8.20" + kotlin("jvm") version "1.9.23" application } applyCommonConfiguration() -tasks.withType { - kotlinOptions.jvmTarget = "17" -} - application.mainClass.set("com.sk89q.worldedit.internal.util.DocumentationPrinter") tasks.named("run") { workingDir = rootProject.projectDir diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEditManifest.java b/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEditManifest.java index 9ce5c24f0..449e08db3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEditManifest.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEditManifest.java @@ -23,7 +23,7 @@ import javax.annotation.Nullable; import java.io.IOException; import java.io.UncheckedIOException; import java.net.JarURLConnection; -import java.net.URL; +import java.net.URI; import java.util.function.Supplier; import java.util.jar.Attributes; import java.util.jar.Manifest; @@ -73,8 +73,7 @@ public class WorldEditManifest { } try { - URL url = new URL(classPath); - JarURLConnection jarConnection = (JarURLConnection) url.openConnection(); + JarURLConnection jarConnection = (JarURLConnection) URI.create(classPath).toURL().openConnection(); Manifest manifest = jarConnection.getManifest(); return manifest.getMainAttributes(); } catch (IOException e) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/entity/BaseEntity.java b/worldedit-core/src/main/java/com/sk89q/worldedit/entity/BaseEntity.java index ceb07a71e..235cdf761 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/entity/BaseEntity.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/entity/BaseEntity.java @@ -56,6 +56,7 @@ public class BaseEntity implements NbtValued { * @param nbtData NBT data * @deprecated Use {@link BaseEntity#BaseEntity(EntityType, LazyReference)} */ + @SuppressWarnings("this-escape") @Deprecated public BaseEntity(EntityType type, CompoundTag nbtData) { this(type); @@ -87,6 +88,7 @@ public class BaseEntity implements NbtValued { * * @param other the object to clone */ + @SuppressWarnings("this-escape") public BaseEntity(BaseEntity other) { checkNotNull(other); this.type = other.getType(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/BlockChangeLimiter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/BlockChangeLimiter.java index 498e5ce9f..38b79dc34 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/BlockChangeLimiter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/BlockChangeLimiter.java @@ -62,6 +62,7 @@ public class BlockChangeLimiter extends AbstractDelegateExtent { * * @param limit the limit (>= 0) or -1 for no limit */ + @SuppressWarnings("this-escape") // Unlikely anyone is extending this in practice public void setLimit(int limit) { checkArgument(limit >= -1, "limit >= -1 required"); this.limit = limit; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/io/ForwardSeekableInputStream.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/io/ForwardSeekableInputStream.java index 585eaa00e..47f17781f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/io/ForwardSeekableInputStream.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/io/ForwardSeekableInputStream.java @@ -19,11 +19,16 @@ package com.sk89q.worldedit.util.io; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import java.io.IOException; import java.io.InputStream; public class ForwardSeekableInputStream extends InputStream { + private static final Logger LOGGER = LogManager.getLogger(); + protected InputStream parent; protected long position = 0; @@ -60,7 +65,7 @@ public class ForwardSeekableInputStream extends InputStream { @Override public int read(byte[] b, int off, int len) throws IOException { - int read = super.read(b, off, len); + int read = parent.read(b, off, len); position += read; return read; } @@ -86,6 +91,7 @@ public class ForwardSeekableInputStream extends InputStream { public void seek(long n) throws IOException { long diff = n - position; + LOGGER.error("Seek to {} from {} using {}", n, position, diff); if (diff < 0) { throw new IOException("Can't seek backwards"); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/net/HttpRequest.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/net/HttpRequest.java index a5c9fdced..d133eb54e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/net/HttpRequest.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/net/HttpRequest.java @@ -357,7 +357,7 @@ public class HttpRequest implements Closeable { */ public static URL url(String url) { try { - return new URL(url); + return URI.create(url).toURL(); } catch (MalformedURLException e) { throw new RuntimeException(e); } @@ -371,13 +371,7 @@ public class HttpRequest implements Closeable { */ private static URL reformat(URL existing) { try { - URL url = new URL(existing.toString()); - URI uri = new URI( - url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), - url.getPath(), url.getQuery(), url.getRef() - ); - url = uri.toURL(); - return url; + return existing.toURI().toURL(); } catch (MalformedURLException | URISyntaxException e) { return existing; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/EngineHubPaste.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/EngineHubPaste.java index 037cea727..1decfd384 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/EngineHubPaste.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/EngineHubPaste.java @@ -24,6 +24,7 @@ import com.google.gson.reflect.TypeToken; import com.sk89q.worldedit.util.net.HttpRequest; import java.io.IOException; +import java.net.URI; import java.net.URL; import java.util.Map; import java.util.concurrent.Callable; @@ -83,7 +84,7 @@ public class EngineHubPaste implements Paster { .execute() .expectResponseCode(200, 204); - return new URL(response.viewUrl); + return URI.create(response.viewUrl).toURL(); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/task/FutureForwardingTask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/task/FutureForwardingTask.java index fcf0bd661..515d4d53b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/task/FutureForwardingTask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/task/FutureForwardingTask.java @@ -82,21 +82,22 @@ public class FutureForwardingTask extends AbstractTask { return future.get(timeout, unit); } + // TODO: consider deprecating in favor of Future.State? @Override - public State getState() { + public Task.State getState() { if (isCancelled()) { - return State.CANCELLED; + return Task.State.CANCELLED; } else if (isDone()) { try { get(); - return State.SUCCEEDED; + return Task.State.SUCCEEDED; } catch (InterruptedException e) { - return State.CANCELLED; + return Task.State.CANCELLED; } catch (ExecutionException e) { - return State.FAILED; + return Task.State.FAILED; } } else { - return State.RUNNING; + return Task.State.RUNNING; } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockCategories.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockCategories.java index 4d1bde5f8..7d09d509e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockCategories.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockCategories.java @@ -33,8 +33,10 @@ public final class BlockCategories { public static final BlockCategory ANCIENT_CITY_REPLACEABLE = get("minecraft:ancient_city_replaceable"); public static final BlockCategory ANIMALS_SPAWNABLE_ON = get("minecraft:animals_spawnable_on"); public static final BlockCategory ANVIL = get("minecraft:anvil"); + public static final BlockCategory ARMADILLO_SPAWNABLE_ON = get("minecraft:armadillo_spawnable_on"); public static final BlockCategory AXOLOTLS_SPAWNABLE_ON = get("minecraft:axolotls_spawnable_on"); public static final BlockCategory AZALEA_GROWS_ON = get("minecraft:azalea_grows_on"); + public static final BlockCategory BADLANDS_TERRACOTTA = get("minecraft:badlands_terracotta"); public static final BlockCategory AZALEA_ROOT_REPLACEABLE = get("minecraft:azalea_root_replaceable"); public static final BlockCategory BAMBOO_BLOCKS = get("minecraft:bamboo_blocks"); public static final BlockCategory BAMBOO_PLANTABLE_ON = get("minecraft:bamboo_plantable_on"); @@ -78,6 +80,7 @@ public final class BlockCategories { public static final BlockCategory DIRT = get("minecraft:dirt"); @Deprecated public static final BlockCategory DIRT_LIKE = get("minecraft:dirt_like"); + public static final BlockCategory DOES_NOT_BLOCK_HOPPERS = get("minecraft:does_not_block_hoppers"); public static final BlockCategory DOORS = get("minecraft:doors"); public static final BlockCategory DRAGON_IMMUNE = get("minecraft:dragon_immune"); public static final BlockCategory DRAGON_TRANSPARENT = get("minecraft:dragon_transparent"); @@ -103,6 +106,12 @@ public final class BlockCategories { public static final BlockCategory HOGLIN_REPELLENTS = get("minecraft:hoglin_repellents"); public static final BlockCategory ICE = get("minecraft:ice"); public static final BlockCategory IMPERMEABLE = get("minecraft:impermeable"); + public static final BlockCategory INCORRECT_FOR_DIAMOND_TOOL = get("minecraft:incorrect_for_diamond_tool"); + public static final BlockCategory INCORRECT_FOR_GOLD_TOOL = get("minecraft:incorrect_for_gold_tool"); + public static final BlockCategory INCORRECT_FOR_IRON_TOOL = get("minecraft:incorrect_for_iron_tool"); + public static final BlockCategory INCORRECT_FOR_NETHERITE_TOOL = get("minecraft:incorrect_for_netherite_tool"); + public static final BlockCategory INCORRECT_FOR_STONE_TOOL = get("minecraft:incorrect_for_stone_tool"); + public static final BlockCategory INCORRECT_FOR_WOODEN_TOOL = get("minecraft:incorrect_for_wooden_tool"); public static final BlockCategory INFINIBURN_END = get("minecraft:infiniburn_end"); public static final BlockCategory INFINIBURN_NETHER = get("minecraft:infiniburn_nether"); public static final BlockCategory INFINIBURN_OVERWORLD = get("minecraft:infiniburn_overworld"); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockType.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockType.java index 7762ee532..a2e58a97c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockType.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockType.java @@ -60,6 +60,7 @@ public class BlockType implements Keyed, Pattern { private static final Logger LOGGER = LogManagerCompat.getLogger(); private final String id; + @SuppressWarnings("this-escape") private final LazyReference emptyFuzzy = LazyReference.from(() -> new FuzzyBlockState(this)); //FAWE start 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 513a00557..0206cdf92 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 @@ -908,6 +908,8 @@ public final class BlockTypes { @Nullable public static final BlockType HAY_BLOCK = init(); @Nullable + public static final BlockType HEAVY_CORE = init(); + @Nullable public static final BlockType HEAVY_WEIGHTED_PRESSURE_PLATE = init(); @Nullable public static final BlockType HONEYCOMB_BLOCK = init(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk13.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk13.java index e1cb08bc8..9b0d764f1 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk13.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk13.java @@ -163,7 +163,7 @@ public class AnvilChunk13 implements Chunk { throw new InvalidFormatException("Too short block state table"); } currentSerializedValue = blockStatesSerialized[nextSerializedItem++]; - localBlockId |= (currentSerializedValue & ((1 << bitsNextLong) - 1)) << remainingBits; + localBlockId |= (int) ((currentSerializedValue & ((1 << bitsNextLong) - 1)) << remainingBits); currentSerializedValue >>>= bitsNextLong; remainingBits = 64 - bitsNextLong; } else { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/entity/EntityTypes.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/entity/EntityTypes.java index f981593fe..52044abdf 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/entity/EntityTypes.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/entity/EntityTypes.java @@ -35,6 +35,8 @@ public final class EntityTypes { @Nullable public static final EntityType AREA_EFFECT_CLOUD = get("minecraft:area_effect_cloud"); @Nullable + public static final EntityType ARMADILLO = get("minecraft:armadillo"); + @Nullable public static final EntityType ARMOR_STAND = get("minecraft:armor_stand"); @Nullable public static final EntityType ARROW = get("minecraft:arrow"); @@ -51,8 +53,12 @@ public final class EntityTypes { @Nullable public static final EntityType BOAT = get("minecraft:boat"); @Nullable + public static final EntityType BOGGED = get("minecraft:bogged"); + @Nullable public static final EntityType BREEZE = get("minecraft:breeze"); @Nullable + public static final EntityType BREEZE_WIND_CHARGE = get("minecraft:breeze_wind_charge"); + @Nullable public static final EntityType CAMEL = get("minecraft:camel"); @Nullable public static final EntityType CAT = get("minecraft:cat"); @@ -171,6 +177,8 @@ public final class EntityTypes { @Nullable public static final EntityType OCELOT = get("minecraft:ocelot"); @Nullable + public static final EntityType OMINOUS_ITEM_SPAWNER = get("minecraft:ominous_item_spawner"); + @Nullable public static final EntityType PAINTING = get("minecraft:painting"); @Nullable public static final EntityType PANDA = get("minecraft:panda"); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemCategories.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemCategories.java index 3b6bdc6b6..466db6fdd 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemCategories.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemCategories.java @@ -29,28 +29,36 @@ public final class ItemCategories { public static final ItemCategory ACACIA_LOGS = get("minecraft:acacia_logs"); public static final ItemCategory ANVIL = get("minecraft:anvil"); + public static final ItemCategory ARMADILLO_FOOD = get("minecraft:armadillo_food"); public static final ItemCategory ARROWS = get("minecraft:arrows"); public static final ItemCategory AXES = get("minecraft:axes"); - public static final ItemCategory AXOLOTL_TEMPT_ITEMS = get("minecraft:axolotl_tempt_items"); + public static final ItemCategory AXOLOTL_FOOD = get("minecraft:axolotl_food"); + @Deprecated public static final ItemCategory AXOLOTL_TEMPT_ITEMS = get("minecraft:axolotl_tempt_items"); public static final ItemCategory BAMBOO_BLOCKS = get("minecraft:bamboo_blocks"); public static final ItemCategory BANNERS = get("minecraft:banners"); public static final ItemCategory BEACON_PAYMENT_ITEMS = get("minecraft:beacon_payment_items"); public static final ItemCategory BEDS = get("minecraft:beds"); + public static final ItemCategory BEE_FOOD = get("minecraft:bee_food"); public static final ItemCategory BIRCH_LOGS = get("minecraft:birch_logs"); public static final ItemCategory BOATS = get("minecraft:boats"); public static final ItemCategory BOOKSHELF_BOOKS = get("minecraft:bookshelf_books"); public static final ItemCategory BREAKS_DECORATED_POTS = get("minecraft:breaks_decorated_pots"); public static final ItemCategory BUTTONS = get("minecraft:buttons"); + public static final ItemCategory CAMEL_FOOD = get("minecraft:camel_food"); public static final ItemCategory CANDLES = get("minecraft:candles"); @Deprecated public static final ItemCategory CARPETS = get("minecraft:carpets"); + public static final ItemCategory CAT_FOOD = get("minecraft:cat_food"); public static final ItemCategory CHERRY_LOGS = get("minecraft:cherry_logs"); + public static final ItemCategory CHEST_ARMOR = get("minecraft:chest_armor"); public static final ItemCategory CHEST_BOATS = get("minecraft:chest_boats"); + public static final ItemCategory CHICKEN_FOOD = get("minecraft:chicken_food"); public static final ItemCategory CLUSTER_MAX_HARVESTABLES = get("minecraft:cluster_max_harvestables"); public static final ItemCategory COAL_ORES = get("minecraft:coal_ores"); public static final ItemCategory COALS = get("minecraft:coals"); public static final ItemCategory COMPASSES = get("minecraft:compasses"); public static final ItemCategory COMPLETES_FIND_TREE_TUTORIAL = get("minecraft:completes_find_tree_tutorial"); public static final ItemCategory COPPER_ORES = get("minecraft:copper_ores"); + public static final ItemCategory COW_FOOD = get("minecraft:cow_food"); public static final ItemCategory CREEPER_DROP_MUSIC_DISCS = get("minecraft:creeper_drop_music_discs"); public static final ItemCategory CREEPER_IGNITERS = get("minecraft:creeper_igniters"); public static final ItemCategory CRIMSON_STEMS = get("minecraft:crimson_stems"); @@ -61,44 +69,82 @@ public final class ItemCategories { public static final ItemCategory DIAMOND_ORES = get("minecraft:diamond_ores"); public static final ItemCategory DIRT = get("minecraft:dirt"); public static final ItemCategory DOORS = get("minecraft:doors"); + public static final ItemCategory DYEABLE = get("minecraft:dyeable"); public static final ItemCategory EMERALD_ORES = get("minecraft:emerald_ores"); + public static final ItemCategory ENCHANTABLE_ARMOR = get("minecraft:enchantable/armor"); + public static final ItemCategory ENCHANTABLE_BOW = get("minecraft:enchantable/bow"); + public static final ItemCategory ENCHANTABLE_CHEST_ARMOR = get("minecraft:enchantable/chest_armor"); + public static final ItemCategory ENCHANTABLE_CROSSBOW = get("minecraft:enchantable/crossbow"); + public static final ItemCategory ENCHANTABLE_DURABILITY = get("minecraft:enchantable/durability"); + public static final ItemCategory ENCHANTABLE_EQUIPPABLE = get("minecraft:enchantable/equippable"); + public static final ItemCategory ENCHANTABLE_FIRE_ASPECT = get("minecraft:enchantable/fire_aspect"); + public static final ItemCategory ENCHANTABLE_FISHING = get("minecraft:enchantable/fishing"); + public static final ItemCategory ENCHANTABLE_FOOT_ARMOR = get("minecraft:enchantable/foot_armor"); + public static final ItemCategory ENCHANTABLE_HEAD_ARMOR = get("minecraft:enchantable/head_armor"); + public static final ItemCategory ENCHANTABLE_LEG_ARMOR = get("minecraft:enchantable/leg_armor"); + public static final ItemCategory ENCHANTABLE_MINING = get("minecraft:enchantable/mining"); + public static final ItemCategory ENCHANTABLE_MINING_LOOT = get("minecraft:enchantable/mining_loot"); + public static final ItemCategory ENCHANTABLE_SHARP_WEAPON = get("minecraft:enchantable/sharp_weapon"); + public static final ItemCategory ENCHANTABLE_SWORD = get("minecraft:enchantable/sword"); + public static final ItemCategory ENCHANTABLE_TRIDENT = get("minecraft:enchantable/trident"); + public static final ItemCategory ENCHANTABLE_VANISHING = get("minecraft:enchantable/vanishing"); + public static final ItemCategory ENCHANTABLE_WEAPON = get("minecraft:enchantable/weapon"); public static final ItemCategory FENCE_GATES = get("minecraft:fence_gates"); public static final ItemCategory FENCES = get("minecraft:fences"); public static final ItemCategory FISHES = get("minecraft:fishes"); public static final ItemCategory FLOWERS = get("minecraft:flowers"); + public static final ItemCategory FOOT_ARMOR = get("minecraft:foot_armor"); public static final ItemCategory FOX_FOOD = get("minecraft:fox_food"); public static final ItemCategory FREEZE_IMMUNE_WEARABLES = get("minecraft:freeze_immune_wearables"); + public static final ItemCategory FROG_FOOD = get("minecraft:frog_food"); @Deprecated public static final ItemCategory FURNACE_MATERIALS = get("minecraft:furnace_materials"); + public static final ItemCategory GOAT_FOOD = get("minecraft:goat_food"); public static final ItemCategory GOLD_ORES = get("minecraft:gold_ores"); public static final ItemCategory HANGING_SIGNS = get("minecraft:hanging_signs"); + public static final ItemCategory HEAD_ARMOR = get("minecraft:head_armor"); public static final ItemCategory HOES = get("minecraft:hoes"); + public static final ItemCategory HOGLIN_FOOD = get("minecraft:hoglin_food"); + public static final ItemCategory HORSE_FOOD = get("minecraft:horse_food"); + public static final ItemCategory HORSE_TEMPT_ITEMS = get("minecraft:horse_tempt_items"); public static final ItemCategory IGNORED_BY_PIGLIN_BABIES = get("minecraft:ignored_by_piglin_babies"); public static final ItemCategory IRON_ORES = get("minecraft:iron_ores"); public static final ItemCategory JUNGLE_LOGS = get("minecraft:jungle_logs"); public static final ItemCategory LAPIS_ORES = get("minecraft:lapis_ores"); public static final ItemCategory LEAVES = get("minecraft:leaves"); public static final ItemCategory LECTERN_BOOKS = get("minecraft:lectern_books"); + public static final ItemCategory LEG_ARMOR = get("minecraft:leg_armor"); + public static final ItemCategory LLAMA_FOOD = get("minecraft:llama_food"); + public static final ItemCategory LLAMA_TEMPT_ITEMS = get("minecraft:llama_tempt_items"); public static final ItemCategory LOGS = get("minecraft:logs"); public static final ItemCategory LOGS_THAT_BURN = get("minecraft:logs_that_burn"); public static final ItemCategory MANGROVE_LOGS = get("minecraft:mangrove_logs"); + public static final ItemCategory MEAT = get("minecraft:meat"); public static final ItemCategory MUSIC_DISCS = get("minecraft:music_discs"); public static final ItemCategory NON_FLAMMABLE_WOOD = get("minecraft:non_flammable_wood"); public static final ItemCategory NOTEBLOCK_TOP_INSTRUMENTS = get("minecraft:noteblock_top_instruments"); public static final ItemCategory OAK_LOGS = get("minecraft:oak_logs"); @Deprecated public static final ItemCategory OCCLUDES_VIBRATION_SIGNALS = get("minecraft:occludes_vibration_signals"); + public static final ItemCategory OCELOT_FOOD = get("minecraft:ocelot_food"); @Deprecated public static final ItemCategory OVERWORLD_NATURAL_LOGS = get("minecraft:overworld_natural_logs"); + public static final ItemCategory PANDA_FOOD = get("minecraft:panda_food"); + public static final ItemCategory PARROT_FOOD = get("minecraft:parrot_food"); + public static final ItemCategory PARROT_POISONOUS_FOOD = get("minecraft:parrot_poisonous_food"); public static final ItemCategory PICKAXES = get("minecraft:pickaxes"); + public static final ItemCategory PIG_FOOD = get("minecraft:pig_food"); public static final ItemCategory PIGLIN_FOOD = get("minecraft:piglin_food"); public static final ItemCategory PIGLIN_LOVED = get("minecraft:piglin_loved"); public static final ItemCategory PIGLIN_REPELLENTS = get("minecraft:piglin_repellents"); public static final ItemCategory PLANKS = get("minecraft:planks"); + public static final ItemCategory RABBIT_FOOD = get("minecraft:rabbit_food"); public static final ItemCategory RAILS = get("minecraft:rails"); public static final ItemCategory REDSTONE_ORES = get("minecraft:redstone_ores"); public static final ItemCategory SAND = get("minecraft:sand"); public static final ItemCategory SAPLINGS = get("minecraft:saplings"); + public static final ItemCategory SHEEP_FOOD = get("minecraft:sheep_food"); public static final ItemCategory SHOVELS = get("minecraft:shovels"); public static final ItemCategory SIGNS = get("minecraft:signs"); + public static final ItemCategory SKULLS = get("minecraft:skulls"); public static final ItemCategory SLABS = get("minecraft:slabs"); public static final ItemCategory SMALL_FLOWERS = get("minecraft:small_flowers"); public static final ItemCategory SMELTS_TO_GLASS = get("minecraft:smelts_to_glass"); @@ -110,18 +156,22 @@ public final class ItemCategories { public static final ItemCategory STONE_BUTTONS = get("minecraft:stone_buttons"); public static final ItemCategory STONE_CRAFTING_MATERIALS = get("minecraft:stone_crafting_materials"); public static final ItemCategory STONE_TOOL_MATERIALS = get("minecraft:stone_tool_materials"); + public static final ItemCategory STRIDER_FOOD = get("minecraft:strider_food"); + public static final ItemCategory STRIDER_TEMPT_ITEMS = get("minecraft:strider_tempt_items"); public static final ItemCategory SWORDS = get("minecraft:swords"); public static final ItemCategory TALL_FLOWERS = get("minecraft:tall_flowers"); public static final ItemCategory TERRACOTTA = get("minecraft:terracotta"); - public static final ItemCategory TOOLS = get("minecraft:tools"); + @Deprecated public static final ItemCategory TOOLS = get("minecraft:tools"); public static final ItemCategory TRAPDOORS = get("minecraft:trapdoors"); public static final ItemCategory TRIM_MATERIALS = get("minecraft:trim_materials"); public static final ItemCategory TRIM_TEMPLATES = get("minecraft:trim_templates"); public static final ItemCategory TRIMMABLE_ARMOR = get("minecraft:trimmable_armor"); + public static final ItemCategory TURTLE_FOOD = get("minecraft:turtle_food"); public static final ItemCategory VILLAGER_PLANTABLE_SEEDS = get("minecraft:villager_plantable_seeds"); public static final ItemCategory WALLS = get("minecraft:walls"); public static final ItemCategory WARPED_STEMS = get("minecraft:warped_stems"); public static final ItemCategory WART_BLOCKS = get("minecraft:wart_blocks"); + public static final ItemCategory WOLF_FOOD = get("minecraft:wolf_food"); public static final ItemCategory WOODEN_BUTTONS = get("minecraft:wooden_buttons"); public static final ItemCategory WOODEN_DOORS = get("minecraft:wooden_doors"); public static final ItemCategory WOODEN_FENCES = get("minecraft:wooden_fences"); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemType.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemType.java index 16a65c308..5dc7f9277 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemType.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemType.java @@ -42,7 +42,7 @@ public class ItemType implements RegistryItem, Keyed { public static final NamespacedRegistry REGISTRY = new NamespacedRegistry<>("item type", true); private final String id; - @SuppressWarnings("deprecation") + @SuppressWarnings({"deprecation", "this-escape"}) private transient final LazyReference name = LazyReference.from(() -> { String name = GuavaUtil.firstNonNull( WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS) @@ -51,10 +51,12 @@ public class ItemType implements RegistryItem, Keyed { ); return name.isEmpty() ? getId() : name; }); + @SuppressWarnings("this-escape") private transient final LazyReference richName = LazyReference.from(() -> WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS) .getRegistries().getItemRegistry().getRichName(this) ); + @SuppressWarnings("this-escape") private transient final LazyReference itemMaterial = LazyReference.from(() -> WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS) .getRegistries().getItemRegistry().getMaterial(this) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemTypes.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemTypes.java index b8064bb94..f3cd6d0cc 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemTypes.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemTypes.java @@ -105,6 +105,10 @@ public final class ItemTypes { @Nullable public static final ItemType ARMOR_STAND = init(); @Nullable + public static final ItemType ARMADILLO_SCUTE = init(); + @Nullable + public static final ItemType ARMADILLO_SPAWN_EGG = init(); + @Nullable public static final ItemType ARMS_UP_POTTERY_SHERD = init(); @Nullable public static final ItemType ARROW = init(); @@ -297,6 +301,10 @@ public final class ItemTypes { @Nullable public static final ItemType BLUE_WOOL = init(); @Nullable + public static final ItemType BOGGED_SPAWN_EGG = init(); + @Nullable + public static final ItemType BOLT_ARMOR_TRIM_SMITHING_TEMPLATE = init(); + @Nullable public static final ItemType BONE = init(); @Nullable public static final ItemType BONE_BLOCK = init(); @@ -319,6 +327,8 @@ public final class ItemTypes { @Nullable public static final ItemType BREAD = init(); @Nullable + public static final ItemType BREEZE_ROD = init(); + @Nullable public static final ItemType BREEZE_SPAWN_EGG = init(); @Nullable public static final ItemType BREWER_POTTERY_SHERD = init(); @@ -971,6 +981,12 @@ public final class ItemTypes { @Nullable public static final ItemType FLINT_AND_STEEL = init(); @Nullable + public static final ItemType FLOW_ARMOR_TRIM_SMITHING_TEMPLATE = init(); + @Nullable + public static final ItemType FLOW_BANNER_PATTERN = init(); + @Nullable + public static final ItemType FLOW_POTTERY_SHERD = init(); + @Nullable public static final ItemType FLOWER_BANNER_PATTERN = init(); @Nullable public static final ItemType FLOWER_POT = init(); @@ -1132,6 +1148,10 @@ public final class ItemTypes { @Nullable public static final ItemType GUNPOWDER = init(); @Nullable + public static final ItemType GUSTER_BANNER_PATTERN = init(); + @Nullable + public static final ItemType GUSTER_POTTERY_SHERD = init(); + @Nullable public static final ItemType HANGING_ROOTS = init(); @Nullable public static final ItemType HAY_BLOCK = init(); @@ -1142,6 +1162,8 @@ public final class ItemTypes { @Nullable public static final ItemType HEARTBREAK_POTTERY_SHERD = init(); @Nullable + public static final ItemType HEAVY_CORE = init(); + @Nullable public static final ItemType HEAVY_WEIGHTED_PRESSURE_PLATE = init(); @Nullable public static final ItemType HOGLIN_SPAWN_EGG = init(); @@ -1404,6 +1426,8 @@ public final class ItemTypes { @Nullable public static final ItemType LOOM = init(); @Nullable + public static final ItemType MACE = init(); + @Nullable public static final ItemType MAGENTA_BANNER = init(); @Nullable public static final ItemType MAGENTA_BED = init(); @@ -1668,6 +1692,10 @@ public final class ItemTypes { @Nullable public static final ItemType OCHRE_FROGLIGHT = init(); @Nullable + public static final ItemType OMINOUS_BOTTLE = init(); + @Nullable + public static final ItemType OMINOUS_TRIAL_KEY = init(); + @Nullable public static final ItemType ORANGE_BANNER = init(); @Nullable public static final ItemType ORANGE_BED = init(); @@ -2075,6 +2103,8 @@ public final class ItemTypes { @Nullable public static final ItemType SCAFFOLDING = init(); @Nullable + public static final ItemType SCRAPE_POTTERY_SHERD = init(); + @Nullable public static final ItemType SCULK = init(); @Nullable public static final ItemType SCULK_CATALYST = init(); @@ -2085,6 +2115,7 @@ public final class ItemTypes { @Nullable public static final ItemType SCULK_VEIN = init(); @Nullable + @Deprecated public static final ItemType SCUTE = init(); @Nullable public static final ItemType SEA_LANTERN = init(); @@ -2424,10 +2455,14 @@ public final class ItemTypes { @Nullable public static final ItemType TURTLE_HELMET = init(); @Nullable + public static final ItemType TURTLE_SCUTE = init(); + @Nullable public static final ItemType TURTLE_SPAWN_EGG = init(); @Nullable public static final ItemType TWISTING_VINES = init(); @Nullable + public static final ItemType VAULT = init(); + @Nullable public static final ItemType VERDANT_FROGLIGHT = init(); @Nullable public static final ItemType VEX_ARMOR_TRIM_SMITHING_TEMPLATE = init(); @@ -2614,6 +2649,8 @@ public final class ItemTypes { @Nullable public static final ItemType WILD_ARMOR_TRIM_SMITHING_TEMPLATE = init(); @Nullable + public static final ItemType WIND_CHARGE = init(); + @Nullable public static final ItemType WITCH_SPAWN_EGG = init(); @Nullable public static final ItemType WITHER_ROSE = init(); @@ -2624,6 +2661,8 @@ public final class ItemTypes { @Nullable public static final ItemType WITHER_SPAWN_EGG = init(); @Nullable + public static final ItemType WOLF_ARMOR = init(); + @Nullable public static final ItemType WOLF_SPAWN_EGG = init(); @Nullable public static final ItemType WOODEN_AXE = init(); From 9a6aa78ae8c6afd947d8c1a68c43d7f633fa167a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 19 May 2024 14:46:31 +0200 Subject: [PATCH 61/90] Update dependency com.sk89q.worldguard:worldguard-bukkit to v7.0.10 (#2731) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index c02ba9098..ec09586f1 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -9,7 +9,7 @@ snakeyaml = "2.0" # Plugins dummypermscompat = "1.10" -worldguard-bukkit = "7.0.9" +worldguard-bukkit = "7.0.10" mapmanager = "1.8.0-SNAPSHOT" griefprevention = "17.0.0" griefdefender = "2.1.0-SNAPSHOT" From 49ea04574dd6b49dafb58d649be6697cba23dcd0 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 19 May 2024 14:46:38 +0200 Subject: [PATCH 62/90] Update dependency com.palmergames.bukkit.towny:towny to v0.100.2.9 (#2730) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ec09586f1..c793b1a49 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -14,7 +14,7 @@ mapmanager = "1.8.0-SNAPSHOT" griefprevention = "17.0.0" griefdefender = "2.1.0-SNAPSHOT" residence = "4.5._13.1" -towny = "0.100.2.8" +towny = "0.100.2.9" plotsquared = "7.3.8" # Third party From 96c324a0acb32ebafd0e54d1bf85e58d29a088de Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 19 May 2024 14:20:04 +0000 Subject: [PATCH 63/90] Update eps1lon/actions-label-merge-conflict action to v3.0.1 --- .github/workflows/label-merge-conflicts.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/label-merge-conflicts.yaml b/.github/workflows/label-merge-conflicts.yaml index fa6f3d72d..551b39417 100644 --- a/.github/workflows/label-merge-conflicts.yaml +++ b/.github/workflows/label-merge-conflicts.yaml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Label conflicting PRs - uses: eps1lon/actions-label-merge-conflict@v3.0.0 + uses: eps1lon/actions-label-merge-conflict@v3.0.1 with: dirtyLabel: "unresolved-merge-conflict" repoToken: "${{ secrets.GITHUB_TOKEN }}" From 2285b1dc34452cf891f5d60a856e04601ebd0693 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 19 May 2024 14:20:09 +0000 Subject: [PATCH 64/90] Update adventure to v4.17.0 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index c793b1a49..dfa177187 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -21,7 +21,7 @@ plotsquared = "7.3.8" bstats = "3.0.2" sparsebitset = "1.3" parallelgzip = "1.0.5" -adventure = "4.16.0" +adventure = "4.17.0" adventure-bukkit = "4.3.2" checkerqual = "3.43.0" truezip = "6.8.4" From adb045be6a034d7a2e87cac5c3b48e66d74f43b4 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 19 May 2024 14:20:15 +0000 Subject: [PATCH 65/90] Update dependency net.kyori:adventure-nbt to v4.17.0 --- worldedit-bukkit/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldedit-bukkit/build.gradle.kts b/worldedit-bukkit/build.gradle.kts index 3af5fa04e..ce6c9d1b1 100644 --- a/worldedit-bukkit/build.gradle.kts +++ b/worldedit-bukkit/build.gradle.kts @@ -179,7 +179,7 @@ tasks.named("shadowJar") { include(dependency("org.lz4:lz4-java:1.8.0")) } relocate("net.kyori", "com.fastasyncworldedit.core.adventure") { - include(dependency("net.kyori:adventure-nbt:4.16.0")) + include(dependency("net.kyori:adventure-nbt:4.17.0")) } relocate("com.zaxxer", "com.fastasyncworldedit.core.math") { include(dependency("com.zaxxer:SparseBitSet:1.3")) From d17beba7bb76eb0711fbd4701155753a52fbc38e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 19 May 2024 14:19:58 +0000 Subject: [PATCH 66/90] Update dependency paperweight-userdev to v1.20.6-R0.1-20240518.202723-58 --- worldedit-bukkit/adapters/adapter-1_20_5/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldedit-bukkit/adapters/adapter-1_20_5/build.gradle.kts b/worldedit-bukkit/adapters/adapter-1_20_5/build.gradle.kts index e1a518cbb..abac5e94c 100644 --- a/worldedit-bukkit/adapters/adapter-1_20_5/build.gradle.kts +++ b/worldedit-bukkit/adapters/adapter-1_20_5/build.gradle.kts @@ -12,6 +12,6 @@ repositories { dependencies { // url=https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/1.20.6-R0.1-SNAPSHOT/ - the().paperDevBundle("1.20.6-R0.1-20240516.001739-55") + the().paperDevBundle("1.20.6-R0.1-20240518.202723-58") compileOnly(libs.paperlib) } From 361baef13dfdc7450459f3808248376007010bfd Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 19 May 2024 14:20:21 +0000 Subject: [PATCH 67/90] Update dependency org.mockito:mockito-core to v5.12.0 --- gradle/libs.versions.toml | 2 +- worldedit-sponge/build.gradle.kts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index dfa177187..639b7b010 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -46,7 +46,7 @@ text = "3.0.4" piston = "0.5.10" # Tests -mockito = "5.11.0" +mockito = "5.12.0" # Gradle plugins pluginyml = "0.6.0" diff --git a/worldedit-sponge/build.gradle.kts b/worldedit-sponge/build.gradle.kts index 6498cca7e..1c3ad6b68 100644 --- a/worldedit-sponge/build.gradle.kts +++ b/worldedit-sponge/build.gradle.kts @@ -28,7 +28,7 @@ dependencies { }) api("org.apache.logging.log4j:log4j-api") api("org.bstats:bstats-sponge:1.7") - testImplementation("org.mockito:mockito-core:5.11.0") + testImplementation("org.mockito:mockito-core:5.12.0") } <<<<<<< HEAD From db6442ad35750e933b1855ca6c4ad67d521adfdb Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 19 May 2024 14:20:28 +0000 Subject: [PATCH 68/90] Update plugin xyz.jpenilla.run-paper to v2.3.0 --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index aed748cdb..a57667e8d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,7 +7,7 @@ import xyz.jpenilla.runpaper.task.RunServer plugins { id("io.github.gradle-nexus.publish-plugin") version "2.0.0" - id("xyz.jpenilla.run-paper") version "2.2.4" + id("xyz.jpenilla.run-paper") version "2.3.0" } if (!File("$rootDir/.git").exists()) { From d8eb03f4c1f000cbb496cd3df7e356fcc23be0ab Mon Sep 17 00:00:00 2001 From: Alexander Brandes Date: Sun, 19 May 2024 17:31:14 +0200 Subject: [PATCH 69/90] Release 2.10.0 Signed-off-by: Alexander Brandes --- build.gradle.kts | 4 ++-- buildSrc/src/main/kotlin/CommonJavaConfig.kt | 2 +- .../com/fastasyncworldedit/core/configuration/Config.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index a57667e8d..7c99f1678 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -34,7 +34,7 @@ logger.lifecycle(""" ******************************************* """) -var rootVersion by extra("2.9.3") +var rootVersion by extra("2.10.0") var snapshot by extra("SNAPSHOT") var revision: String by extra("") var buildNumber by extra("") @@ -52,7 +52,7 @@ ext { } } -version = String.format("%s-%s", rootVersion, buildNumber) +version = String.format("%s", rootVersion) if (!project.hasProperty("gitCommitHash")) { apply(plugin = "org.ajoberstar.grgit") diff --git a/buildSrc/src/main/kotlin/CommonJavaConfig.kt b/buildSrc/src/main/kotlin/CommonJavaConfig.kt index f915c2e0c..fec02d1a0 100644 --- a/buildSrc/src/main/kotlin/CommonJavaConfig.kt +++ b/buildSrc/src/main/kotlin/CommonJavaConfig.kt @@ -61,7 +61,7 @@ fun Project.applyCommonJavaConfiguration(sourcesJar: Boolean, banSlf4j: Boolean "https://jd.advntr.dev/api/latest/", "https://logging.apache.org/log4j/2.x/javadoc/log4j-api/", "https://www.antlr.org/api/Java/", - "https://jd.papermc.io/paper/1.20/", + "https://jd.papermc.io/paper/1.20.6/", "https://intellectualsites.github.io/fastasyncworldedit-javadocs/worldedit-core/" ) docTitle = "${rootProject.name}-${project.description}" + " " + "${rootProject.version}" diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Config.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Config.java index c3f223dc2..e5185e6d8 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Config.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Config.java @@ -189,7 +189,7 @@ public class Config { /** * Indicates that a field should be instantiated / created. * - * @since TODO + * @since 2.10.0 */ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD}) From 657dbe214607b6ea620f1f357180aa179d60ed18 Mon Sep 17 00:00:00 2001 From: Alexander Brandes Date: Sun, 19 May 2024 17:47:26 +0200 Subject: [PATCH 70/90] [ci skip] Back to snapshot for development Signed-off-by: Alexander Brandes --- build.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 7c99f1678..8fdea3200 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -34,7 +34,7 @@ logger.lifecycle(""" ******************************************* """) -var rootVersion by extra("2.10.0") +var rootVersion by extra("2.10.1") var snapshot by extra("SNAPSHOT") var revision: String by extra("") var buildNumber by extra("") @@ -52,7 +52,7 @@ ext { } } -version = String.format("%s", rootVersion) +version = String.format("%s-%s", rootVersion, buildNumber) if (!project.hasProperty("gitCommitHash")) { apply(plugin = "org.ajoberstar.grgit") From 3dc949e38394dd0599904bf9c55c101cbce69fd0 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 20 May 2024 03:33:56 +0000 Subject: [PATCH 71/90] Update dependency paperweight-userdev to v1.20.6-R0.1-20240520.005421-60 --- worldedit-bukkit/adapters/adapter-1_20_5/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldedit-bukkit/adapters/adapter-1_20_5/build.gradle.kts b/worldedit-bukkit/adapters/adapter-1_20_5/build.gradle.kts index abac5e94c..a0ee57dc2 100644 --- a/worldedit-bukkit/adapters/adapter-1_20_5/build.gradle.kts +++ b/worldedit-bukkit/adapters/adapter-1_20_5/build.gradle.kts @@ -12,6 +12,6 @@ repositories { dependencies { // url=https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/1.20.6-R0.1-SNAPSHOT/ - the().paperDevBundle("1.20.6-R0.1-20240518.202723-58") + the().paperDevBundle("1.20.6-R0.1-20240520.005421-60") compileOnly(libs.paperlib) } From f9c523c1738d9039e49ec1ff86f11bd95098221a Mon Sep 17 00:00:00 2001 From: Jordan Date: Fri, 24 May 2024 15:09:57 +0200 Subject: [PATCH 72/90] feat: move limits for (brush, superpickaxe and normal) radii to fawe (#2635) - closes #2587 --- .../worldedit/bukkit/WorldEditPlugin.java | 19 +- .../resources/defaults/worldedit-config.yml | 2 + .../core/command/tool/scroll/ScrollRange.java | 2 +- .../core/command/tool/scroll/ScrollSize.java | 2 +- .../core/configuration/Settings.java | 27 ++- .../exception/BrushRadiusLimitException.java | 30 +++ .../core/exception/RadiusLimitException.java | 41 +++++ .../core/limit/FaweLimit.java | 23 ++- .../sk89q/worldedit/LocalConfiguration.java | 30 +++ .../worldedit/MaxBrushRadiusException.java | 15 ++ .../sk89q/worldedit/MaxRadiusException.java | 14 ++ .../java/com/sk89q/worldedit/WorldEdit.java | 57 ++++++ .../worldedit/command/BrushCommands.java | 172 ++++++++++++++---- .../worldedit/command/GenerationCommands.java | 32 ++-- .../command/SuperPickaxeCommands.java | 18 +- .../sk89q/worldedit/command/ToolCommands.java | 9 +- .../worldedit/command/ToolUtilCommands.java | 2 +- .../worldedit/command/UtilityCommands.java | 41 ++--- .../worldedit/command/tool/BrushTool.java | 2 +- .../command/util/annotation/Confirm.java | 2 +- .../WorldEditExceptionConverter.java | 14 ++ .../util/PropertiesConfiguration.java | 8 + .../worldedit/util/YAMLConfiguration.java | 7 + .../src/main/resources/lang/strings.json | 2 + 24 files changed, 470 insertions(+), 101 deletions(-) create mode 100644 worldedit-core/src/main/java/com/fastasyncworldedit/core/exception/BrushRadiusLimitException.java create mode 100644 worldedit-core/src/main/java/com/fastasyncworldedit/core/exception/RadiusLimitException.java diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java index e881416c5..b4556409c 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java @@ -120,7 +120,6 @@ public class WorldEditPlugin extends JavaPlugin { public void onLoad() { //FAWE start - this.bukkitConsoleCommandSender = new BukkitCommandSender(this, Bukkit.getConsoleSender()); // This is already covered by Spigot, however, a more pesky warning with a proper explanation over "Ambiguous plugin name..." can't hurt. Plugin[] plugins = Bukkit.getServer().getPluginManager().getPlugins(); for (Plugin p : plugins) { @@ -138,6 +137,14 @@ public class WorldEditPlugin extends JavaPlugin { //noinspection ResultOfMethodCallIgnored getDataFolder().mkdirs(); + //FAWE start - Modify WorldEdit config name + config = new BukkitConfiguration(new YAMLProcessor(new File(getDataFolder(), "worldedit-config.yml"), true), this); + // Load config before we say we've loaded platforms as it is used in listeners of the event + // Load config in onLoad to ensure it is loaded before FAWE settings to allow (inelegant) copying of values across + // where needed + config.load(); + //FAWE end + WorldEdit worldEdit = WorldEdit.getInstance(); // Setup platform @@ -148,14 +155,14 @@ public class WorldEditPlugin extends JavaPlugin { migrateLegacyConfig(); //FAWE end - //FAWE start - Modify WorldEdit config name - config = new BukkitConfiguration(new YAMLProcessor(new File(getDataFolder(), "worldedit-config.yml"), true), this); - //FAWE end - //FAWE start - Setup permission attachments permissionAttachmentManager = new BukkitPermissionAttachmentManager(this); //FAWE end + //FAWE start - initialise bukkitConsoleCommandSender later + this.bukkitConsoleCommandSender = new BukkitCommandSender(this, Bukkit.getConsoleSender()); + //FAWE end + Path delChunks = Paths.get(getDataFolder().getPath(), DELCHUNKS_FILE_NAME); if (Files.exists(delChunks)) { ChunkDeleter.runFromFile(delChunks, true); @@ -189,8 +196,6 @@ public class WorldEditPlugin extends JavaPlugin { new FaweBukkit(this); //FAWE end - config.load(); // Load config before we say we've loaded platforms as it is used in listeners of the event - WorldEdit.getInstance().getEventBus().post(new PlatformsRegisteredEvent()); PermissionsResolverManager.initialize(this); // Setup permission resolver diff --git a/worldedit-bukkit/src/main/resources/defaults/worldedit-config.yml b/worldedit-bukkit/src/main/resources/defaults/worldedit-config.yml index 8140cade6..b74eaa091 100644 --- a/worldedit-bukkit/src/main/resources/defaults/worldedit-config.yml +++ b/worldedit-bukkit/src/main/resources/defaults/worldedit-config.yml @@ -24,11 +24,13 @@ limits: max-polygonal-points: default: -1 maximum: 20 + # radius, superpickaxe, brush radius are ignored, use FAWE config limits max-radius: -1 max-super-pickaxe-size: 5 max-brush-radius: 100 butcher-radius: default: -1 + # Ignored, use FAWE config limits maximum: -1 disallowed-blocks: - "minecraft:wheat" diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/scroll/ScrollRange.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/scroll/ScrollRange.java index 405b62b81..db33a526f 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/scroll/ScrollRange.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/scroll/ScrollRange.java @@ -13,7 +13,7 @@ public class ScrollRange extends Scroll { @Override public boolean increment(Player player, int amount) { - int max = WorldEdit.getInstance().getConfiguration().maxBrushRadius; + int max = player.getLimit().MAX_BRUSH_RADIUS; int newSize = MathMan.wrap(getTool().getRange() + amount, (int) (getTool().getSize() + 1), max); getTool().setRange(newSize); return true; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/scroll/ScrollSize.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/scroll/ScrollSize.java index cf60639f5..ac34226f2 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/scroll/ScrollSize.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/scroll/ScrollSize.java @@ -12,7 +12,7 @@ public class ScrollSize extends Scroll { @Override public boolean increment(Player player, int amount) { - int max = WorldEdit.getInstance().getConfiguration().maxRadius; + int max = player.getLimit().MAX_RADIUS; double newSize = Math.max(0, Math.min(max == -1 ? 4095 : max, getTool().getSize() + amount)); getTool().setSize(newSize); return true; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Settings.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Settings.java index 63f37fd6b..33c8c94f0 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Settings.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Settings.java @@ -2,6 +2,7 @@ package com.fastasyncworldedit.core.configuration; import com.fastasyncworldedit.core.limit.FaweLimit; import com.fastasyncworldedit.core.limit.PropertyRemap; +import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.world.block.BlockTypesCache; @@ -140,8 +141,22 @@ public class Settings extends Config { ); limit.MAX_FAILS = Math.max(limit.MAX_FAILS, newLimit.MAX_FAILS != -1 ? newLimit.MAX_FAILS : Integer.MAX_VALUE); limit.MAX_ITERATIONS = Math.max( - limit.MAX_ITERATIONS, - newLimit.MAX_ITERATIONS != -1 ? newLimit.MAX_ITERATIONS : Integer.MAX_VALUE + limit.MAX_ITERATIONS, newLimit.MAX_ITERATIONS != -1 ? newLimit.MAX_ITERATIONS : Integer.MAX_VALUE); + limit.MAX_RADIUS = Math.max( + limit.MAX_RADIUS, + newLimit.MAX_RADIUS != -1 ? newLimit.MAX_RADIUS : Integer.MAX_VALUE + ); + limit.MAX_SUPER_PICKAXE_SIZE = Math.max( + limit.MAX_SUPER_PICKAXE_SIZE, + newLimit.MAX_SUPER_PICKAXE_SIZE != -1 ? newLimit.MAX_SUPER_PICKAXE_SIZE : Integer.MAX_VALUE + ); + limit.MAX_BRUSH_RADIUS = Math.max( + limit.MAX_BRUSH_RADIUS, + newLimit.MAX_BRUSH_RADIUS != -1 ? newLimit.MAX_BRUSH_RADIUS : Integer.MAX_VALUE + ); + limit.MAX_BUTCHER_RADIUS = Math.max( + limit.MAX_BUTCHER_RADIUS, + newLimit.MAX_BUTCHER_RADIUS != -1 ? newLimit.MAX_BUTCHER_RADIUS : Integer.MAX_VALUE ); limit.MAX_HISTORY = Math.max( limit.MAX_HISTORY, @@ -352,6 +367,14 @@ public class Settings extends Config { public int MAX_ITERATIONS = 1000; @Comment("Max allowed entities (e.g. cows)") public int MAX_ENTITIES = 1337; + @Comment("Max allowed radius (e.g. for //sphere)") + public int MAX_RADIUS = LocalConfiguration.MAX_RADIUS; + @Comment("Max allowed superpickaxe size") + public int MAX_SUPER_PICKAXE_SIZE = LocalConfiguration.MAX_SUPER_RADIUS; + @Comment("Max allowed brush radius") + public int MAX_BRUSH_RADIUS = LocalConfiguration.MAX_BRUSH_RADIUS; + @Comment("Max allowed butcher radius") + public int MAX_BUTCHER_RADIUS = LocalConfiguration.MAX_BUTCHER_RADIUS; @Comment({ "Blockstates include Banner, Beacon, BrewingStand, Chest, CommandBlock, ", "CreatureSpawner, Dispenser, Dropper, EndGateway, Furnace, Hopper, Jukebox, ", diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/exception/BrushRadiusLimitException.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/exception/BrushRadiusLimitException.java new file mode 100644 index 000000000..838845bd0 --- /dev/null +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/exception/BrushRadiusLimitException.java @@ -0,0 +1,30 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.fastasyncworldedit.core.exception; + +/** + * Thrown when a maximum radius for a brush is reached. + */ +public class BrushRadiusLimitException extends RadiusLimitException { + + public BrushRadiusLimitException(int maxBrushRadius) { + super(maxBrushRadius); + } +} diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/exception/RadiusLimitException.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/exception/RadiusLimitException.java new file mode 100644 index 000000000..c7f72af3a --- /dev/null +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/exception/RadiusLimitException.java @@ -0,0 +1,41 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.fastasyncworldedit.core.exception; + +import com.sk89q.worldedit.WorldEditException; + +/** + * Thrown when a maximum radius is reached, such as, for example, + * in the case of a sphere command. + */ +public class RadiusLimitException extends WorldEditException { + + private final int maxRadius; + + public RadiusLimitException(int maxRadius) { + this.maxRadius = maxRadius; + } + + public int getMaxRadius() { + return maxRadius; + } + //FAWE end + +} diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/limit/FaweLimit.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/limit/FaweLimit.java index e02e3abc9..5ecc89d44 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/limit/FaweLimit.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/limit/FaweLimit.java @@ -18,6 +18,10 @@ public class FaweLimit { public int SCHEM_FILE_SIZE_LIMIT = 0; public int SCHEM_FILE_NUM_LIMIT = 0; public int MAX_EXPRESSION_MS = 0; + public int MAX_RADIUS = 0; + public int MAX_SUPER_PICKAXE_SIZE = 0; + public int MAX_BRUSH_RADIUS = 0; + public int MAX_BUTCHER_RADIUS = 0; public int INVENTORY_MODE = Integer.MAX_VALUE; public int SPEED_REDUCTION = Integer.MAX_VALUE; public boolean FAST_PLACEMENT = false; @@ -123,6 +127,10 @@ public class FaweLimit { MAX.UNIVERSAL_DISALLOWED_BLOCKS = false; MAX.DISALLOWED_BLOCKS = Collections.emptySet(); MAX.REMAP_PROPERTIES = Collections.emptySet(); + MAX.MAX_RADIUS = Integer.MAX_VALUE; + MAX.MAX_SUPER_PICKAXE_SIZE = Integer.MAX_VALUE; + MAX.MAX_BRUSH_RADIUS = Integer.MAX_VALUE; + MAX.MAX_BUTCHER_RADIUS = Integer.MAX_VALUE; } public boolean MAX_CHANGES() { @@ -250,7 +258,12 @@ public class FaweLimit { && (STRIP_NBT == null || STRIP_NBT.isEmpty()) // && !UNIVERSAL_DISALLOWED_BLOCKS --> do not include this, it effectively has no relevance && (DISALLOWED_BLOCKS == null || DISALLOWED_BLOCKS.isEmpty()) - && (REMAP_PROPERTIES == null || REMAP_PROPERTIES.isEmpty()); + && (REMAP_PROPERTIES == null || REMAP_PROPERTIES.isEmpty()) + && MAX_RADIUS == Integer.MAX_VALUE + && MAX_SUPER_PICKAXE_SIZE == Integer.MAX_VALUE + && MAX_BRUSH_RADIUS == Integer.MAX_VALUE + && MAX_BUTCHER_RADIUS == Integer.MAX_VALUE; + } public void set(FaweLimit limit) { @@ -273,6 +286,10 @@ public class FaweLimit { UNIVERSAL_DISALLOWED_BLOCKS = limit.UNIVERSAL_DISALLOWED_BLOCKS; DISALLOWED_BLOCKS = limit.DISALLOWED_BLOCKS; REMAP_PROPERTIES = limit.REMAP_PROPERTIES; + MAX_RADIUS = limit.MAX_RADIUS; + MAX_SUPER_PICKAXE_SIZE = limit.MAX_SUPER_PICKAXE_SIZE; + MAX_BRUSH_RADIUS = limit.MAX_BRUSH_RADIUS; + MAX_BUTCHER_RADIUS = limit.MAX_BUTCHER_RADIUS; } public FaweLimit copy() { @@ -296,6 +313,10 @@ public class FaweLimit { limit.UNIVERSAL_DISALLOWED_BLOCKS = UNIVERSAL_DISALLOWED_BLOCKS; limit.DISALLOWED_BLOCKS = DISALLOWED_BLOCKS; limit.REMAP_PROPERTIES = REMAP_PROPERTIES; + limit.MAX_RADIUS = MAX_RADIUS; + limit.MAX_SUPER_PICKAXE_SIZE = MAX_SUPER_PICKAXE_SIZE; + limit.MAX_BRUSH_RADIUS = MAX_BRUSH_RADIUS; + limit.MAX_BUTCHER_RADIUS = MAX_BUTCHER_RADIUS; return limit; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalConfiguration.java b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalConfiguration.java index 57ec6f186..7e2ba4549 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalConfiguration.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalConfiguration.java @@ -52,12 +52,26 @@ import java.util.Set; public abstract class LocalConfiguration { private static final Logger LOGGER = LogManagerCompat.getLogger(); + //FAWE start - inelegant but required to transfer to FAWE limits as defaults + public static int MAX_RADIUS; + public static int MAX_SUPER_RADIUS; + public static int MAX_BRUSH_RADIUS; + public static int MAX_BUTCHER_RADIUS; + //FAWE end public boolean profile = false; public boolean traceUnflushedSessions = true; public Set disallowedBlocks = new HashSet<>(); protected BlockMask disallowedBlocksMask; + /** + * @deprecated Use actor's limit {@link com.fastasyncworldedit.core.limit.FaweLimit#MAX_CHANGES} + */ + @Deprecated public int defaultChangeLimit = -1; + /** + * @deprecated Use actor's limit {@link com.fastasyncworldedit.core.limit.FaweLimit#MAX_CHANGES} + */ + @Deprecated public int maxChangeLimit = -1; public int defaultVerticalHeight = 256; public int defaultMaxPolygonalPoints = -1; @@ -68,8 +82,20 @@ public abstract class LocalConfiguration { public boolean snapshotsConfigured = false; public SnapshotRepository snapshotRepo = null; public SnapshotDatabase snapshotDatabase = null; + /** + * @deprecated Use actor's limit {@link com.fastasyncworldedit.core.limit.FaweLimit#MAX_RADIUS} + */ + @Deprecated public int maxRadius = -1; + /** + * @deprecated Use actor's limit {@link com.fastasyncworldedit.core.limit.FaweLimit#MAX_SUPER_PICKAXE_SIZE} + */ + @Deprecated public int maxSuperPickaxeSize = 5; + /** + * @deprecated Use actor's limit {@link com.fastasyncworldedit.core.limit.FaweLimit#MAX_BRUSH_RADIUS} + */ + @Deprecated public int maxBrushRadius = 6; public boolean logCommands = false; public String logFile = ""; @@ -92,6 +118,10 @@ public abstract class LocalConfiguration { public String scriptsDir = "craftscripts"; public boolean showHelpInfo = true; // unused public int butcherDefaultRadius = -1; + /** + * @deprecated Use actor's limit {@link com.fastasyncworldedit.core.limit.FaweLimit#MAX_BUTCHER_RADIUS} + */ + @Deprecated public int butcherMaxRadius = -1; public boolean allowSymlinks = false; public boolean serverSideCUI = true; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/MaxBrushRadiusException.java b/worldedit-core/src/main/java/com/sk89q/worldedit/MaxBrushRadiusException.java index 76a640c66..cb1371451 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/MaxBrushRadiusException.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/MaxBrushRadiusException.java @@ -19,9 +19,24 @@ package com.sk89q.worldedit; +import com.fastasyncworldedit.core.exception.BrushRadiusLimitException; +import com.fastasyncworldedit.core.exception.RadiusLimitException; + /** * Thrown when a maximum radius for a brush is reached. + * + * @deprecated Use {@link RadiusLimitException} */ +@Deprecated public class MaxBrushRadiusException extends MaxRadiusException { + //FAWE start + + /** + * @deprecated Use {@link BrushRadiusLimitException} + */ + @Deprecated + public MaxBrushRadiusException() { + } + //FAWE end } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/MaxRadiusException.java b/worldedit-core/src/main/java/com/sk89q/worldedit/MaxRadiusException.java index 6641c063c..1e5da912f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/MaxRadiusException.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/MaxRadiusException.java @@ -19,10 +19,24 @@ package com.sk89q.worldedit; +import com.fastasyncworldedit.core.exception.RadiusLimitException; + /** * Thrown when a maximum radius is reached, such as, for example, * in the case of a sphere command. + * + * @deprecated Use {@link RadiusLimitException} */ +@Deprecated public class MaxRadiusException extends WorldEditException { + //FAWE start + /** + * @deprecated Use {@link RadiusLimitException} + */ + @Deprecated + public MaxRadiusException() { + } + //FAWE end + } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEdit.java b/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEdit.java index 2c62e08ec..be4c9af8c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEdit.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEdit.java @@ -20,6 +20,8 @@ package com.sk89q.worldedit; import com.fastasyncworldedit.core.configuration.Caption; +import com.fastasyncworldedit.core.exception.BrushRadiusLimitException; +import com.fastasyncworldedit.core.exception.RadiusLimitException; import com.fastasyncworldedit.core.extension.factory.TransformFactory; import com.fastasyncworldedit.core.extent.ResettableExtent; import com.google.common.base.Throwables; @@ -437,7 +439,9 @@ public final class WorldEdit { * * @param radius the radius * @throws MaxRadiusException if the radius is bigger than the configured radius + * @deprecated Use {@link WorldEdit#checkMaxRadius(double, Actor)} */ + @Deprecated public void checkMaxRadius(double radius) throws MaxRadiusException { if (getConfiguration().maxRadius > 0 && radius > getConfiguration().maxRadius) { throw new MaxRadiusException(); @@ -449,7 +453,9 @@ public final class WorldEdit { * * @param radius the radius * @throws MaxBrushRadiusException if the radius is bigger than the configured radius + * @deprecated Use {@link WorldEdit#checkMaxBrushRadius(double, Actor)} */ + @Deprecated public void checkMaxBrushRadius(double radius) throws MaxBrushRadiusException { if (getConfiguration().maxBrushRadius > 0 && radius > getConfiguration().maxBrushRadius) { throw new MaxBrushRadiusException(); @@ -457,6 +463,10 @@ public final class WorldEdit { } //FAWE start + /** + * @deprecated Use {@link WorldEdit#checkMaxBrushRadius(Expression, Actor)} + */ + @Deprecated(forRemoval = true, since = "TODO") public void checkMaxBrushRadius(Expression radius) throws MaxBrushRadiusException { double val = radius.evaluate(); checkArgument(val >= 0, "Radius must be a positive number."); @@ -466,6 +476,53 @@ public final class WorldEdit { } } } + + /** + * Check the given radius against the give actor's limit. + * + * @param radius Radius to check + * @param actor Actor to check for + * @throws MaxRadiusException If given radius larger than allowed + * @since TODO + */ + public void checkMaxRadius(double radius, Actor actor) { + int max = actor.getLimit().MAX_RADIUS; + if (max > 0 && radius > max) { + throw new RadiusLimitException(max); + } + } + + /** + * Check the given radius against the give actor's limit. + * + * @param radius Radius to check + * @param actor Actor to check for + * @throws MaxRadiusException If given radius larger than allowed + * @since TODO + */ + public void checkMaxBrushRadius(double radius, Actor actor) { + int max = actor.getLimit().MAX_BRUSH_RADIUS; + if (max > 0 && radius > max) { + throw new RadiusLimitException(max); + } + } + + /** + * Check the given radius against the give actor's limit. + * + * @param expression Radius to check + * @param actor Actor to check for + * @throws BrushRadiusLimitException If given radius larger than allowed + * @since TODO + */ + public void checkMaxBrushRadius(Expression expression, Actor actor) { + double radius = expression.evaluate(); + checkArgument(radius >= 0, "Radius must be a positive number."); + int max = actor.getLimit().MAX_BRUSH_RADIUS; + if (max > 0 && radius > max) { + throw new BrushRadiusLimitException(max); + } + } //FAWE end /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java index 76cb60c64..bdd6a4ed4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java @@ -186,7 +186,10 @@ public class BrushCommands { @ArgFlag(name = 'm', desc = "Mask to limit blocks being considered", def = "") Mask mask ) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); + worldEdit.checkMaxBrushRadius( + radius, + context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player")) + ); checkCommandArgument(minFreqDiff >= 0 && minFreqDiff <= 26, "minFreqDiff not in range 0 <= value <= 26"); if (mask != null && !(mask instanceof CachedMask)) { mask = new CachedMask(mask, false); @@ -212,7 +215,10 @@ public class BrushCommands { @Arg(desc = "fillRec", def = "1") int fillRec ) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); + worldEdit.checkMaxBrushRadius( + radius, + context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player")) + ); set(context, new ErodeBrush(erodefaces, erodeRec, fillFaces, fillRec), "worldedit.brush.erode").setSize(radius); } @@ -234,7 +240,10 @@ public class BrushCommands { @Arg(desc = "fillRec", def = "1") int fillRec ) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); + worldEdit.checkMaxBrushRadius( + radius, + context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player")) + ); set(context, new RaiseBrush(erodefaces, erodeRec, fillFaces, fillRec), "worldedit.brush.pull").setSize(radius); } @@ -252,7 +261,10 @@ public class BrushCommands { @Arg(name = "filled", desc = "Whether the circle should be filled", def = "false") boolean filled ) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); + worldEdit.checkMaxBrushRadius( + radius, + context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player")) + ); set(context, new CircleBrush(filled), "worldedit.brush.sphere").setSize(radius).setFill(fill); } @@ -276,7 +288,10 @@ public class BrushCommands { @Switch(name = 'd', desc = "Apply in depth first order") boolean depthFirst ) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); + worldEdit.checkMaxBrushRadius( + radius, + context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player")) + ); set(context, new RecurseBrush(depthFirst), "worldedit.brush.recursive").setSize(radius).setFill(fill) .setMask(new IdMask(editSession)); } @@ -299,7 +314,10 @@ public class BrushCommands { @Switch(name = 'f', desc = "Create a flat line") boolean flat ) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); + worldEdit.checkMaxBrushRadius( + radius, + context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player")) + ); set(context, new LineBrush(shell, select, flat), "worldedit.brush.line").setSize(radius).setFill(fill); } @@ -326,7 +344,10 @@ public class BrushCommands { Expression radius ) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); + worldEdit.checkMaxBrushRadius( + radius, + context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player")) + ); player.print(Caption.of("fawe.worldedit.brush.brush.spline", (radius))); set(context, new SplineBrush(player), "worldedit.brush.spline").setSize(radius).setFill(fill); } @@ -379,7 +400,10 @@ public class BrushCommands { @Switch(name = 'd', desc = "sags the catenary toward the facing direction") boolean facingDirection ) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); + worldEdit.checkMaxBrushRadius( + radius, + context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player")) + ); set(context, new CatenaryBrush(shell, select, facingDirection, lengthFactor), "worldedit.brush.spline") .setSize(radius).setFill(fill); } @@ -411,7 +435,10 @@ public class BrushCommands { double quality ) throws WorldEditException { player.print(Caption.of("fawe.worldedit.brush.brush.spline", (radius))); - worldEdit.checkMaxBrushRadius(radius); + worldEdit.checkMaxBrushRadius( + radius, + context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player")) + ); set(context, new SurfaceSpline(tension, bias, continuity, quality), "surfacespline").setSize(radius) .setFill(fill); } @@ -436,9 +463,11 @@ public class BrushCommands { double amplitude ) throws WorldEditException { double max = MathMan.max(radius.getX(), radius.getY(), radius.getZ()); - worldEdit.checkMaxBrushRadius(max); - Brush brush = - new BlobBrush(radius.divide(max), frequency / 100, amplitude / 100, sphericity / 100); + worldEdit.checkMaxBrushRadius( + max, + context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player")) + ); + Brush brush = new BlobBrush(radius.divide(max), frequency / 100, amplitude / 100, sphericity / 100); set(context, brush, "worldedit.brush.rock").setSize(max).setFill(fill); } @@ -459,7 +488,10 @@ public class BrushCommands { @Arg(desc = "Lines", def = "10") int count ) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); + worldEdit.checkMaxBrushRadius( + radius, + context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player")) + ); set(context, new ShatterBrush(count), "worldedit.brush.shatter").setSize(radius).setFill(fill) .setMask(new ExistingBlockMask(editSession)); } @@ -490,7 +522,10 @@ public class BrushCommands { boolean randomRotate ) throws WorldEditException, FileNotFoundException { - worldEdit.checkMaxBrushRadius(radius); + worldEdit.checkMaxBrushRadius( + radius, + context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player")) + ); InputStream stream = getHeightmapStream(image); HeightBrush brush; int minY = player.getWorld().getMinY(); @@ -526,7 +561,10 @@ public class BrushCommands { URL url = new URL(imageURL); MainUtil.checkImageHost(url.toURI()); BufferedImage image = MainUtil.readImage(url); - worldEdit.checkMaxBrushRadius(radius); + worldEdit.checkMaxBrushRadius( + radius, + context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player")) + ); if (yscale != 1) { ImageUtil.scaleAlpha(image, yscale); alpha = true; @@ -553,7 +591,10 @@ public class BrushCommands { @Arg(desc = "Expression", def = "5") Expression radius ) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); + worldEdit.checkMaxBrushRadius( + radius, + context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player")) + ); set(context, new SurfaceSphereBrush(), "worldedit.brush.surface").setFill(fill).setSize(radius); } @@ -578,7 +619,10 @@ public class BrushCommands { @Switch(name = 'o', desc = "Overlay the block") boolean overlay ) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); + worldEdit.checkMaxBrushRadius( + radius, + context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player")) + ); Brush brush; if (overlay) { brush = new ScatterOverlayBrush((int) points, (int) distance); @@ -612,7 +656,10 @@ public class BrushCommands { @Switch(name = 'r', desc = "Apply random rotation") boolean rotate ) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); + worldEdit.checkMaxBrushRadius( + radius, + context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player")) + ); try { MultiClipboardHolder clipboards = ClipboardFormats.loadAllFromInput(player, clipboardStr, null, true); @@ -651,7 +698,10 @@ public class BrushCommands { List patternLayers ) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); + worldEdit.checkMaxBrushRadius( + radius, + context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player")) + ); set(context, new LayerBrush(patternLayers.toArray(new Pattern[0])), "worldedit.brush.layer").setSize(radius); } @@ -678,7 +728,10 @@ public class BrushCommands { @Arg(desc = "boolean", def = "true") boolean solid ) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); + worldEdit.checkMaxBrushRadius( + radius, + context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player")) + ); set(context, new SplatterBrush((int) points, (int) recursion, solid), "worldedit.brush.splatter").setSize(radius) .setFill(fill); } @@ -711,7 +764,10 @@ public class BrushCommands { boolean print ) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); + worldEdit.checkMaxBrushRadius( + radius, + context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player")) + ); set( context, new ScatterCommand((int) points, (int) distance, StringMan.join(commandStr, " "), print), @@ -838,7 +894,10 @@ public class BrushCommands { InjectedValueAccess context ) throws WorldEditException, FileNotFoundException { - worldEdit.checkMaxBrushRadius(radius); + worldEdit.checkMaxBrushRadius( + radius, + context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player")) + ); InputStream stream = getHeightmapStream(image); HeightBrush brush; int minY = player.getWorld().getMinY(); @@ -908,7 +967,10 @@ public class BrushCommands { @Switch(name = 'a', desc = "Apply auto view based rotation on paste") boolean autoRotate ) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); + worldEdit.checkMaxBrushRadius( + radius, + context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player")) + ); player.print(Caption.of("fawe.worldedit.brush.brush.copy", (radius))); set(context, new CopyPastaBrush(player, session, randomRotate, autoRotate), "worldedit.brush.copy").setSize(radius); @@ -933,7 +995,10 @@ public class BrushCommands { @Switch(name = 'p', desc = "Show any printed output") boolean print ) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); + worldEdit.checkMaxBrushRadius( + radius, + context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player")) + ); String cmd = StringMan.join(input, " "); set(context, new CommandBrush(cmd, print), "worldedit.brush.command").setSize(radius); } @@ -1042,7 +1107,7 @@ public class BrushCommands { String permission ) throws WorldEditException { - WorldEdit.getInstance().checkMaxBrushRadius(radius); + WorldEdit.getInstance().checkMaxBrushRadius(radius, player); BrushTool tool = session.getBrushTool(player); tool.setSize(radius); tool.setFill(null); @@ -1197,7 +1262,10 @@ public class BrushCommands { @Switch(name = 'f', desc = "Create falling spheres instead") boolean falling ) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); + worldEdit.checkMaxBrushRadius( + radius, + context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player")) + ); Brush brush; if (hollow) { brush = new HollowSphereBrush(); @@ -1244,8 +1312,14 @@ public class BrushCommands { @Switch(name = 'h', desc = "Create hollow cylinders instead") boolean hollow ) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); - worldEdit.checkMaxBrushRadius(height); + worldEdit.checkMaxBrushRadius( + radius, + context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player")) + ); + worldEdit.checkMaxBrushRadius( + height, + context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player")) + ); BrushSettings settings; if (hollow) { @@ -1293,9 +1367,18 @@ public class BrushCommands { BlockVector3 size = clipboard.getDimensions(); - worldEdit.checkMaxBrushRadius(size.getBlockX() / 2D - 1); - worldEdit.checkMaxBrushRadius(size.getBlockY() / 2D - 1); - worldEdit.checkMaxBrushRadius(size.getBlockZ() / 2D - 1); + worldEdit.checkMaxBrushRadius( + size.getBlockX() / 2D - 1, + context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player")) + ); + worldEdit.checkMaxBrushRadius( + size.getBlockY() / 2D - 1, + context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player")) + ); + worldEdit.checkMaxBrushRadius( + size.getBlockZ() / 2D - 1, + context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player")) + ); set( context, @@ -1324,7 +1407,10 @@ public class BrushCommands { Mask mask, InjectedValueAccess context ) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); + worldEdit.checkMaxBrushRadius( + radius, + context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player")) + ); //FAWE start FaweLimit limit = Settings.settings().getLimit(player); @@ -1359,7 +1445,10 @@ public class BrushCommands { @ArgFlag(name = 'm', desc = "The mask of blocks to use for the heightmap") Mask mask, InjectedValueAccess context ) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); + worldEdit.checkMaxBrushRadius( + radius, + context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player")) + ); //FAWE start FaweLimit limit = Settings.settings().getLimit(player); @@ -1386,7 +1475,10 @@ public class BrushCommands { @Arg(desc = "The radius to extinguish", def = "5") Expression radius ) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); + worldEdit.checkMaxBrushRadius( + radius, + context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player")) + ); set(context, new SphereBrush(), "worldedit.brush.ex").setSize(radius).setFill(BlockTypes.AIR.getDefaultState()) .setMask(new SingleBlockTypeMask(editSession, BlockTypes.FIRE)); @@ -1405,7 +1497,10 @@ public class BrushCommands { @Switch(name = 'h', desc = "Affect blocks starting at max Y, rather than the target location Y + radius") boolean fromMaxY ) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); + worldEdit.checkMaxBrushRadius( + radius, + context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player")) + ); set(context, new GravityBrush(fromMaxY), "worldedit.brush.gravity").setSize(radius); } @@ -1439,7 +1534,10 @@ public class BrushCommands { @Switch(name = 'w', desc = "Also kill water mobs") boolean killWater, InjectedValueAccess context ) throws WorldEditException { - worldEdit.checkMaxBrushRadius(radius); + worldEdit.checkMaxBrushRadius( + radius, + context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player")) + ); CreatureButcher flags = new CreatureButcher(player); flags.or( @@ -1508,7 +1606,7 @@ public class BrushCommands { RegionFactory shape, String permission ) throws WorldEditException { - WorldEdit.getInstance().checkMaxBrushRadius(radius); + WorldEdit.getInstance().checkMaxBrushRadius(radius, player); BrushTool tool = session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType()); tool.setSize(radius); tool.setFill(null); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java index d3d456965..90b59cb52 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java @@ -130,9 +130,9 @@ public class GenerationCommands { return 0; } } - worldEdit.checkMaxRadius(radiusX); - worldEdit.checkMaxRadius(radiusZ); - worldEdit.checkMaxRadius(height); + worldEdit.checkMaxRadius(radiusX, actor); + worldEdit.checkMaxRadius(radiusZ, actor); + worldEdit.checkMaxRadius(height, actor); if (thickness > radiusX || thickness > radiusZ) { actor.print(Caption.of("worldedit.hcyl.thickness-too-large")); @@ -178,9 +178,9 @@ public class GenerationCommands { } } - worldEdit.checkMaxRadius(radiusX); - worldEdit.checkMaxRadius(radiusZ); - worldEdit.checkMaxRadius(height); + worldEdit.checkMaxRadius(radiusX, actor); + worldEdit.checkMaxRadius(radiusZ, actor); + worldEdit.checkMaxRadius(height, actor); BlockVector3 pos = session.getPlacementPosition(actor); int affected = editSession.makeCylinder(pos, pattern, radiusX, radiusZ, height, !hollow); @@ -224,9 +224,9 @@ public class GenerationCommands { } } - worldEdit.checkMaxRadius(radiusX); - worldEdit.checkMaxRadius(radiusZ); - worldEdit.checkMaxRadius(height); + worldEdit.checkMaxRadius(radiusX, actor); + worldEdit.checkMaxRadius(radiusZ, actor); + worldEdit.checkMaxRadius(height, actor); BlockVector3 pos = session.getPlacementPosition(actor); int affected = editSession.makeCone(pos, pattern, radiusX, radiusZ, height, !hollow, thickness); @@ -290,9 +290,9 @@ public class GenerationCommands { } } - worldEdit.checkMaxRadius(radiusX); - worldEdit.checkMaxRadius(radiusY); - worldEdit.checkMaxRadius(radiusZ); + worldEdit.checkMaxRadius(radiusX, actor); + worldEdit.checkMaxRadius(radiusY, actor); + worldEdit.checkMaxRadius(radiusZ, actor); BlockVector3 pos = session.getPlacementPosition(actor); if (raised) { pos = pos.add(0, (int) radiusY, 0); @@ -323,7 +323,7 @@ public class GenerationCommands { double density ) throws WorldEditException { checkCommandArgument(0 <= density && density <= 100, "Density must be between 0 and 100"); - worldEdit.checkMaxRadius(size); + worldEdit.checkMaxRadius(size, actor); density /= 100; int affected = editSession.makeForest(session.getPlacementPosition(actor), size, density, type); actor.print(Caption.of("worldedit.forestgen.created", TextComponent.of(affected))); @@ -345,7 +345,7 @@ public class GenerationCommands { double density ) throws WorldEditException { checkCommandArgument(0 <= density && density <= 100, "Density must be between 0 and 100"); - worldEdit.checkMaxRadius(size); + worldEdit.checkMaxRadius(size, actor); int affected = editSession.makePumpkinPatches(session.getPlacementPosition(actor), size, density); actor.print(Caption.of("worldedit.pumpkins.created", TextComponent.of(affected))); return affected; @@ -382,7 +382,7 @@ public class GenerationCommands { @Switch(name = 'h', desc = "Make a hollow pyramid") boolean hollow ) throws WorldEditException { - worldEdit.checkMaxRadius(size); + worldEdit.checkMaxRadius(size, actor); BlockVector3 pos = session.getPlacementPosition(actor); int affected = editSession.makePyramid(pos, pattern, size, !hollow); if (actor instanceof Player && Settings.settings().GENERAL.UNSTUCK_ON_GENERATE) { @@ -736,7 +736,7 @@ public class GenerationCommands { double amplitude ) throws WorldEditException { double max = MathMan.max(radius.getX(), radius.getY(), radius.getZ()); - worldEdit.checkMaxRadius(max); + worldEdit.checkMaxRadius(max, actor); BlockVector3 pos = session.getPlacementPosition(actor); int affected = editSession.makeBlob( pos, diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SuperPickaxeCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SuperPickaxeCommands.java index cb24daec5..fdd86498f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SuperPickaxeCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SuperPickaxeCommands.java @@ -66,10 +66,11 @@ public class SuperPickaxeCommands { int range ) throws WorldEditException { - LocalConfiguration config = we.getConfiguration(); - - if (range > config.maxSuperPickaxeSize) { - player.print(Caption.of("worldedit.tool.superpickaxe.max-range", TextComponent.of(config.maxSuperPickaxeSize))); + if (range > player.getLimit().MAX_SUPER_PICKAXE_SIZE) { + player.print(Caption.of( + "worldedit.tool.superpickaxe.max-range", + TextComponent.of(player.getLimit().MAX_SUPER_PICKAXE_SIZE) + )); return; } session.setSuperPickaxe(new AreaPickaxe(range)); @@ -89,10 +90,11 @@ public class SuperPickaxeCommands { double range ) throws WorldEditException { - LocalConfiguration config = we.getConfiguration(); - - if (range > config.maxSuperPickaxeSize) { - player.print(Caption.of("worldedit.tool.superpickaxe.max-range", TextComponent.of(config.maxSuperPickaxeSize))); + if (range > player.getLimit().MAX_SUPER_PICKAXE_SIZE) { + player.print(Caption.of( + "worldedit.tool.superpickaxe.max-range", + TextComponent.of(player.getLimit().MAX_SUPER_PICKAXE_SIZE) + )); return; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java index 8395b2e2d..95499372c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java @@ -297,10 +297,11 @@ public class ToolCommands { int range ) throws WorldEditException { - LocalConfiguration config = we.getConfiguration(); - - if (range > config.maxSuperPickaxeSize) { - player.print(Caption.of("worldedit.tool.superpickaxe.max-range", TextComponent.of(config.maxSuperPickaxeSize))); + if (range > player.getLimit().MAX_SUPER_PICKAXE_SIZE) { + player.print(Caption.of( + "worldedit.tool.superpickaxe.max-range", + TextComponent.of(player.getLimit().MAX_SUPER_PICKAXE_SIZE) + )); return; } setTool(player, session, new FloodFillTool(range, pattern), "worldedit.tool.floodfill.equip"); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolUtilCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolUtilCommands.java index 0694b2af3..48fb76318 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolUtilCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolUtilCommands.java @@ -154,7 +154,7 @@ public class ToolUtilCommands { @Arg(desc = "The size of the brush") int size ) throws WorldEditException { - we.checkMaxBrushRadius(size); + we.checkMaxBrushRadius(size, player); session.getBrushTool(player).setSize(size); player.print(Caption.of("worldedit.tool.size.set")); 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 aca13bc46..a336f4b12 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 @@ -246,8 +246,9 @@ public class UtilityCommands { double radius = radiusExp.evaluate(); //FAWE end radius = Math.max(1, radius); - we.checkMaxRadius(radius); + we.checkMaxRadius(radius, actor); depth = Math.max(1, depth); + we.checkMaxRadius(depth, actor); BlockVector3 pos = session.getPlacementPosition(actor); int affected = editSession.fillDirection(pos, pattern, radius, depth, direction); @@ -333,9 +334,9 @@ public class UtilityCommands { double radius = radiusExp.evaluate(); //FAWE end radius = Math.max(1, radius); - we.checkMaxRadius(radius); + we.checkMaxRadius(radius, actor); depth = depth == null ? Integer.MAX_VALUE : Math.max(1, depth); - we.checkMaxRadius(radius); + we.checkMaxRadius(radius, actor); BlockVector3 pos = session.getPlacementPosition(actor); int affected = editSession.fillXZ(pos, pattern, radius, depth, true); @@ -364,7 +365,7 @@ public class UtilityCommands { //FAWE end double radius = radiusExp.evaluate(); radius = Math.max(0, radius); - we.checkMaxRadius(radius); + we.checkMaxRadius(radius, actor); int affected = editSession.drainArea(session.getPlacementPosition(actor), radius, waterlogged, plants); actor.print(Caption.of("worldedit.drain.drained", TextComponent.of(affected))); return affected; @@ -383,7 +384,7 @@ public class UtilityCommands { double radius ) throws WorldEditException { radius = Math.max(0, radius); - we.checkMaxRadius(radius); + we.checkMaxRadius(radius, actor); int affected = editSession.fixLiquid(session.getPlacementPosition(actor), radius, BlockTypes.LAVA); actor.print(Caption.of("worldedit.fixlava.fixed", TextComponent.of(affected))); return affected; @@ -402,7 +403,7 @@ public class UtilityCommands { double radius ) throws WorldEditException { radius = Math.max(0, radius); - we.checkMaxRadius(radius); + we.checkMaxRadius(radius, actor); int affected = editSession.fixLiquid(session.getPlacementPosition(actor), radius, BlockTypes.WATER); actor.print(Caption.of("worldedit.fixwater.fixed", TextComponent.of(affected))); return affected; @@ -423,7 +424,7 @@ public class UtilityCommands { Integer height ) throws WorldEditException { size = Math.max(1, size); - we.checkMaxRadius(size); + we.checkMaxRadius(size, actor); height = height != null ? Math.min((world.getMaxY() - world.getMinY() + 1), height + 1) @@ -448,7 +449,7 @@ public class UtilityCommands { Integer height ) throws WorldEditException { size = Math.max(1, size); - we.checkMaxRadius(size); + we.checkMaxRadius(size, actor); height = height != null ? Math.min((world.getMaxY() - world.getMinY() + 1), height + 1) @@ -476,7 +477,7 @@ public class UtilityCommands { new MaskTraverser(mask).setNewExtent(editSession); //FAWE end radius = Math.max(1, radius); - we.checkMaxRadius(radius); + we.checkMaxRadius(radius, actor); int affected = editSession.removeNear(session.getPlacementPosition(actor), mask, radius); actor.print(Caption.of("worldedit.removenear.removed", TextComponent.of(affected))); @@ -503,7 +504,7 @@ public class UtilityCommands { new MaskTraverser(from).setNewExtent(editSession); //FAWE end radius = Math.max(1, radius); - we.checkMaxRadius(radius); + we.checkMaxRadius(radius, actor); BlockVector3 base = session.getPlacementPosition(actor); BlockVector3 min = base.subtract(radius, radius, radius); @@ -542,7 +543,7 @@ public class UtilityCommands { ) throws WorldEditException { size = Math.max(1, size); height = Math.max(1, height); - we.checkMaxRadius(size); + we.checkMaxRadius(size, actor); BlockVector3 position = session.getPlacementPosition(actor); @@ -579,7 +580,7 @@ public class UtilityCommands { ) throws WorldEditException { size = Math.max(1, size); height = Math.max(1, height); - we.checkMaxRadius(size); + we.checkMaxRadius(size, actor); int affected = editSession.thaw(session.getPlacementPosition(actor), size, height); actor.print(Caption.of( @@ -610,7 +611,7 @@ public class UtilityCommands { ) throws WorldEditException { size = Math.max(1, size); height = Math.max(1, height); - we.checkMaxRadius(size); + we.checkMaxRadius(size, actor); final boolean onlyNormalDirt = !convertCoarse; final int affected = editSession.green( @@ -635,11 +636,9 @@ public class UtilityCommands { Integer radius ) throws WorldEditException { - LocalConfiguration config = we.getConfiguration(); - - int defaultRadius = config.maxRadius != -1 ? Math.min(40, config.maxRadius) : 40; + int defaultRadius = actor.getLimit().MAX_RADIUS != -1 ? Math.min(40, actor.getLimit().MAX_RADIUS) : 40; int size = radius != null ? Math.max(1, radius) : defaultRadius; - we.checkMaxRadius(size); + we.checkMaxRadius(size, actor); Mask mask = new BlockTypeMask(editSession, BlockTypes.FIRE); int affected = editSession.removeNear(session.getPlacementPosition(actor), mask, size); @@ -685,12 +684,12 @@ public class UtilityCommands { actor.print(Caption.of("worldedit.butcher.explain-all")); return 0; } else if (radius == -1) { - if (config.butcherMaxRadius != -1) { - radius = config.butcherMaxRadius; + if (actor.getLimit().MAX_BUTCHER_RADIUS != -1) { + radius = actor.getLimit().MAX_BUTCHER_RADIUS; } } - if (config.butcherMaxRadius != -1) { - radius = Math.min(radius, config.butcherMaxRadius); + if (actor.getLimit().MAX_BUTCHER_RADIUS != -1) { + radius = Math.min(radius, actor.getLimit().MAX_BUTCHER_RADIUS); } CreatureButcher flags = new CreatureButcher(actor); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java index d6c44fa66..c4d45d683 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java @@ -477,7 +477,7 @@ public class BrushTool try { new PatternTraverser(current).reset(editSession); double size = current.getSize(); - WorldEdit.getInstance().checkMaxBrushRadius(size); + WorldEdit.getInstance().checkMaxBrushRadius(size, player); brush.build(editSession, target.toBlockPoint(), current.getMaterial(), size); } catch (MaxChangedBlocksException e) { player.print(Caption.of("worldedit.tool.max-block-changes")); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/Confirm.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/Confirm.java index a2854a8c7..37ea4abeb 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/Confirm.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/Confirm.java @@ -75,7 +75,7 @@ public @interface Confirm { if (checkExisting(context)) { return true; } - int max = WorldEdit.getInstance().getConfiguration().maxRadius; + int max = actor.getLimit().MAX_RADIUS; if (max != -1 && value > max) { actor.print(Caption.of("fawe.cancel.reason.confirm.radius", value, max, getArgs(context) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/exception/WorldEditExceptionConverter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/exception/WorldEditExceptionConverter.java index a0c5eb328..b07f3f61d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/exception/WorldEditExceptionConverter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/exception/WorldEditExceptionConverter.java @@ -20,6 +20,8 @@ package com.sk89q.worldedit.internal.command.exception; import com.fastasyncworldedit.core.configuration.Caption; +import com.fastasyncworldedit.core.exception.BrushRadiusLimitException; +import com.fastasyncworldedit.core.exception.RadiusLimitException; import com.fastasyncworldedit.core.internal.exception.FaweException; import com.google.common.collect.ImmutableList; import com.sk89q.worldedit.DisallowedItemException; @@ -134,6 +136,18 @@ public class WorldEditExceptionConverter extends ExceptionConverterHelper { ); } + //FAWE start + @ExceptionMatch + public void convert(BrushRadiusLimitException e) throws CommandException { + throw newCommandException(Caption.of("fawe.error.limit.max-brush-radius", TextComponent.of(e.getMaxRadius())), e); + } + + @ExceptionMatch + public void convert(RadiusLimitException e) throws CommandException { + throw newCommandException(Caption.of("fawe.error.limit.max-radius", TextComponent.of(e.getMaxRadius())), e); + } + //FAWE end + @ExceptionMatch public void convert(UnknownDirectionException e) throws CommandException { throw newCommandException(e.getRichMessage(), e); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java index f350af03f..3804be8d3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java @@ -136,6 +136,14 @@ public class PropertiesConfiguration extends LocalConfiguration { scriptsDir = getString("craftscript-dir", scriptsDir); butcherDefaultRadius = getInt("butcher-default-radius", butcherDefaultRadius); butcherMaxRadius = getInt("butcher-max-radius", butcherMaxRadius); + + //FAWE start + MAX_RADIUS = maxRadius; + MAX_BRUSH_RADIUS = maxBrushRadius; + MAX_SUPER_RADIUS = maxSuperPickaxeSize; + MAX_BUTCHER_RADIUS = butcherMaxRadius; + //FAWE end + allowSymlinks = getBool("allow-symbolic-links", allowSymlinks); serverSideCUI = getBool("server-side-cui", serverSideCUI); extendedYLimit = getBool("extended-y-limit", extendedYLimit); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java index 1a8b0667c..7b0cbf4b8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java @@ -95,6 +95,13 @@ public class YAMLConfiguration extends LocalConfiguration { butcherDefaultRadius = Math.max(-1, config.getInt("limits.butcher-radius.default", butcherDefaultRadius)); butcherMaxRadius = Math.max(-1, config.getInt("limits.butcher-radius.maximum", butcherMaxRadius)); + //FAWE start + MAX_RADIUS = maxRadius; + MAX_BRUSH_RADIUS = maxBrushRadius; + MAX_SUPER_RADIUS = maxSuperPickaxeSize; + MAX_BUTCHER_RADIUS = butcherMaxRadius; + //FAWE end + disallowedBlocks = config.getStringList("limits.disallowed-blocks", Lists.newArrayList(getDefaultDisallowedBlocks())) .stream() .map(s -> s.contains(":") ? s.toLowerCase(Locale.ROOT) : ("minecraft:" + s).toLowerCase(Locale.ROOT)) diff --git a/worldedit-core/src/main/resources/lang/strings.json b/worldedit-core/src/main/resources/lang/strings.json index 208de9027..c343dd623 100644 --- a/worldedit-core/src/main/resources/lang/strings.json +++ b/worldedit-core/src/main/resources/lang/strings.json @@ -137,6 +137,8 @@ "fawe.error.limit.disallowed-property": "Your limit disallows use of property '{0}'", "fawe.error.region-mask-invalid": "Invalid region mask: {0}", "fawe.error.occurred-continuing": "Ignorable error occurred during edit: {0}", + "fawe.error.limit.max-brush-radius": "Maximum brush radius in limit: {0}", + "fawe.error.limit.max-radius": "Maximum radius in limit: {0}", "fawe.cancel.count": "Cancelled {0} edits.", "fawe.cancel.reason.confirm": "Use //confirm to execute {0}", "fawe.cancel.reason.confirm.region": "Your selection is large ({0} -> {1}, containing {3} blocks). Use //confirm to execute {2}", From c77d34156b5f5b460691c74a5573a8a0ba1d7996 Mon Sep 17 00:00:00 2001 From: Pierre Maurice Schwang Date: Sat, 25 May 2024 13:36:37 +0200 Subject: [PATCH 73/90] Fix compatibility with WorldGuard (#2743) * Make the Vector classes into Records (#2477) * Make the Vector classes into Records * Drop custom equals and hashCode methods in Vector/BlockVector classes (cherry picked from commit 0df2b6af4c1ce18b77eedd5c62eeb45011512103) Signed-off-by: Pierre Maurice Schwang * chore: cleanup cherry-pick issues, migrate to new methods * chore: add since attributes to deprecated tags, use MathMan instead of Math std lib for rounding ints * chore: mark custom hashCode + equals implementations diffing from upstream --------- Co-authored-by: Maddy Miller --- .../adapters/adapter-1_20_5/build.gradle.kts | 2 +- .../filter/block/AbstractFilterBlock.java | 20 +- .../extent/filter/block/ArrayFilterBlock.java | 10 +- .../extent/filter/block/CharFilterBlock.java | 16 +- .../core/extent/filter/block/FilterBlock.java | 32 +-- .../filter/block/SingleFilterBlock.java | 6 +- .../core/math/DelegateBlockVector3.java | 27 +- .../core/math/MutableBlockVector3.java | 22 +- .../core/math/MutableVector3.java | 14 +- .../core/math/OffsetBlockVector3.java | 12 +- .../core/math/Vector3Impl.java | 8 +- .../sk89q/worldedit/math/BlockVector2.java | 35 ++- .../sk89q/worldedit/math/BlockVector3.java | 253 ++++++++++------- .../sk89q/worldedit/math/BlockVector3Imp.java | 12 +- .../com/sk89q/worldedit/math/Vector2.java | 59 ++-- .../com/sk89q/worldedit/math/Vector3.java | 266 +++++++++++------- .../com/sk89q/worldedit/util/Location.java | 14 +- 17 files changed, 454 insertions(+), 354 deletions(-) diff --git a/worldedit-bukkit/adapters/adapter-1_20_5/build.gradle.kts b/worldedit-bukkit/adapters/adapter-1_20_5/build.gradle.kts index a0ee57dc2..80c044f91 100644 --- a/worldedit-bukkit/adapters/adapter-1_20_5/build.gradle.kts +++ b/worldedit-bukkit/adapters/adapter-1_20_5/build.gradle.kts @@ -12,6 +12,6 @@ repositories { dependencies { // url=https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/1.20.6-R0.1-SNAPSHOT/ - the().paperDevBundle("1.20.6-R0.1-20240520.005421-60") + the().paperDevBundle("1.20.6-R0.1-20240523.202134-70") compileOnly(libs.paperlib) } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/block/AbstractFilterBlock.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/block/AbstractFilterBlock.java index b91ef08b0..4f3db3994 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/block/AbstractFilterBlock.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/block/AbstractFilterBlock.java @@ -31,18 +31,18 @@ public abstract class AbstractFilterBlock extends FilterBlock { public abstract Extent getExtent(); @Override - public int getX() { - return getPosition().getX(); + public int x() { + return getPosition().x(); } @Override - public int getY() { - return getPosition().getY(); + public int y() { + return getPosition().y(); } @Override - public int getZ() { - return getPosition().getZ(); + public int z() { + return getPosition().z(); } @Override @@ -72,12 +72,12 @@ public abstract class AbstractFilterBlock extends FilterBlock { @Override public BlockVector3 getMinimumPoint() { - return at(getX(), getY(), getZ()); + return at(x(), y(), z()); } @Override public BlockVector3 getMaximumPoint() { - return at(getX(), getY(), getZ()); + return at(x(), y(), z()); } @Override @@ -88,7 +88,7 @@ public abstract class AbstractFilterBlock extends FilterBlock { @Override public > boolean setBlock(int x, int y, int z, T block) throws WorldEditException { - if (x == this.getX() && y == this.getY() && z == this.getZ()) { + if (x == this.x() && y == this.y() && z == this.z()) { setFullBlock(block.toBaseBlock()); return true; } @@ -97,7 +97,7 @@ public abstract class AbstractFilterBlock extends FilterBlock { @Override public boolean setBiome(int x, int y, int z, BiomeType biome) { - if (x == this.getX() && y == this.getY() && z == this.getZ()) { + if (x == this.x() && y == this.y() && z == this.z()) { setBiome(biome); return true; } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/block/ArrayFilterBlock.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/block/ArrayFilterBlock.java index 4f73d5fa3..362f869ac 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/block/ArrayFilterBlock.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/block/ArrayFilterBlock.java @@ -80,17 +80,17 @@ public class ArrayFilterBlock extends AbstractExtentFilterBlock { } @Override - public int getX() { + public int x() { return x; } @Override - public int getY() { + public int y() { return (heights[index] & 0xFF) + yOffset; } @Override - public int getZ() { + public int z() { return z; } @@ -112,12 +112,12 @@ public class ArrayFilterBlock extends AbstractExtentFilterBlock { @Override public void setBiome(final BiomeType biome) { - getExtent().setBiome(getX(), getY(), getZ(), biome); + getExtent().setBiome(x(), y(), z(), biome); } @Override public BiomeType getBiome() { - return getExtent().getBiomeType(getX(), getY(), getZ()); + return getExtent().getBiomeType(x(), y(), z()); } } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/block/CharFilterBlock.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/block/CharFilterBlock.java index 9a339826a..579f04a9a 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/block/CharFilterBlock.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/block/CharFilterBlock.java @@ -190,17 +190,17 @@ public class CharFilterBlock extends ChunkFilterBlock { } @Override - public final int getX() { + public final int x() { return xx + x; } @Override - public final int getY() { + public final int y() { return yy + y; } @Override - public final int getZ() { + public final int z() { return zz + z; } @@ -304,7 +304,7 @@ public class CharFilterBlock extends ChunkFilterBlock { if (z > 0) { return states[getArr[index - 16]]; } - return getExtent().getBlock(getX(), getY(), getZ() - 1); + return getExtent().getBlock(x(), y(), z() - 1); } @Override @@ -312,7 +312,7 @@ public class CharFilterBlock extends ChunkFilterBlock { if (x < 15) { return states[getArr[index + 1]]; } - return getExtent().getBlock(getX() + 1, getY(), getZ()); + return getExtent().getBlock(x() + 1, y(), z()); } @Override @@ -320,7 +320,7 @@ public class CharFilterBlock extends ChunkFilterBlock { if (z < 15) { return states[getArr[index + 16]]; } - return getExtent().getBlock(getX(), getY(), getZ() + 1); + return getExtent().getBlock(x(), y(), z() + 1); } @Override @@ -328,7 +328,7 @@ public class CharFilterBlock extends ChunkFilterBlock { if (x > 0) { return states[getArr[index - 1]]; } - return getExtent().getBlock(getX() - 1, getY(), getZ()); + return getExtent().getBlock(x() - 1, y(), z()); } @Override @@ -401,7 +401,7 @@ public class CharFilterBlock extends ChunkFilterBlock { @Override public boolean setBiome(BlockVector3 position, BiomeType biome) { - return setBiome(position.getX(), position.getY(), position.getBlockZ(), biome); + return setBiome(position.x(), position.y(), position.z(), biome); } @Override diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/block/FilterBlock.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/block/FilterBlock.java index c27d3770a..3565c696f 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/block/FilterBlock.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/block/FilterBlock.java @@ -73,60 +73,60 @@ public abstract class FilterBlock extends BlockVector3 implements Extent, TileEn } public BlockState getBlockBelow() { - return getBlock(getX(), getY() - 1, getZ()); + return getBlock(x(), y() - 1, z()); } public BlockState getBlockAbove() { - return getBlock(getX(), getY() + 1, getZ()); + return getBlock(x(), y() + 1, z()); } public BlockState getBlockNorth() { - return getBlock(getX(), getY(), getZ() - 1); + return getBlock(x(), y(), z() - 1); } public BlockState getBlockEast() { - return getBlock(getX() + 1, getY(), getZ()); + return getBlock(x() + 1, y(), z()); } public BlockState getBlockSouth() { - return getBlock(getX(), getY(), getZ() + 1); + return getBlock(x(), y(), z() + 1); } public BlockState getBlockWest() { - return getBlock(getX() - 1, getY(), getZ()); + return getBlock(x() - 1, y(), z()); } public BlockState getBlockRelativeY(int y) { - return getBlock(getX(), getY() + y, getZ()); + return getBlock(x(), y() + y, z()); } @Override - public abstract int getX(); + public abstract int x(); @Override - public abstract int getY(); + public abstract int y(); @Override - public abstract int getZ(); + public abstract int z(); public int getLocalX() { - return getX() & 15; + return x() & 15; } public int getLocalY() { - return getY() & 15; + return y() & 15; } public int getLocalZ() { - return getZ() & 15; + return z() & 15; } public int getChunkX() { - return getX() >> 4; + return x() >> 4; } public int getChunkZ() { - return getZ() >> 4; + return z() >> 4; } /* @@ -204,7 +204,7 @@ public abstract class FilterBlock extends BlockVector3 implements Extent, TileEn @Override public boolean setBiome(BlockVector3 position, BiomeType biome) { - return setBiome(position.getX(), position.getY(), position.getZ(), biome); + return setBiome(position.x(), position.y(), position.z(), biome); } } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/block/SingleFilterBlock.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/block/SingleFilterBlock.java index 5516ae3bb..83301c4ea 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/block/SingleFilterBlock.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/block/SingleFilterBlock.java @@ -17,17 +17,17 @@ public class SingleFilterBlock extends AbstractSingleFilterBlock { } @Override - public int getX() { + public int x() { return x; } @Override - public int getY() { + public int y() { return y; } @Override - public int getZ() { + public int z() { return z; } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/DelegateBlockVector3.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/DelegateBlockVector3.java index b75e157b2..b13aece41 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/DelegateBlockVector3.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/DelegateBlockVector3.java @@ -95,13 +95,8 @@ public class DelegateBlockVector3 extends BlockVector3 { } @Override - public int getX() { - return parent.getX(); - } - - @Override - public int getBlockX() { - return parent.getBlockX(); + public int x() { + return parent.x(); } @Override @@ -110,13 +105,8 @@ public class DelegateBlockVector3 extends BlockVector3 { } @Override - public int getY() { - return parent.getY(); - } - - @Override - public int getBlockY() { - return parent.getBlockY(); + public int y() { + return parent.y(); } @Override @@ -125,13 +115,8 @@ public class DelegateBlockVector3 extends BlockVector3 { } @Override - public int getZ() { - return parent.getZ(); - } - - @Override - public int getBlockZ() { - return parent.getBlockZ(); + public int z() { + return parent.z(); } @Override diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/MutableBlockVector3.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/MutableBlockVector3.java index 6ebabae1d..e4cfda85a 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/MutableBlockVector3.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/MutableBlockVector3.java @@ -21,11 +21,11 @@ public class MutableBlockVector3 extends BlockVector3 { } public MutableBlockVector3(BlockVector3 other) { - this(other.getX(), other.getY(), other.getZ()); + this(other.x(), other.y(), other.z()); } public MutableBlockVector3 setComponents(BlockVector3 other) { - return setComponents(other.getBlockX(), other.getBlockY(), other.getBlockZ()); + return setComponents(other.x(), other.y(), other.z()); } private int x; @@ -47,33 +47,33 @@ public class MutableBlockVector3 extends BlockVector3 { } @Override - public final int getX() { + public final int x() { return x; } @Override - public final int getY() { + public final int y() { return y; } @Override - public final int getZ() { + public final int z() { return z; } @Override public BlockVector3 getMinimum(BlockVector3 v2) { - this.x = Math.min(v2.getX(), x); - this.y = Math.min(v2.getY(), y); - this.z = Math.min(v2.getZ(), z); + this.x = Math.min(v2.x(), x); + this.y = Math.min(v2.y(), y); + this.z = Math.min(v2.z(), z); return this; } @Override public BlockVector3 getMaximum(BlockVector3 v2) { - this.x = Math.max(v2.getX(), x); - this.y = Math.max(v2.getY(), y); - this.z = Math.max(v2.getZ(), z); + this.x = Math.max(v2.x(), x); + this.y = Math.max(v2.y(), y); + this.z = Math.max(v2.z(), z); return this; } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/MutableVector3.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/MutableVector3.java index 22d85d38a..3c6ad1334 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/MutableVector3.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/MutableVector3.java @@ -23,7 +23,7 @@ public class MutableVector3 extends Vector3 { } public MutableVector3(Vector3 other) { - this(other.getX(), other.getY(), other.getZ()); + this(other.x(), other.y(), other.z()); } public static MutableVector3 get(int x, int y, int z) { @@ -36,9 +36,9 @@ public class MutableVector3 extends Vector3 { @Override public MutableVector3 setComponents(Vector3 other) { - this.x = other.getX(); - this.y = other.getY(); - this.z = other.getZ(); + this.x = other.x(); + this.y = other.y(); + this.z = other.z(); return this; } @@ -95,17 +95,17 @@ public class MutableVector3 extends Vector3 { } @Override - public double getX() { + public double x() { return x; } @Override - public double getY() { + public double y() { return y; } @Override - public double getZ() { + public double z() { return z; } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/OffsetBlockVector3.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/OffsetBlockVector3.java index 044a623de..5e0d0ebe0 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/OffsetBlockVector3.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/OffsetBlockVector3.java @@ -11,18 +11,18 @@ public class OffsetBlockVector3 extends DelegateBlockVector3 { } @Override - public int getX() { - return super.getX() + offset.getX(); + public int x() { + return super.x() + offset.x(); } @Override - public int getY() { - return super.getY() + offset.getY(); + public int y() { + return super.y() + offset.y(); } @Override - public int getZ() { - return super.getZ() + offset.getZ(); + public int z() { + return super.z() + offset.z(); } } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/Vector3Impl.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/Vector3Impl.java index c1092a881..33706aee5 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/Vector3Impl.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/Vector3Impl.java @@ -15,21 +15,21 @@ public class Vector3Impl extends Vector3 { } public Vector3Impl(Vector3 other) { - this(other.getX(), other.getY(), other.getZ()); + this(other.x(), other.y(), other.z()); } @Override - public final double getX() { + public final double x() { return x; } @Override - public final double getY() { + public final double y() { return y; } @Override - public final double getZ() { + public final double z() { return z; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector2.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector2.java index fe95ad3ad..cb5784cce 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector2.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector2.java @@ -27,7 +27,7 @@ import java.util.Comparator; /** * An immutable 2-dimensional vector. */ -//FAWE start - un-finalize +//FAWE start - not a record public class BlockVector2 { //FAWE end @@ -122,7 +122,19 @@ public class BlockVector2 { * Get the X coordinate. * * @return the x coordinate + * @since TODO */ + public int x() { + return x; + } + + /** + * Get the X coordinate. + * + * @return the x coordinate + * @deprecated use {@link #x()} instead + */ + @Deprecated(forRemoval = true, since = "TODO") public int getX() { return x; } @@ -131,7 +143,9 @@ public class BlockVector2 { * Get the X coordinate. * * @return the x coordinate + * @deprecated use {@link #x()} instead */ + @Deprecated(forRemoval = true, since = "TODO") public int getBlockX() { return x; } @@ -150,7 +164,19 @@ public class BlockVector2 { * Get the Z coordinate. * * @return the z coordinate + * @since TODO */ + public int z() { + return z; + } + + /** + * Get the Z coordinate. + * + * @return the z coordinate + * @deprecated use {@link #z()} instead + */ + @Deprecated(forRemoval = true, since = "TODO") public int getZ() { return z; } @@ -159,7 +185,9 @@ public class BlockVector2 { * Get the Z coordinate. * * @return the z coordinate + * @deprecated use {@link #z()} instead */ + @Deprecated(forRemoval = true, since = "TODO") public int getBlockZ() { return z; } @@ -598,13 +626,13 @@ public class BlockVector2 { return BlockVector3.at(x, y, z); } + //FAWE start - not a record, need own implementations @Override public boolean equals(Object obj) { - if (!(obj instanceof BlockVector2)) { + if (!(obj instanceof BlockVector2 other)) { return false; } - BlockVector2 other = (BlockVector2) obj; return other.x == this.x && other.z == this.z; } @@ -613,6 +641,7 @@ public class BlockVector2 { public int hashCode() { return (x << 16) ^ z; } + //FAWE end @Override public String toString() { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3.java index 5f1c14842..e48355d63 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3.java @@ -38,7 +38,9 @@ import static com.sk89q.worldedit.math.BitMath.unpackZ; /** * An immutable 3-dimensional vector. */ +//FAWE start - not a record public abstract class BlockVector3 { +//FAWE end public static final BlockVector3 ZERO = BlockVector3.at(0, 0, 0); public static final BlockVector3 UNIT_X = BlockVector3.at(1, 0, 0); @@ -85,9 +87,9 @@ public abstract class BlockVector3 { } public static boolean isLongPackable(BlockVector3 location) { - return isHorizontallyInBounds(location.getX()) - && isHorizontallyInBounds(location.getZ()) - && WORLD_Y_MIN <= location.getY() && location.getY() <= WORLD_Y_MAX; + return isHorizontallyInBounds(location.x()) + && isHorizontallyInBounds(location.z()) + && WORLD_Y_MIN <= location.y() && location.y() <= WORLD_Y_MAX; } public static void checkLongPackable(BlockVector3 location) { @@ -107,9 +109,9 @@ public abstract class BlockVector3 { private static final class YzxOrderComparator { private static final Comparator YZX_ORDER = - Comparator.comparingInt(BlockVector3::getY) - .thenComparingInt(BlockVector3::getZ) - .thenComparingInt(BlockVector3::getX); + Comparator.comparingInt(BlockVector3::y) + .thenComparingInt(BlockVector3::z) + .thenComparingInt(BlockVector3::x); } @@ -135,57 +137,69 @@ public abstract class BlockVector3 { public long toLongPackedForm() { checkLongPackable(this); - return (getX() & BITS_26) | ((getZ() & BITS_26) << 26) | (((getY() & BITS_12) << (26 + 26))); + return (x() & BITS_26) | ((z() & BITS_26) << 26) | (((y() & BITS_12) << (26 + 26))); } public MutableBlockVector3 mutX(double x) { - return new MutableBlockVector3((int) x, getY(), getZ()); + return new MutableBlockVector3((int) x, y(), z()); } public MutableBlockVector3 mutY(double y) { - return new MutableBlockVector3(getX(), (int) y, getZ()); + return new MutableBlockVector3(x(), (int) y, z()); } public MutableBlockVector3 mutZ(double z) { - return new MutableBlockVector3(getX(), getY(), (int) z); + return new MutableBlockVector3(x(), y(), (int) z); } public MutableBlockVector3 mutX(int x) { - return new MutableBlockVector3(x, getY(), getZ()); + return new MutableBlockVector3(x, y(), z()); } public MutableBlockVector3 mutY(int y) { - return new MutableBlockVector3(getX(), y, getZ()); + return new MutableBlockVector3(x(), y, z()); } public MutableBlockVector3 mutZ(int z) { - return new MutableBlockVector3(getX(), getY(), z); + return new MutableBlockVector3(x(), y(), z); } public BlockVector3 toImmutable() { - return BlockVector3.at(getX(), getY(), getZ()); + return BlockVector3.at(x(), y(), z()); } //FAWE end + //FAWE start - make record getters to abstract methods /** * Get the X coordinate. * * @return the x coordinate + * @since TODO */ - //FAWE start - Made abstract - public abstract int getX(); + public abstract int x(); //FAWE end /** * Get the X coordinate. * * @return the x coordinate + * @deprecated use {@link #x()} instead */ - //FAWE start - getter + @Deprecated(forRemoval = true, since = "TODO") + public int getX() { + return this.x(); //FAWE - access abstract getter instead of local field + } + + /** + * Get the X coordinate. + * + * @return the x coordinate + * @deprecated use {@link #x()} instead + */ + @Deprecated(forRemoval = true, since = "TODO") public int getBlockX() { - return getX(); + return this.x(); //FAWE - access abstract getter instead of local field } - //FAWE end /** * Set the X coordinate. @@ -195,29 +209,42 @@ public abstract class BlockVector3 { */ //FAWE start - getter public BlockVector3 withX(int x) { - return BlockVector3.at(x, getY(), getZ()); + return BlockVector3.at(x, y(), z()); } //FAWE end + + //FAWE start - make record getters to abstract methods /** * Get the Y coordinate. * * @return the y coordinate + * @since TODO */ - //FAWE start - Made abstract - public abstract int getY(); + public abstract int y(); //FAWE end /** * Get the Y coordinate. * * @return the y coordinate + * @deprecated use {@link #y()} instead */ - //FAWE start - getter + @Deprecated(forRemoval = true, since = "TODO") + public int getY() { + return this.y(); //FAWE - access abstract getter instead of local field + } + + /** + * Get the Y coordinate. + * + * @return the y coordinate + * @deprecated use {@link #y()} instead + */ + @Deprecated(forRemoval = true, since = "TODO") public int getBlockY() { - return getY(); + return this.y(); //FAWE - access abstract getter instead of local field } - //FAWE end /** * Set the Y coordinate. @@ -231,25 +258,37 @@ public abstract class BlockVector3 { } //FAWE end + //FAWE start - make record getters to abstract methods /** * Get the Z coordinate. * - * @return the z coordinate + * @return the Z coordinate + * @since TODO */ - //FAWE start - Made abstract - public abstract int getZ(); + public abstract int z(); //FAWE end /** * Get the Z coordinate. * * @return the z coordinate + * @deprecated use {@link #z()} instead */ - //FAWE start - getter - public int getBlockZ() { - return getZ(); + @Deprecated(forRemoval = true, since = "TODO") + public int getZ() { + return this.z(); //FAWE - access abstract getter instead of local field + } + + /** + * Get the Z coordinate. + * + * @return the z coordinate + * @deprecated use {@link #z()} instead + */ + @Deprecated(forRemoval = true, since = "TODO") + public int getBlockZ() { + return this.z(); //FAWE - access abstract getter instead of local field } - //FAWE end /** * Set the Z coordinate. @@ -259,7 +298,7 @@ public abstract class BlockVector3 { */ //FAWE start - getter public BlockVector3 withZ(int z) { - return BlockVector3.at(getX(), getY(), z); + return BlockVector3.at(x(), y(), z); } //FAWE end @@ -271,7 +310,7 @@ public abstract class BlockVector3 { */ //FAWE start - getter public BlockVector3 add(BlockVector3 other) { - return add(other.getX(), other.getY(), other.getZ()); + return add(other.x(), other.y(), other.z()); } //FAWE end @@ -285,7 +324,7 @@ public abstract class BlockVector3 { */ //FAWE start - getter public BlockVector3 add(int x, int y, int z) { - return BlockVector3.at(this.getX() + x, this.getY() + y, this.getZ() + z); + return BlockVector3.at(this.x() + x, this.y() + y, this.z() + z); } //FAWE end @@ -298,14 +337,14 @@ public abstract class BlockVector3 { */ //FAWE start - getter public BlockVector3 add(BlockVector3... others) { - int newX = getX(); - int newY = getY(); - int newZ = getZ(); + int newX = x(); + int newY = y(); + int newZ = z(); for (BlockVector3 other : others) { - newX += other.getX(); - newY += other.getY(); - newZ += other.getZ(); + newX += other.x(); + newY += other.y(); + newZ += other.z(); } return BlockVector3.at(newX, newY, newZ); @@ -321,7 +360,7 @@ public abstract class BlockVector3 { */ //FAWE start - getter public BlockVector3 subtract(BlockVector3 other) { - return subtract(other.getX(), other.getY(), other.getZ()); + return subtract(other.x(), other.y(), other.z()); } //FAWE end @@ -336,7 +375,7 @@ public abstract class BlockVector3 { */ //FAWE start - getter public BlockVector3 subtract(int x, int y, int z) { - return BlockVector3.at(this.getX() - x, this.getY() - y, this.getZ() - z); + return BlockVector3.at(this.x() - x, this.y() - y, this.z() - z); } //FAWE end @@ -349,14 +388,14 @@ public abstract class BlockVector3 { */ //FAWE start - getter public BlockVector3 subtract(BlockVector3... others) { - int newX = getX(); - int newY = getY(); - int newZ = getZ(); + int newX = x(); + int newY = y(); + int newZ = z(); for (BlockVector3 other : others) { - newX -= other.getX(); - newY -= other.getY(); - newZ -= other.getZ(); + newX -= other.x(); + newY -= other.y(); + newZ -= other.z(); } return BlockVector3.at(newX, newY, newZ); @@ -371,7 +410,7 @@ public abstract class BlockVector3 { */ //FAWE start - getter public BlockVector3 multiply(BlockVector3 other) { - return multiply(other.getX(), other.getY(), other.getZ()); + return multiply(other.x(), other.y(), other.z()); } //FAWE end @@ -385,7 +424,7 @@ public abstract class BlockVector3 { */ //FAWE start - getter public BlockVector3 multiply(int x, int y, int z) { - return BlockVector3.at(this.getX() * x, this.getY() * y, this.getZ() * z); + return BlockVector3.at(this.x() * x, this.y() * y, this.z() * z); } //FAWE end @@ -397,14 +436,14 @@ public abstract class BlockVector3 { */ //FAWE start - getter public BlockVector3 multiply(BlockVector3... others) { - int newX = getX(); - int newY = getY(); - int newZ = getZ(); + int newX = x(); + int newY = y(); + int newZ = z(); for (BlockVector3 other : others) { - newX *= other.getX(); - newY *= other.getY(); - newZ *= other.getZ(); + newX *= other.x(); + newY *= other.y(); + newZ *= other.z(); } return BlockVector3.at(newX, newY, newZ); @@ -429,7 +468,7 @@ public abstract class BlockVector3 { */ //FAWE start - getter public BlockVector3 divide(BlockVector3 other) { - return divide(other.getX(), other.getY(), other.getZ()); + return divide(other.x(), other.y(), other.z()); } //FAWE end @@ -443,7 +482,7 @@ public abstract class BlockVector3 { */ //FAWE start - getter public BlockVector3 divide(int x, int y, int z) { - return BlockVector3.at(this.getX() / x, this.getY() / y, this.getZ() / z); + return BlockVector3.at(this.x() / x, this.y() / y, this.z() / z); } //FAWE end @@ -467,7 +506,7 @@ public abstract class BlockVector3 { */ //FAWE start - getter public BlockVector3 shr(int x, int y, int z) { - return at(this.getX() >> x, this.getY() >> y, this.getZ() >> z); + return at(this.x() >> x, this.y() >> y, this.z() >> z); } //FAWE end @@ -491,7 +530,7 @@ public abstract class BlockVector3 { */ //FAWE start - getter public BlockVector3 shl(int x, int y, int z) { - return at(this.getX() << x, this.getY() << y, this.getZ() << z); + return at(this.x() << x, this.y() << y, this.z() << z); } //FAWE end @@ -521,7 +560,7 @@ public abstract class BlockVector3 { */ //FAWE start - getter public int lengthSq() { - return getX() * getX() + getY() * getY() + getZ() * getZ(); + return x() * x() + y() * y() + z() * z(); } //FAWE end @@ -543,9 +582,9 @@ public abstract class BlockVector3 { */ //FAWE start - getter public int distanceSq(BlockVector3 other) { - int dx = other.getX() - getX(); - int dy = other.getY() - getY(); - int dz = other.getZ() - getZ(); + int dx = other.x() - x(); + int dy = other.y() - y(); + int dz = other.z() - z(); return dx * dx + dy * dy + dz * dz; } //FAWE end @@ -559,9 +598,9 @@ public abstract class BlockVector3 { //FAWE start - getter public BlockVector3 normalize() { double len = length(); - double x = this.getX() / len; - double y = this.getY() / len; - double z = this.getZ() / len; + double x = this.x() / len; + double y = this.y() / len; + double z = this.z() / len; return BlockVector3.at(x, y, z); } //FAWE end @@ -574,7 +613,7 @@ public abstract class BlockVector3 { */ //FAWE start - getter public double dot(BlockVector3 other) { - return getX() * other.getX() + getY() * other.getY() + getZ() * other.getZ(); + return x() * other.x() + y() * other.y() + z() * other.z(); } //FAWE end @@ -587,9 +626,9 @@ public abstract class BlockVector3 { //FAWE start - getter public BlockVector3 cross(BlockVector3 other) { return new BlockVector3Imp( - getY() * other.getZ() - getZ() * other.getY(), - getZ() * other.getX() - getX() * other.getZ(), - getX() * other.getY() - getY() * other.getX() + y() * other.z() - z() * other.y(), + z() * other.x() - x() * other.z(), + x() * other.y() - y() * other.x() ); } //FAWE end @@ -603,8 +642,7 @@ public abstract class BlockVector3 { */ //FAWE start - getter public boolean containedWithin(BlockVector3 min, BlockVector3 max) { - return getX() >= min.getX() && getX() <= max.getX() && getY() >= min.getY() && getY() <= max - .getY() && getZ() >= min.getZ() && getZ() <= max.getZ(); + return x() >= min.x() && x() <= max.x() && y() >= min.y() && y() <= max.y() && z() >= min.z() && z() <= max.z(); } //FAWE end @@ -618,11 +656,11 @@ public abstract class BlockVector3 { //FAWE start - getter public BlockVector3 clampY(int min, int max) { checkArgument(min <= max, "minimum cannot be greater than maximum"); - if (getY() < min) { - return BlockVector3.at(getX(), min, getZ()); + if (y() < min) { + return BlockVector3.at(x(), min, z()); } - if (getY() > max) { - return BlockVector3.at(getX(), max, getZ()); + if (y() > max) { + return BlockVector3.at(x(), max, z()); } return this; } @@ -668,7 +706,7 @@ public abstract class BlockVector3 { */ //FAWE start - getter public BlockVector3 abs() { - return BlockVector3.at(Math.abs(getX()), Math.abs(getY()), Math.abs(getZ())); + return BlockVector3.at(Math.abs(x()), Math.abs(y()), Math.abs(z())); } //FAWE end @@ -686,8 +724,8 @@ public abstract class BlockVector3 { //FAWE start - getter public BlockVector3 transform2D(double angle, double aboutX, double aboutZ, double translateX, double translateZ) { angle = Math.toRadians(angle); - double x = this.getX() - aboutX; - double z = this.getZ() - aboutZ; + double x = this.x() - aboutX; + double z = this.z() - aboutZ; double cos = Math.cos(angle); double sin = Math.sin(angle); double x2 = x * cos - z * sin; @@ -695,7 +733,7 @@ public abstract class BlockVector3 { return BlockVector3.at( x2 + aboutX + translateX, - getY(), + y(), z2 + aboutZ + translateZ ); } @@ -707,16 +745,16 @@ public abstract class BlockVector3 { * @return pitch in radians */ public double toPitch() { - double x = getX(); - double z = getZ(); + double x = x(); + double z = z(); if (x == 0 && z == 0) { - return getY() > 0 ? -90 : 90; + return y() > 0 ? -90 : 90; } else { double x2 = x * x; double z2 = z * z; double xz = Math.sqrt(x2 + z2); - return Math.toDegrees(Math.atan(-getY() / xz)); + return Math.toDegrees(Math.atan(-y() / xz)); } } @@ -726,8 +764,8 @@ public abstract class BlockVector3 { * @return yaw in radians */ public double toYaw() { - double x = getX(); - double z = getZ(); + double x = x(); + double z = z(); double t = Math.atan2(-x, z); double tau = 2 * Math.PI; @@ -744,9 +782,9 @@ public abstract class BlockVector3 { //FAWE start - getter public BlockVector3 getMinimum(BlockVector3 v2) { return new BlockVector3Imp( - Math.min(getX(), v2.getX()), - Math.min(getY(), v2.getY()), - Math.min(getZ(), v2.getZ()) + Math.min(x(), v2.x()), + Math.min(y(), v2.y()), + Math.min(z(), v2.z()) ); } //FAWE end @@ -760,9 +798,9 @@ public abstract class BlockVector3 { //FAWE start - getter public BlockVector3 getMaximum(BlockVector3 v2) { return new BlockVector3Imp( - Math.max(getX(), v2.getX()), - Math.max(getY(), v2.getY()), - Math.max(getZ(), v2.getZ()) + Math.max(x(), v2.x()), + Math.max(y(), v2.y()), + Math.max(z(), v2.z()) ); } //FAWE end @@ -815,19 +853,19 @@ public abstract class BlockVector3 { } public CompoundTag getNbtData(Extent orDefault) { - return orDefault.getFullBlock(getX(), getY(), getZ()).getNbtData(); + return orDefault.getFullBlock(x(), y(), z()).getNbtData(); } public BlockState getOrdinalBelow(Extent orDefault) { - return orDefault.getBlock(getX(), getY() - 1, getZ()); + return orDefault.getBlock(x(), y() - 1, z()); } public BlockState getStateAbove(Extent orDefault) { - return orDefault.getBlock(getX(), getY() + 1, getZ()); + return orDefault.getBlock(x(), y() + 1, z()); } public BlockState getStateRelativeY(Extent orDefault, final int y) { - return orDefault.getBlock(getX(), getY() + y, getZ()); + return orDefault.getBlock(x(), y() + y, z()); } /** @@ -836,21 +874,21 @@ public abstract class BlockVector3 { * @return a new {@link BlockVector2} */ public BlockVector2 toBlockVector2() { - return BlockVector2.at(getX(), getZ()); + return BlockVector2.at(x(), z()); } public Vector3 toVector3() { - return Vector3.at(getX(), getY(), getZ()); + return Vector3.at(x(), y(), z()); } + //FAWE start - not a record, need own implementations @Override public boolean equals(Object obj) { - if (!(obj instanceof BlockVector3)) { + if (!(obj instanceof final BlockVector3 other)) { return false; } - BlockVector3 other = (BlockVector3) obj; - return other.getX() == this.getX() && other.getY() == this.getY() && other.getZ() == this.getZ(); + return other.x() == this.x() && other.y() == this.y() && other.z() == this.z(); } public final boolean equals(BlockVector3 other) { @@ -858,17 +896,18 @@ public abstract class BlockVector3 { return false; } - return other.getX() == this.getX() && other.getY() == this.getY() && other.getZ() == this.getZ(); + return other.x() == this.x() && other.y() == this.y() && other.z() == this.z(); } @Override public int hashCode() { - return (getX() ^ (getZ() << 12)) ^ (getY() << 24); + return (x() ^ (z() << 12)) ^ (y() << 24); } + //FAWE end @Override public String toString() { - return "(" + getX() + ", " + getY() + ", " + getZ() + ")"; + return "(" + x() + ", " + y() + ", " + z() + ")"; } /** @@ -877,7 +916,7 @@ public abstract class BlockVector3 { * @return string */ public String toParserString() { - return getX() + "," + getY() + "," + getZ(); + return x() + "," + y() + "," + z(); } //Used by VS fork diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3Imp.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3Imp.java index ab202e83b..5ec2f4fe2 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3Imp.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3Imp.java @@ -56,33 +56,33 @@ public final class BlockVector3Imp extends BlockVector3 { } @Override - public final int getX() { + public int x() { return x; } @Override - public final int getY() { + public int y() { return y; } @Override - public final int getZ() { + public int z() { return z; } @Override public int hashCode() { - return (getX() ^ (getZ() << 12)) ^ (getY() << 24); + return (x() ^ (z() << 12)) ^ (y() << 24); } @Override - public final BlockVector3 toImmutable() { + public BlockVector3 toImmutable() { return this; } @Override public String toString() { - return "(" + getX() + ", " + getY() + ", " + getZ() + ")"; + return "(" + x() + ", " + y() + ", " + z() + ")"; } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector2.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector2.java index d680b0c0d..9d08676f9 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector2.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector2.java @@ -19,12 +19,13 @@ package com.sk89q.worldedit.math; +import com.fastasyncworldedit.core.util.MathMan; import com.sk89q.worldedit.math.transform.AffineTransform; /** * An immutable 2-dimensional vector. */ -public final class Vector2 { +public record Vector2(double x, double z) { public static final Vector2 ZERO = new Vector2(0, 0); public static final Vector2 UNIT_X = new Vector2(1, 0); @@ -50,29 +51,27 @@ public final class Vector2 { return new Vector2(x, z); } - private final double x; - private final double z; - - /** - * Construct an instance. - * - * @param x the X coordinate - * @param z the Z coordinate - */ - private Vector2(double x, double z) { - this.x = x; - this.z = z; - } - /** * Get the X coordinate. * * @return the x coordinate + * @deprecated use {@link #x()} instead */ + @Deprecated(forRemoval = true, since = "TODO") public double getX() { return x; } + /** + * Get the X coordinate, aligned to the block grid. + * + * @return the block-aligned x coordinate + * @since TODO + */ + public int blockX() { + return MathMan.roundInt(x); + } + /** * Set the X coordinate. * @@ -83,11 +82,23 @@ public final class Vector2 { return Vector2.at(x, z); } + /** + * Get the Z coordinate, aligned to the block grid. + * + * @return the block-aligned z coordinate + * @since TODO + */ + public int blockZ() { + return MathMan.roundInt(z); + } + /** * Get the Z coordinate. * * @return the z coordinate + * @deprecated use {@link #z()} instead */ + @Deprecated(forRemoval = true, since = "TODO") public double getZ() { return z; } @@ -458,24 +469,6 @@ public final class Vector2 { return Vector3.at(x, y, z); } - @Override - public boolean equals(Object obj) { - if (!(obj instanceof Vector2)) { - return false; - } - - Vector2 other = (Vector2) obj; - return other.x == this.x && other.z == this.z; - - } - - @Override - public int hashCode() { - //FAWE start - XOR over x z calc - return (int) x << 16 ^ (int) z; - //FAWE end - } - @Override public String toString() { return "(" + x + ", " + z + ")"; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector3.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector3.java index 5a4d550b4..898bb5241 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector3.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector3.java @@ -32,7 +32,9 @@ import static com.google.common.base.Preconditions.checkArgument; /** * An immutable 3-dimensional vector. */ +//FAWE start - not a record, make abstract public abstract class Vector3 { +//FAWE end public static final Vector3 ZERO = Vector3.at(0, 0, 0); public static final Vector3 UNIT_X = Vector3.at(1, 0, 0); @@ -69,9 +71,9 @@ public abstract class Vector3 { private static final Comparator YZX_ORDER = (a, b) -> { return ComparisonChain.start() - .compare(a.getY(), b.getY()) - .compare(a.getZ(), b.getZ()) - .compare(a.getX(), b.getX()) + .compare(a.y(), b.y()) + .compare(a.z(), b.z()) + .compare(a.x(), b.x()) .result(); }; @@ -96,7 +98,7 @@ public abstract class Vector3 { * @return the x coordinate */ public int getBlockX() { - return MathMan.roundInt(getX()); + return MathMan.roundInt(x()); } /** @@ -105,7 +107,7 @@ public abstract class Vector3 { * @return the y coordinate */ public int getBlockY() { - return MathMan.roundInt(getY()); + return MathMan.roundInt(y()); } /** @@ -114,7 +116,7 @@ public abstract class Vector3 { * @return the z coordinate */ public int getBlockZ() { - return MathMan.roundInt(getZ()); + return MathMan.roundInt(z()); } public MutableVector3 setComponents(Vector3 other) { @@ -130,27 +132,27 @@ public abstract class Vector3 { } public MutableVector3 mutX(int x) { - return new MutableVector3(x, getY(), getZ()); + return new MutableVector3(x, y(), z()); } public MutableVector3 mutX(double x) { - return new MutableVector3(x, getY(), getZ()); + return new MutableVector3(x, y(), z()); } public MutableVector3 mutY(int y) { - return new MutableVector3(getX(), y, getZ()); + return new MutableVector3(x(), y, z()); } public MutableVector3 mutY(double y) { - return new MutableVector3(getX(), y, getZ()); + return new MutableVector3(x(), y, z()); } public MutableVector3 mutZ(int z) { - return new MutableVector3(getX(), getY(), z); + return new MutableVector3(x(), y(), z); } public MutableVector3 mutZ(double z) { - return new MutableVector3(getX(), getY(), z); + return new MutableVector3(x(), y(), z); } //FAWE end @@ -158,10 +160,29 @@ public abstract class Vector3 { * Get the X coordinate. * * @return the x coordinate + * @since TODO */ - //FAWE start - made abstract - public abstract double getX(); - //FAWE end + public abstract double x(); + + /** + * Get the X coordinate, aligned to the block grid. + * + * @return the block-aligned x coordinate + */ + public int blockX() { + return MathMan.roundInt(this.x()); + } + + /** + * Get the X coordinate. + * + * @return the x coordinate + * @deprecated use {@link #x()} instead + */ + @Deprecated(forRemoval = true, since = "TODO") + public double getX() { + return this.x(); + } /** * Set the X coordinate. @@ -171,18 +192,38 @@ public abstract class Vector3 { */ //FAWE start - getter public Vector3 withX(double x) { - return Vector3.at(x, getY(), getZ()); + return Vector3.at(x, y(), z()); } //FAWE end + /** * Get the Y coordinate. * * @return the y coordinate + * @since TODO */ - //FAWE start - made abstract - public abstract double getY(); - //FAWE end + public abstract double y(); + + /** + * Get the Y coordinate, aligned to the block grid. + * + * @return the block-aligned y coordinate + */ + public int blockY() { + return MathMan.roundInt(this.y()); + } + + /** + * Get the Y coordinate. + * + * @return the y coordinate + * @deprecated use {@link #y()} instead + */ + @Deprecated(forRemoval = true, since = "TODO") + public double getY() { + return this.y(); + } /** * Set the Y coordinate. @@ -192,7 +233,7 @@ public abstract class Vector3 { */ //FAWE start - getter public Vector3 withY(double y) { - return Vector3.at(getX(), y, getZ()); + return Vector3.at(x(), y, z()); } //FAWE end @@ -200,10 +241,29 @@ public abstract class Vector3 { * Get the Z coordinate. * * @return the z coordinate + * @since TODO */ - //FAWE start - made abstract - public abstract double getZ(); - //FAWE end + public abstract double z(); + + /** + * Get the Z coordinate, aligned to the block grid. + * + * @return the block-aligned z coordinate + */ + public int blockZ() { + return MathMan.roundInt(this.z()); + } + + /** + * Get the Z coordinate. + * + * @return the z coordinate + * @deprecated use {@link #z()} instead + */ + @Deprecated(forRemoval = true, since = "TODO") + public double getZ() { + return this.z(); + } /** * Set the Z coordinate. @@ -213,7 +273,7 @@ public abstract class Vector3 { */ //FAWE start - getter public Vector3 withZ(double z) { - return Vector3.at(getX(), getY(), z); + return Vector3.at(x(), y(), z); } //FAWE end @@ -225,7 +285,7 @@ public abstract class Vector3 { */ //FAWE start - getter public Vector3 add(Vector3 other) { - return add(other.getX(), other.getY(), other.getZ()); + return add(other.x(), other.y(), other.z()); } //FAWE end @@ -239,7 +299,7 @@ public abstract class Vector3 { */ //FAWE start - getter public Vector3 add(double x, double y, double z) { - return Vector3.at(this.getX() + x, this.getY() + y, this.getZ() + z); + return Vector3.at(this.x() + x, this.y() + y, this.z() + z); } //FAWE end @@ -252,14 +312,14 @@ public abstract class Vector3 { */ //FAWE start - getter public Vector3 add(Vector3... others) { - double newX = getX(); - double newY = getY(); - double newZ = getZ(); + double newX = x(); + double newY = y(); + double newZ = z(); for (Vector3 other : others) { - newX += other.getX(); - newY += other.getY(); - newZ += other.getZ(); + newX += other.x(); + newY += other.y(); + newZ += other.z(); } return Vector3.at(newX, newY, newZ); @@ -275,7 +335,7 @@ public abstract class Vector3 { */ //FAWE start - getter public Vector3 subtract(Vector3 other) { - return subtract(other.getX(), other.getY(), other.getZ()); + return subtract(other.x(), other.y(), other.z()); } //FAWE end @@ -290,7 +350,7 @@ public abstract class Vector3 { */ //FAWE start - getter public Vector3 subtract(double x, double y, double z) { - return Vector3.at(this.getX() - x, this.getY() - y, this.getZ() - z); + return Vector3.at(this.x() - x, this.y() - y, this.z() - z); } //FAWE end @@ -303,14 +363,14 @@ public abstract class Vector3 { */ //FAWE start - getter public Vector3 subtract(Vector3... others) { - double newX = getX(); - double newY = getY(); - double newZ = getZ(); + double newX = x(); + double newY = y(); + double newZ = z(); for (Vector3 other : others) { - newX -= other.getX(); - newY -= other.getY(); - newZ -= other.getZ(); + newX -= other.x(); + newY -= other.y(); + newZ -= other.z(); } return Vector3.at(newX, newY, newZ); @@ -325,7 +385,7 @@ public abstract class Vector3 { */ //FAWE start - getter public Vector3 multiply(Vector3 other) { - return multiply(other.getX(), other.getY(), other.getZ()); + return multiply(other.x(), other.y(), other.z()); } //FAWE end @@ -339,7 +399,7 @@ public abstract class Vector3 { */ //FAWE start - getter public Vector3 multiply(double x, double y, double z) { - return Vector3.at(this.getX() * x, this.getY() * y, this.getZ() * z); + return Vector3.at(this.x() * x, this.y() * y, this.z() * z); } //FAWE end @@ -351,14 +411,14 @@ public abstract class Vector3 { */ //FAWE start - getter public Vector3 multiply(Vector3... others) { - double newX = getX(); - double newY = getY(); - double newZ = getZ(); + double newX = x(); + double newY = y(); + double newZ = z(); for (Vector3 other : others) { - newX *= other.getX(); - newY *= other.getY(); - newZ *= other.getZ(); + newX *= other.x(); + newY *= other.y(); + newZ *= other.z(); } return Vector3.at(newX, newY, newZ); @@ -383,7 +443,7 @@ public abstract class Vector3 { */ //FAWE start - getter public Vector3 divide(Vector3 other) { - return divide(other.getX(), other.getY(), other.getZ()); + return divide(other.x(), other.y(), other.z()); } //FAWE end @@ -397,7 +457,7 @@ public abstract class Vector3 { */ //FAWE start - getter public Vector3 divide(double x, double y, double z) { - return Vector3.at(this.getX() / x, this.getY() / y, this.getZ() / z); + return Vector3.at(this.x() / x, this.y() / y, this.z() / z); } //FAWE end @@ -427,7 +487,7 @@ public abstract class Vector3 { */ //FAWE start - getter public double lengthSq() { - return getX() * getX() + getY() * getY() + getZ() * getZ(); + return x() * x() + y() * y() + z() * z(); } //FAWE end @@ -449,9 +509,9 @@ public abstract class Vector3 { */ //FAWE start - getter public double distanceSq(Vector3 other) { - double dx = other.getX() - getX(); - double dy = other.getY() - getY(); - double dz = other.getZ() - getZ(); + double dx = other.x() - x(); + double dy = other.y() - y(); + double dz = other.z() - z(); return dx * dx + dy * dy + dz * dz; } //FAWE end @@ -474,7 +534,7 @@ public abstract class Vector3 { */ //FAWE start - getter public double dot(Vector3 other) { - return getX() * other.getX() + getY() * other.getY() + getZ() * other.getZ(); + return x() * other.x() + y() * other.y() + z() * other.z(); } //FAWE end @@ -487,9 +547,9 @@ public abstract class Vector3 { //FAWE start - getter public Vector3 cross(Vector3 other) { return Vector3.at( - getY() * other.getZ() - getZ() * other.getY(), - getZ() * other.getX() - getX() * other.getZ(), - getX() * other.getY() - getY() * other.getX() + y() * other.z() - z() * other.y(), + z() * other.x() - x() * other.z(), + x() * other.y() - y() * other.x() ); } //FAWE end @@ -503,8 +563,7 @@ public abstract class Vector3 { */ //FAWE start - getter public boolean containedWithin(Vector3 min, Vector3 max) { - return getX() >= min.getX() && getX() <= max.getX() && getY() >= min.getY() && getY() <= max.getY() && getZ() >= min.getZ() && getZ() <= max - .getZ(); + return x() >= min.x() && x() <= max.x() && y() >= min.y() && y() <= max.y() && z() >= min.z() && z() <= max.z(); } //FAWE end @@ -518,11 +577,11 @@ public abstract class Vector3 { //FAWE start - getter public Vector3 clampY(int min, int max) { checkArgument(min <= max, "minimum cannot be greater than maximum"); - if (getY() < min) { - return Vector3.at(getX(), min, getZ()); + if (y() < min) { + return Vector3.at(x(), min, z()); } - if (getY() > max) { - return Vector3.at(getX(), max, getZ()); + if (y() > max) { + return Vector3.at(x(), max, z()); } return this; } @@ -535,7 +594,7 @@ public abstract class Vector3 { */ //FAWE start - getter public Vector3 floor() { - return Vector3.at(Math.floor(getX()), Math.floor(getY()), Math.floor(getZ())); + return Vector3.at(Math.floor(x()), Math.floor(y()), Math.floor(z())); } //FAWE end @@ -546,7 +605,7 @@ public abstract class Vector3 { */ //FAWE start - getter public Vector3 ceil() { - return Vector3.at(Math.ceil(getX()), Math.ceil(getY()), Math.ceil(getZ())); + return Vector3.at(Math.ceil(x()), Math.ceil(y()), Math.ceil(z())); } //FAWE end @@ -559,7 +618,7 @@ public abstract class Vector3 { */ //FAWE start - getter public Vector3 round() { - return Vector3.at(Math.floor(getX() + 0.5), Math.floor(getY() + 0.5), Math.floor(getZ() + 0.5)); + return Vector3.at(Math.floor(x() + 0.5), Math.floor(y() + 0.5), Math.floor(z() + 0.5)); } //FAWE end @@ -570,7 +629,7 @@ public abstract class Vector3 { */ //FAWE start - getter public Vector3 roundHalfUp() { - return Vector3.at(MathUtils.roundHalfUp(getX()), MathUtils.roundHalfUp(getY()), MathUtils.roundHalfUp(getZ())); + return Vector3.at(MathUtils.roundHalfUp(x()), MathUtils.roundHalfUp(y()), MathUtils.roundHalfUp(z())); } //FAWE end @@ -582,7 +641,7 @@ public abstract class Vector3 { */ //FAWE start - getter public Vector3 abs() { - return Vector3.at(Math.abs(getX()), Math.abs(getY()), Math.abs(getZ())); + return Vector3.at(Math.abs(x()), Math.abs(y()), Math.abs(z())); } //FAWE end @@ -600,8 +659,8 @@ public abstract class Vector3 { //FAWE start - getter public Vector3 transform2D(double angle, double aboutX, double aboutZ, double translateX, double translateZ) { angle = Math.toRadians(angle); - double x = this.getX() - aboutX; - double z = this.getZ() - aboutZ; + double x = this.x() - aboutX; + double z = this.z() - aboutZ; double cos = Math.cos(angle); double sin = Math.sin(angle); double x2 = x * cos - z * sin; @@ -609,7 +668,7 @@ public abstract class Vector3 { return Vector3.at( x2 + aboutX + translateX, - getY(), + y(), z2 + aboutZ + translateZ ); } @@ -621,16 +680,16 @@ public abstract class Vector3 { * @return pitch in radians */ public double toPitch() { - double x = getX(); - double z = getZ(); + double x = x(); + double z = z(); if (x == 0 && z == 0) { - return getY() > 0 ? -90 : 90; + return y() > 0 ? -90 : 90; } else { double x2 = x * x; double z2 = z * z; double xz = Math.sqrt(x2 + z2); - return Math.toDegrees(Math.atan(-getY() / xz)); + return Math.toDegrees(Math.atan(-y() / xz)); } } @@ -640,8 +699,8 @@ public abstract class Vector3 { * @return yaw in radians */ public double toYaw() { - double x = getX(); - double z = getZ(); + double x = x(); + double z = z(); double t = Math.atan2(-x, z); double tau = 2 * Math.PI; @@ -658,9 +717,9 @@ public abstract class Vector3 { //FAWE start - getter public Vector3 getMinimum(Vector3 v2) { return Vector3.at( - Math.min(getX(), v2.getX()), - Math.min(getY(), v2.getY()), - Math.min(getZ(), v2.getZ()) + Math.min(x(), v2.x()), + Math.min(y(), v2.y()), + Math.min(z(), v2.z()) ); } //FAWE end @@ -674,9 +733,9 @@ public abstract class Vector3 { //FAWE start - getter public Vector3 getMaximum(Vector3 v2) { return Vector3.at( - Math.max(getX(), v2.getX()), - Math.max(getY(), v2.getY()), - Math.max(getZ(), v2.getZ()) + Math.max(x(), v2.x()), + Math.max(y(), v2.y()), + Math.max(z(), v2.z()) ); } //FAWE end @@ -700,7 +759,7 @@ public abstract class Vector3 { */ //FAWE start - getter public BlockVector3 toBlockPoint() { - return toBlockPoint(getX(), getY(), getZ()); + return toBlockPoint(x(), y(), z()); } //FAWE end @@ -711,24 +770,20 @@ public abstract class Vector3 { */ //FAWE start - getter public Vector2 toVector2() { - return Vector2.at(getX(), getZ()); + return Vector2.at(x(), z()); } //FAWE end + //FAWE start - not a record, need own implementations @Override public boolean equals(Object obj) { - if (!(obj instanceof Vector3)) { + if (!(obj instanceof final Vector3 other)) { return false; } - Vector3 other = (Vector3) obj; - //FAWE start - getter - return other.getX() == this.getX() && other.getY() == this.getY() && other.getZ() == this.getZ(); - //FAWE end + return other.x() == this.x() && other.y() == this.y() && other.z() == this.z(); } - //FAWE start - /** * Tests if vectors are equal, accounting for floating point errors * @@ -741,28 +796,27 @@ public abstract class Vector3 { } // Minecraft deals in whole blocks, thus any difference smaller than this is unnecessary - if (Math.abs(getX() - other.getX()) > 0.000001d) { + if (Math.abs(x() - other.x()) > 0.000001d) { return false; } - if (Math.abs(getY() - other.getY()) > 0.000001d) { + if (Math.abs(y() - other.y()) > 0.000001d) { return false; } - return !(Math.abs(getZ() - other.getZ()) > 0.000001d); + return !(Math.abs(z() - other.z()) > 0.000001d); + } + + @Override + public int hashCode() { + return (int) x() ^ (int) z() << 12 ^ (int) y() << 24; } //FAWE end - @Override - //FAWE start - XOR over get calculating all values independently - public int hashCode() { - return (int) getX() ^ (int) getZ() << 12 ^ (int) getY() << 24; - } - @Override public String toString() { //FAWE start - getter & ternary - String x = (getX() == getBlockX() ? "" + getBlockX() : "" + getX()); - String y = (getY() == getBlockY() ? "" + getBlockY() : "" + getY()); - String z = (getZ() == getBlockZ() ? "" + getBlockZ() : "" + getZ()); + String x = (x() == blockX() ? "" + blockX() : "" + x()); + String y = (y() == blockY() ? "" + blockY() : "" + y()); + String z = (z() == blockZ() ? "" + blockZ() : "" + z()); //FAWE end return "(" + x + ", " + y + ", " + z + ")"; } @@ -774,7 +828,7 @@ public abstract class Vector3 { */ //FAWE start - getter public String toParserString() { - return getX() + "," + getY() + "," + getZ(); + return x() + "," + y() + "," + z(); } //FAWE end diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/Location.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/Location.java index 3a3cd6fb8..52c1a3e62 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/Location.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/Location.java @@ -302,11 +302,11 @@ public class Location extends Vector3Impl { @Override public Location clampY(int min, int max) { checkArgument(min <= max, "minimum cannot be greater than maximum"); - if (getY() < min) { - return new Location(extent, getX(), min, getZ()); + if (y() < min) { + return new Location(extent, x(), min, z()); } - if (getY() > max) { - return new Location(extent, getX(), max, getZ()); + if (y() > max) { + return new Location(extent, x(), max, z()); } return this; @@ -331,13 +331,13 @@ public class Location extends Vector3Impl { return false; } //FAWE start - if (this.getX() != location.getX()) { + if (this.x() != location.x()) { return false; } - if (this.getZ() != location.getZ()) { + if (this.z() != location.z()) { return false; } - if (this.getY() != location.getY()) { + if (this.y() != location.y()) { return false; } return extent.equals(location.extent); From 5225dddaa6dd58d3b854a1a83964640f431cc3d0 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 27 May 2024 00:23:10 +0000 Subject: [PATCH 74/90] Update dependency paperweight-userdev to v1.20.6-R0.1-20240526.222003-87 --- worldedit-bukkit/adapters/adapter-1_20_5/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldedit-bukkit/adapters/adapter-1_20_5/build.gradle.kts b/worldedit-bukkit/adapters/adapter-1_20_5/build.gradle.kts index 80c044f91..8f97a8454 100644 --- a/worldedit-bukkit/adapters/adapter-1_20_5/build.gradle.kts +++ b/worldedit-bukkit/adapters/adapter-1_20_5/build.gradle.kts @@ -12,6 +12,6 @@ repositories { dependencies { // url=https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/1.20.6-R0.1-SNAPSHOT/ - the().paperDevBundle("1.20.6-R0.1-20240523.202134-70") + the().paperDevBundle("1.20.6-R0.1-20240526.222003-87") compileOnly(libs.paperlib) } From df92febf7b911d49f4c2ce53a16c6c200a36d001 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 27 May 2024 00:23:05 +0000 Subject: [PATCH 75/90] Update dependency com.palmergames.bukkit.towny:towny to v0.100.2.11 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 639b7b010..6d7a9bd85 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -14,7 +14,7 @@ mapmanager = "1.8.0-SNAPSHOT" griefprevention = "17.0.0" griefdefender = "2.1.0-SNAPSHOT" residence = "4.5._13.1" -towny = "0.100.2.9" +towny = "0.100.2.11" plotsquared = "7.3.8" # Third party From e9866fb4d7ed7fb8103df1b6e18d3f387f74411f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 27 May 2024 03:21:30 +0000 Subject: [PATCH 76/90] Update dependency commons-cli:commons-cli to v1.8.0 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 6d7a9bd85..38f8f3f32 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -35,7 +35,7 @@ jlibnoise = "1.0.0" jchronic = "0.2.4a" lz4-java = "1.8.0" lz4-stream = "1.0.0" -commons-cli = "1.7.0" +commons-cli = "1.8.0" paperlib = "1.0.8" paster = "1.1.6" vault = "1.7.1" From 73186856131c51244a0e1c00d89e6fe2d1ccc6c4 Mon Sep 17 00:00:00 2001 From: Pierre Maurice Schwang Date: Mon, 27 May 2024 21:32:09 +0200 Subject: [PATCH 77/90] fix: ClassCastException on spigot (#2751) fix: ClassCastException on spigot due to method change --- .../impl/fawe/v1_20_R4/PaperweightPlatformAdapter.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4/PaperweightPlatformAdapter.java b/worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4/PaperweightPlatformAdapter.java index 128897111..4f934129e 100644 --- a/worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4/PaperweightPlatformAdapter.java +++ b/worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4/PaperweightPlatformAdapter.java @@ -345,10 +345,8 @@ public final class PaperweightPlatformAdapter extends NMSAdapter { .getChunkSource() .getChunkAtIfLoadedImmediately(chunkX, chunkZ); } else { - levelChunk = ((Optional) ((Either) chunkHolder - .getTickingChunkFuture() // method is not present with new paper chunk system - .getNow(ChunkHolder.UNLOADED_LEVEL_CHUNK)).left()) - .orElse(null); + levelChunk = chunkHolder.getTickingChunkFuture() + .getNow(ChunkHolder.UNLOADED_LEVEL_CHUNK).orElse(null); } if (levelChunk == null) { return; From 36d2c85fdb850fa6b20ba0d12d2cee4a757e05cb Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Mon, 27 May 2024 18:48:46 +0100 Subject: [PATCH 78/90] chore: address deprecations in vector classes --- .../ext/fawe/v1_19_R3/PaperweightAdapter.java | 17 +- .../fawe/v1_19_R3/PaperweightFaweAdapter.java | 2 +- .../fawe/v1_19_R3/PaperweightGetBlocks.java | 6 +- .../ext/fawe/v1_20_R1/PaperweightAdapter.java | 16 +- .../fawe/v1_20_R1/PaperweightFaweAdapter.java | 2 +- .../fawe/v1_20_R1/PaperweightGetBlocks.java | 6 +- .../ext/fawe/v1_20_R2/PaperweightAdapter.java | 16 +- .../fawe/v1_20_R2/PaperweightFaweAdapter.java | 2 +- .../fawe/v1_20_R2/PaperweightGetBlocks.java | 6 +- .../ext.fawe/v1_20_R3/PaperweightAdapter.java | 16 +- .../fawe/v1_20_R3/PaperweightFaweAdapter.java | 2 +- .../fawe/v1_20_R3/PaperweightGetBlocks.java | 6 +- .../ext.fawe/v1_20_R4/PaperweightAdapter.java | 16 +- .../fawe/v1_20_R4/PaperweightFaweAdapter.java | 2 +- .../fawe/v1_20_R4/PaperweightGetBlocks.java | 6 +- .../bukkit/adapter/IBukkitAdapter.java | 4 +- .../bukkit/adapter/Regenerator.java | 24 +- .../bukkit/regions/WorldGuardFeature.java | 2 +- .../FaweDelegateSchematicHandler.java | 18 +- .../plotsquared/PlotSquaredFeature.java | 4 +- .../sk89q/worldedit/bukkit/BukkitAdapter.java | 8 +- .../sk89q/worldedit/bukkit/BukkitPlayer.java | 8 +- .../sk89q/worldedit/bukkit/BukkitWorld.java | 30 +-- .../com/fastasyncworldedit/core/FaweAPI.java | 8 +- .../core/command/tool/brush/BlendBall.java | 6 +- .../command/tool/brush/CatenaryBrush.java | 6 +- .../core/command/tool/brush/CommandBrush.java | 6 +- .../command/tool/brush/CopyPastaBrush.java | 4 +- .../core/command/tool/brush/ErodeBrush.java | 20 +- .../command/tool/brush/FallingSphere.java | 6 +- .../core/command/tool/brush/InspectBrush.java | 8 +- .../core/command/tool/brush/RecurseBrush.java | 4 +- .../core/command/tool/brush/RockBrush.java | 12 +- .../core/command/tool/brush/ScatterBrush.java | 8 +- .../command/tool/brush/ScatterCommand.java | 6 +- .../tool/brush/ScatterOverlayBrush.java | 8 +- .../core/command/tool/brush/ShatterBrush.java | 12 +- .../core/command/tool/brush/SplineBrush.java | 6 +- .../command/tool/brush/SurfaceSpline.java | 20 +- .../command/tool/sweep/ClipboardSpline.java | 10 +- .../core/command/tool/sweep/Spline.java | 4 +- .../core/command/tool/sweep/SweepBrush.java | 4 +- .../core/database/RollbackDatabase.java | 36 +-- .../core/extent/BlockTranslateExtent.java | 4 +- .../core/extent/FaweRegionExtent.java | 10 +- .../core/extent/HistoryExtent.java | 4 +- .../core/extent/LimitExtent.java | 4 +- .../core/extent/PositionTransformExtent.java | 28 +-- .../core/extent/ProcessedWEExtent.java | 4 +- .../core/extent/SourceMaskExtent.java | 4 +- .../core/extent/TemporalExtent.java | 6 +- .../core/extent/TransformExtent.java | 30 +-- .../clipboard/CPUOptimizedClipboard.java | 4 +- .../clipboard/DiskOptimizedClipboard.java | 22 +- .../clipboard/MemoryOptimizedClipboard.java | 4 +- .../extent/clipboard/SimpleClipboard.java | 6 +- .../extent/clipboard/WorldCopyClipboard.java | 2 +- .../clipboard/io/FastSchematicReader.java | 4 +- .../clipboard/io/FastSchematicWriter.java | 24 +- .../io/schematic/MinecraftStructure.java | 6 +- .../clipboard/io/schematic/PNGWriter.java | 6 +- .../core/extent/filter/ArrayImageMask.java | 2 +- .../block/AbstractSingleFilterBlock.java | 6 +- .../EntityInBlockRemovingProcessor.java | 6 +- .../processor/lighting/NMSRelighter.java | 58 ++--- .../extent/transform/OffsetTransform.java | 12 +- .../transform/RandomOffsetTransform.java | 12 +- .../core/extent/transform/ScaleTransform.java | 64 ++--- .../extent/transform/SelectTransform.java | 4 +- .../core/function/SurfaceRegionFunction.java | 4 +- .../core/function/block/BiomeCopy.java | 10 +- .../core/function/generator/CavesGen.java | 4 +- .../core/function/generator/GenBase.java | 4 +- .../core/function/generator/SchemGen.java | 2 +- .../core/function/mask/AdjacentAnyMask.java | 6 +- .../core/function/mask/AdjacentMask.java | 6 +- .../core/function/mask/AngleMask.java | 18 +- .../core/function/mask/CachedMask.java | 12 +- .../core/function/mask/ImageBrushMask.java | 14 +- .../core/function/mask/LayerBrushMask.java | 18 +- .../core/function/mask/PlaneMask.java | 18 +- .../core/function/mask/RadiusMask.java | 6 +- .../core/function/mask/SimplexMask.java | 2 +- .../core/function/mask/StencilBrushMask.java | 12 +- .../core/function/mask/SurfaceAngleMask.java | 14 +- .../core/function/mask/WallMakeMask.java | 4 +- .../core/function/mask/WallMask.java | 6 +- .../core/function/mask/XAxisMask.java | 4 +- .../core/function/mask/YAxisMask.java | 4 +- .../core/function/mask/ZAxisMask.java | 4 +- .../function/pattern/AngleColorPattern.java | 6 +- .../core/function/pattern/AnglePattern.java | 6 +- .../function/pattern/BufferedPattern2D.java | 2 +- .../function/pattern/ExpressionPattern.java | 2 +- .../pattern/Linear2DBlockPattern.java | 6 +- .../pattern/Linear3DBlockPattern.java | 8 +- .../core/function/pattern/NoXPattern.java | 8 +- .../core/function/pattern/NoYPattern.java | 8 +- .../core/function/pattern/NoZPattern.java | 9 +- .../core/function/pattern/OffsetPattern.java | 16 +- .../function/pattern/RandomOffsetPattern.java | 16 +- .../function/pattern/RelativePattern.java | 16 +- .../pattern/SolidRandomOffsetPattern.java | 18 +- .../pattern/SurfaceRandomOffsetPattern.java | 14 +- .../core/function/visitor/AboveVisitor.java | 2 +- .../core/function/visitor/DFSVisitor.java | 6 +- .../function/visitor/DirectionalVisitor.java | 12 +- .../history/RollbackOptimizedHistory.java | 12 +- .../history/changeset/AbstractChangeSet.java | 16 +- .../history/changeset/BlockBagChangeSet.java | 6 +- .../core/math/BlockVector3ChunkMap.java | 2 +- .../core/math/BlockVectorSet.java | 18 +- .../core/math/LocalBlockVectorSet.java | 12 +- .../core/math/heightmap/HeightMap.java | 13 +- .../math/heightmap/RotatableHeightMap.java | 2 +- .../math/heightmap/ScalableHeightMap.java | 16 +- .../math/random/SimplexNoiseGenerator.java | 4 +- .../core/queue/IChunkExtent.java | 14 +- .../core/queue/IChunkGet.java | 2 +- .../core/queue/IChunkSet.java | 2 +- .../core/queue/IQueueExtent.java | 2 +- .../implementation/ParallelQueueExtent.java | 6 +- .../SingleThreadQueueExtent.java | 2 +- .../implementation/blocks/CharSetBlocks.java | 4 +- .../blocks/ThreadUnsafeCharBlocks.java | 2 +- .../preloader/AsyncPreloader.java | 6 +- .../core/regions/FuzzyRegion.java | 4 +- .../core/regions/PolyhedralRegion.java | 18 +- .../core/regions/RegionWrapper.java | 24 +- .../core/regions/Triangle.java | 12 +- .../regions/filter/CuboidRegionFilter.java | 16 +- .../core/util/MainUtil.java | 6 +- .../core/util/WEManager.java | 4 +- .../core/util/collection/BlockSet.java | 6 +- .../core/util/collection/BlockVector3Set.java | 8 +- .../core/util/collection/MemBlockSet.java | 11 +- .../core/world/SimpleWorld.java | 4 +- .../core/wrappers/AsyncPlayer.java | 2 +- .../java/com/sk89q/util/yaml/YAMLNode.java | 20 +- .../java/com/sk89q/worldedit/EditSession.java | 220 +++++++++--------- .../worldedit/command/BrushCommands.java | 8 +- .../worldedit/command/ClipboardCommands.java | 12 +- .../command/FlattenedClipboardTransform.java | 12 +- .../worldedit/command/GenerationCommands.java | 22 +- .../worldedit/command/HistorySubCommands.java | 18 +- .../worldedit/command/RegionCommands.java | 14 +- .../worldedit/command/SelectionCommands.java | 24 +- .../worldedit/command/UtilityCommands.java | 13 +- .../command/argument/OffsetConverter.java | 6 +- .../worldedit/command/tool/BrushTool.java | 2 +- .../command/tool/brush/GravityBrush.java | 8 +- .../command/util/annotation/Confirm.java | 3 +- .../platform/AbstractPlayerActor.java | 8 +- .../com/sk89q/worldedit/extent/Extent.java | 20 +- .../sk89q/worldedit/extent/InputExtent.java | 14 +- .../sk89q/worldedit/extent/OutputExtent.java | 6 +- .../extent/clipboard/BlockArrayClipboard.java | 102 ++++---- .../worldedit/extent/clipboard/Clipboard.java | 28 +-- .../extent/clipboard/io/ClipboardWriter.java | 6 +- .../clipboard/io/SpongeSchematicReader.java | 8 +- .../clipboard/io/SpongeSchematicWriter.java | 24 +- .../extent/inventory/BlockBagExtent.java | 2 +- .../transform/BlockTransformExtent.java | 6 +- .../validation/DataValidatorExtent.java | 4 +- .../extent/world/SideEffectExtent.java | 2 +- .../function/biome/BiomeReplace.java | 2 +- .../function/biome/ExtentBiomeCopy.java | 2 +- .../function/block/SnowSimulator.java | 2 +- .../function/entity/ExtentEntityCopy.java | 12 +- .../function/factory/ApplyLayer.java | 4 +- .../worldedit/function/factory/Deform.java | 6 +- .../function/mask/BoundedHeightMask.java | 2 +- .../function/mask/ExpressionMask.java | 4 +- .../function/mask/ExpressionMask2D.java | 4 +- .../worldedit/function/mask/NoiseFilter.java | 2 +- .../worldedit/function/mask/OffsetMask.java | 2 +- .../worldedit/function/mask/OffsetMask2D.java | 4 +- .../operation/BackwardsExtentBlockCopy.java | 18 +- .../function/operation/ForwardExtentCopy.java | 28 +-- .../function/pattern/RandomPattern.java | 4 +- .../pattern/RepeatingExtentPattern.java | 6 +- .../function/visitor/BreadthFirstSearch.java | 14 +- .../function/visitor/DownwardVisitor.java | 4 +- .../function/visitor/RegionVisitor.java | 8 +- .../history/changeset/ArrayListHistory.java | 2 +- .../internal/anvil/ChunkDeleter.java | 22 +- .../internal/anvil/ChunkDeletionInfo.java | 2 +- .../internal/anvil/RegionAccess.java | 4 +- .../internal/cui/SelectionCylinderEvent.java | 10 +- .../cui/SelectionEllipsoidPointEvent.java | 6 +- .../internal/cui/SelectionPoint2DEvent.java | 16 +- .../internal/cui/SelectionPointEvent.java | 6 +- .../internal/cui/ServerCUIHandler.java | 16 +- .../util/RegionOptimizedVectorSorter.java | 6 +- .../internal/wna/WorldNativeAccess.java | 16 +- .../sk89q/worldedit/math/BlockVector2.java | 2 +- .../sk89q/worldedit/math/BlockVector3.java | 2 +- .../worldedit/math/convolution/HeightMap.java | 30 +-- .../math/convolution/SnowHeightMap.java | 16 +- .../KochanekBartelsInterpolation.java | 8 +- .../math/noise/JLibNoiseGenerator.java | 4 +- .../math/transform/AffineTransform.java | 24 +- .../worldedit/regions/AbstractFlatRegion.java | 4 +- .../worldedit/regions/AbstractRegion.java | 36 ++- .../sk89q/worldedit/regions/CuboidRegion.java | 210 ++++++++--------- .../worldedit/regions/CylinderRegion.java | 26 +-- .../worldedit/regions/EllipsoidRegion.java | 58 ++--- .../worldedit/regions/Polygonal2DRegion.java | 62 ++--- .../com/sk89q/worldedit/regions/Region.java | 18 +- .../worldedit/regions/RegionIntersection.java | 4 +- .../com/sk89q/worldedit/regions/Regions.java | 8 +- .../worldedit/regions/TransformRegion.java | 6 +- .../factory/CylinderRegionFactory.java | 4 +- .../iterator/FlatRegion3DIterator.java | 2 +- .../regions/iterator/FlatRegionIterator.java | 10 +- .../regions/iterator/RegionIterator.java | 16 +- .../ConvexPolyhedralRegionSelector.java | 4 +- .../selector/CylinderRegionSelector.java | 12 +- .../ExtendingCuboidRegionSelector.java | 12 +- .../selector/Polygonal2DRegionSelector.java | 14 +- .../selector/SphereRegionSelector.java | 6 +- .../regions/shape/ArbitraryBiomeShape.java | 18 +- .../regions/shape/ArbitraryShape.java | 18 +- .../com/sk89q/worldedit/util/Direction.java | 14 +- .../com/sk89q/worldedit/util/TargetBlock.java | 12 +- .../sk89q/worldedit/util/TreeGenerator.java | 10 +- .../worldedit/util/collection/BlockMap.java | 12 +- .../util/collection/VectorPositionList.java | 6 +- .../com/sk89q/worldedit/world/NullWorld.java | 2 +- .../worldedit/world/chunk/AnvilChunk.java | 12 +- .../worldedit/world/chunk/AnvilChunk13.java | 10 +- .../worldedit/world/chunk/AnvilChunk15.java | 6 +- .../worldedit/world/chunk/AnvilChunk17.java | 12 +- .../worldedit/world/chunk/AnvilChunk18.java | 14 +- .../sk89q/worldedit/world/chunk/OldChunk.java | 8 +- .../world/snapshot/SnapshotRestore.java | 8 +- .../experimental/SnapshotRestore.java | 8 +- .../worldedit/world/storage/ChunkStore.java | 2 +- .../world/storage/LegacyChunkStore.java | 8 +- .../world/storage/McRegionChunkStore.java | 4 +- .../world/storage/McRegionReader.java | 4 +- .../expression/RealExpressionTest.java | 2 +- .../util/RegionOptimizedVectorSorterTest.java | 10 +- .../sk89q/worldedit/util/LocationTest.java | 32 +-- 244 files changed, 1493 insertions(+), 1515 deletions(-) diff --git a/worldedit-bukkit/adapters/adapter-1_19_4/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_19_R3/PaperweightAdapter.java b/worldedit-bukkit/adapters/adapter-1_19_4/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_19_R3/PaperweightAdapter.java index 22c5a07b2..6d1038677 100644 --- a/worldedit-bukkit/adapters/adapter-1_19_4/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_19_R3/PaperweightAdapter.java +++ b/worldedit-bukkit/adapters/adapter-1_19_4/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_19_R3/PaperweightAdapter.java @@ -27,7 +27,6 @@ import com.google.common.collect.Sets; import com.google.common.util.concurrent.Futures; import com.mojang.datafixers.util.Either; import com.mojang.serialization.Lifecycle; -import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.NBTConstants; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.blocks.BaseItem; @@ -531,7 +530,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter (net.minecraft.nbt.CompoundTag) fromNativeBinary(nbtData) @@ -581,10 +580,10 @@ public final class PaperweightAdapter implements BukkitImplAdapter>) - getChunkFutureMethod.invoke(chunkManager, chunk.getX(), chunk.getZ(), ChunkStatus.FEATURES, true)) + getChunkFutureMethod.invoke(chunkManager, chunk.x(), chunk.z(), ChunkStatus.FEATURES, true)) .thenApply(either -> either.left().orElse(null)) ); } catch (IllegalAccessException | InvocationTargetException e) { @@ -797,7 +796,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter entry : tiles.entrySet()) { final CompoundTag nativeTag = entry.getValue(); final BlockVector3 blockHash = entry.getKey(); - final int x = blockHash.getX() + bx; - final int y = blockHash.getY(); - final int z = blockHash.getZ() + bz; + final int x = blockHash.x() + bx; + final int y = blockHash.y(); + final int z = blockHash.z() + bz; final BlockPos pos = new BlockPos(x, y, z); synchronized (nmsWorld) { diff --git a/worldedit-bukkit/adapters/adapter-1_20/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_20_R1/PaperweightAdapter.java b/worldedit-bukkit/adapters/adapter-1_20/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_20_R1/PaperweightAdapter.java index b40c12b1a..6d7e28504 100644 --- a/worldedit-bukkit/adapters/adapter-1_20/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_20_R1/PaperweightAdapter.java +++ b/worldedit-bukkit/adapters/adapter-1_20/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_20_R1/PaperweightAdapter.java @@ -570,7 +570,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter (net.minecraft.nbt.CompoundTag) fromNativeBinary(nbtData) @@ -631,10 +631,10 @@ public final class PaperweightAdapter implements BukkitImplAdapter>) - getChunkFutureMethod.invoke(chunkManager, chunk.getX(), chunk.getZ(), ChunkStatus.FEATURES, true)) + getChunkFutureMethod.invoke(chunkManager, chunk.x(), chunk.z(), ChunkStatus.FEATURES, true)) .thenApply(either -> either.left().orElse(null)) ); } catch (IllegalAccessException | InvocationTargetException e) { @@ -848,7 +848,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter entry : tiles.entrySet()) { final CompoundTag nativeTag = entry.getValue(); final BlockVector3 blockHash = entry.getKey(); - final int x = blockHash.getX() + bx; - final int y = blockHash.getY(); - final int z = blockHash.getZ() + bz; + final int x = blockHash.x() + bx; + final int y = blockHash.y(); + final int z = blockHash.z() + bz; final BlockPos pos = new BlockPos(x, y, z); synchronized (nmsWorld) { diff --git a/worldedit-bukkit/adapters/adapter-1_20_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_20_R2/PaperweightAdapter.java b/worldedit-bukkit/adapters/adapter-1_20_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_20_R2/PaperweightAdapter.java index b73e6d06e..d8dafb8e5 100644 --- a/worldedit-bukkit/adapters/adapter-1_20_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_20_R2/PaperweightAdapter.java +++ b/worldedit-bukkit/adapters/adapter-1_20_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_20_R2/PaperweightAdapter.java @@ -530,7 +530,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter (net.minecraft.nbt.CompoundTag) fromNativeBinary(nbtData) @@ -580,10 +580,10 @@ public final class PaperweightAdapter implements BukkitImplAdapter>) - getChunkFutureMethod.invoke(chunkManager, chunk.getX(), chunk.getZ(), ChunkStatus.FEATURES, true)) + getChunkFutureMethod.invoke(chunkManager, chunk.x(), chunk.z(), ChunkStatus.FEATURES, true)) .thenApply(either -> either.left().orElse(null)) ); } catch (IllegalAccessException | InvocationTargetException e) { @@ -797,7 +797,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter entry : tiles.entrySet()) { final CompoundTag nativeTag = entry.getValue(); final BlockVector3 blockHash = entry.getKey(); - final int x = blockHash.getX() + bx; - final int y = blockHash.getY(); - final int z = blockHash.getZ() + bz; + final int x = blockHash.x() + bx; + final int y = blockHash.y(); + final int z = blockHash.z() + bz; final BlockPos pos = new BlockPos(x, y, z); synchronized (nmsWorld) { diff --git a/worldedit-bukkit/adapters/adapter-1_20_4/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext.fawe/v1_20_R3/PaperweightAdapter.java b/worldedit-bukkit/adapters/adapter-1_20_4/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext.fawe/v1_20_R3/PaperweightAdapter.java index 899c6e0c4..51b97b081 100644 --- a/worldedit-bukkit/adapters/adapter-1_20_4/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext.fawe/v1_20_R3/PaperweightAdapter.java +++ b/worldedit-bukkit/adapters/adapter-1_20_4/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext.fawe/v1_20_R3/PaperweightAdapter.java @@ -530,7 +530,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter (net.minecraft.nbt.CompoundTag) fromNativeBinary(nbtData) @@ -580,10 +580,10 @@ public final class PaperweightAdapter implements BukkitImplAdapter>) - getChunkFutureMethod.invoke(chunkManager, chunk.getX(), chunk.getZ(), ChunkStatus.FEATURES, true)) + getChunkFutureMethod.invoke(chunkManager, chunk.x(), chunk.z(), ChunkStatus.FEATURES, true)) .thenApply(either -> either.left().orElse(null)) ); } catch (IllegalAccessException | InvocationTargetException e) { @@ -797,7 +797,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter entry : tiles.entrySet()) { final CompoundTag nativeTag = entry.getValue(); final BlockVector3 blockHash = entry.getKey(); - final int x = blockHash.getX() + bx; - final int y = blockHash.getY(); - final int z = blockHash.getZ() + bz; + final int x = blockHash.x() + bx; + final int y = blockHash.y(); + final int z = blockHash.z() + bz; final BlockPos pos = new BlockPos(x, y, z); synchronized (nmsWorld) { diff --git a/worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext.fawe/v1_20_R4/PaperweightAdapter.java b/worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext.fawe/v1_20_R4/PaperweightAdapter.java index e629c4611..8218ec892 100644 --- a/worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext.fawe/v1_20_R4/PaperweightAdapter.java +++ b/worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext.fawe/v1_20_R4/PaperweightAdapter.java @@ -577,7 +577,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter>) - getChunkFutureMethod.invoke(chunkManager, chunk.getX(), chunk.getZ(), ChunkStatus.FEATURES, true)) + getChunkFutureMethod.invoke(chunkManager, chunk.x(), chunk.z(), ChunkStatus.FEATURES, true)) .thenApply(either -> either.orElse(null)) ); } catch (IllegalAccessException | InvocationTargetException e) { @@ -874,7 +874,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter entry : tiles.entrySet()) { final CompoundTag nativeTag = entry.getValue(); final BlockVector3 blockHash = entry.getKey(); - final int x = blockHash.getX() + bx; - final int y = blockHash.getY(); - final int z = blockHash.getZ() + bz; + final int x = blockHash.x() + bx; + final int y = blockHash.y(); + final int z = blockHash.z() + bz; final BlockPos pos = new BlockPos(x, y, z); synchronized (nmsWorld) { diff --git a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/IBukkitAdapter.java b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/IBukkitAdapter.java index 9792f9344..6ea8cad89 100644 --- a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/IBukkitAdapter.java +++ b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/IBukkitAdapter.java @@ -99,7 +99,7 @@ public interface IBukkitAdapter { checkNotNull(position); return new org.bukkit.Location( world, - position.getX(), position.getY(), position.getZ() + position.x(), position.y(), position.z() ); } @@ -119,7 +119,7 @@ public interface IBukkitAdapter { checkNotNull(location); return new org.bukkit.Location( world, - location.getX(), location.getY(), location.getZ(), + location.x(), location.y(), location.z(), location.getYaw(), location.getPitch() ); diff --git a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/Regenerator.java b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/Regenerator.java index 2a006d141..4afbe03a2 100644 --- a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/Regenerator.java +++ b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/Regenerator.java @@ -354,7 +354,7 @@ public abstract class Regenerator> 4 << 4) - border * 16, - oldMin.getY(), - (oldMin.getZ() >> 4 << 4) - border * 16 + (oldMin.x() >> 4 << 4) - border * 16, + oldMin.y(), + (oldMin.z() >> 4 << 4) - border * 16 ); BlockVector3 oldMax = region.getMaximumPoint(); BlockVector3 newMax = BlockVector3.at( - (oldMax.getX() >> 4 << 4) + (border + 1) * 16 - 1, - oldMax.getY(), - (oldMax.getZ() >> 4 << 4) + (border + 1) * 16 - 1 + (oldMax.x() >> 4 << 4) + (border + 1) * 16 - 1, + oldMax.y(), + (oldMax.z() >> 4 << 4) + (border + 1) * 16 - 1 ); Region adjustedRegion = new CuboidRegion(newMin, newMax); return adjustedRegion.getChunks().stream() .sorted(Comparator - .comparingInt(BlockVector2::getZ) - .thenComparingInt(BlockVector2::getX)) //needed for RegionLimitedWorldAccess - .mapToLong(c -> MathMan.pairInt(c.getX(), c.getZ())) + .comparingInt(BlockVector2::z) + .thenComparingInt(BlockVector2::x)) //needed for RegionLimitedWorldAccess + .mapToLong(c -> MathMan.pairInt(c.x(), c.z())) .toArray(); } diff --git a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/WorldGuardFeature.java b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/WorldGuardFeature.java index 1043d9a3e..c847a8688 100644 --- a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/WorldGuardFeature.java +++ b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/WorldGuardFeature.java @@ -56,7 +56,7 @@ public class WorldGuardFeature extends BukkitMaskManager implements Listener { if (region instanceof ProtectedPolygonalRegion casted) { BlockVector3 max = region.getMaximumPoint(); BlockVector3 min = region.getMinimumPoint(); - return new Polygonal2DRegion(null, casted.getPoints(), min.getBlockY(), max.getBlockY()); + return new Polygonal2DRegion(null, casted.getPoints(), min.y(), max.y()); } return new AdaptedRegion(region); } diff --git a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweDelegateSchematicHandler.java b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweDelegateSchematicHandler.java index 6cf09da28..792f3937e 100644 --- a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweDelegateSchematicHandler.java +++ b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweDelegateSchematicHandler.java @@ -94,15 +94,15 @@ public class FaweDelegateSchematicHandler { return; } BlockVector3 dimension = schematic.getClipboard().getDimensions(); - final int WIDTH = dimension.getX(); - final int LENGTH = dimension.getZ(); - final int HEIGHT = dimension.getY(); + final int WIDTH = dimension.x(); + final int LENGTH = dimension.z(); + final int HEIGHT = dimension.y(); final int worldHeight = plot.getArea().getMaxGenHeight() - plot.getArea().getMinGenHeight() + 1; // Validate dimensions CuboidRegion region = plot.getLargestRegion(); boolean sizeMismatch = - ((region.getMaximumPoint().getX() - region.getMinimumPoint().getX() + xOffset + 1) < WIDTH) || ( - (region.getMaximumPoint().getZ() - region.getMinimumPoint().getZ() + zOffset + 1) < LENGTH) || (HEIGHT + ((region.getMaximumPoint().x() - region.getMinimumPoint().x() + xOffset + 1) < WIDTH) || ( + (region.getMaximumPoint().z() - region.getMinimumPoint().z() + zOffset + 1) < LENGTH) || (HEIGHT > worldHeight); if (!Settings.Schematics.PASTE_MISMATCHES && sizeMismatch) { if (actor != null) { @@ -111,8 +111,8 @@ public class FaweDelegateSchematicHandler { TaskManager.runTask(whenDone); return; } - if (((region.getMaximumPoint().getX() - region.getMinimumPoint().getX() + xOffset + 1) < WIDTH) || ( - (region.getMaximumPoint().getZ() - region.getMinimumPoint().getZ() + zOffset + 1) < LENGTH) || (HEIGHT + if (((region.getMaximumPoint().x() - region.getMinimumPoint().x() + xOffset + 1) < WIDTH) || ( + (region.getMaximumPoint().z() - region.getMinimumPoint().z() + zOffset + 1) < LENGTH) || (HEIGHT > worldHeight)) { if (whenDone != null) { TaskManager.runTask(whenDone); @@ -141,7 +141,7 @@ public class FaweDelegateSchematicHandler { } else { y_offset_actual = yOffset + pw.getMinBuildHeight() + editSession.getHighestTerrainBlock(region .getMinimumPoint() - .getX() + 1, region.getMinimumPoint().getZ() + 1, pw.getMinGenHeight(), pw.getMaxGenHeight() + .x() + 1, region.getMinimumPoint().z() + 1, pw.getMinGenHeight(), pw.getMaxGenHeight() ); } } @@ -150,7 +150,7 @@ public class FaweDelegateSchematicHandler { } final BlockVector3 to = BlockVector3 - .at(region.getMinimumPoint().getX() + xOffset, y_offset_actual, region.getMinimumPoint().getZ() + zOffset); + .at(region.getMinimumPoint().x() + xOffset, y_offset_actual, region.getMinimumPoint().z() + zOffset); final Clipboard clipboard = schematic.getClipboard(); clipboard.setOrigin(clipboard.getRegion().getMinimumPoint()); clipboard.paste(editSession, to, true, false, true); diff --git a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/PlotSquaredFeature.java b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/PlotSquaredFeature.java index e1ac20617..9f0916a4b 100644 --- a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/PlotSquaredFeature.java +++ b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/PlotSquaredFeature.java @@ -159,8 +159,8 @@ public class PlotSquaredFeature extends FaweMaskManager { regions = WEManager.getMask(pp); if (regions.size() == 1) { CuboidRegion region = regions.iterator().next(); - if (region.getMinimumPoint().getX() == Integer.MIN_VALUE - && region.getMaximumPoint().getX() == Integer.MAX_VALUE) { + if (region.getMinimumPoint().x() == Integer.MIN_VALUE + && region.getMaximumPoint().x() == Integer.MAX_VALUE) { regions.clear(); } } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitAdapter.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitAdapter.java index 41e7e7294..e0a643015 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitAdapter.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitAdapter.java @@ -240,7 +240,7 @@ public enum BukkitAdapter { Vector3 position = location; return new org.bukkit.Location( adapt((World) location.getExtent()), - position.getX(), position.getY(), position.getZ(), + position.x(), position.y(), position.z(), location.getYaw(), location.getPitch() ); @@ -258,7 +258,7 @@ public enum BukkitAdapter { checkNotNull(position); return new org.bukkit.Location( world, - position.getX(), position.getY(), position.getZ() + position.x(), position.y(), position.z() ); } @@ -274,7 +274,7 @@ public enum BukkitAdapter { checkNotNull(position); return new org.bukkit.Location( world, - position.getX(), position.getY(), position.getZ() + position.x(), position.y(), position.z() ); } @@ -290,7 +290,7 @@ public enum BukkitAdapter { checkNotNull(location); return new org.bukkit.Location( world, - location.getX(), location.getY(), location.getZ(), + location.x(), location.y(), location.z(), location.getYaw(), location.getPitch() ); diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java index 9c5196e91..8a0081484 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java @@ -242,9 +242,9 @@ public class BukkitPlayer extends AbstractPlayerActor { //FAWE end return TaskManager.taskManager().sync(() -> player.teleport(new Location( finalWorld, - pos.getX(), - pos.getY(), - pos.getZ(), + pos.x(), + pos.y(), + pos.z(), yaw, pitch ))); @@ -422,7 +422,7 @@ public class BukkitPlayer extends AbstractPlayerActor { @Override public > void sendFakeBlock(BlockVector3 pos, B block) { - Location loc = new Location(player.getWorld(), pos.getX(), pos.getY(), pos.getZ()); + Location loc = new Location(player.getWorld(), pos.x(), pos.y(), pos.z()); if (block == null) { player.sendBlockChange(loc, player.getWorld().getBlockAt(loc).getBlockData()); } else { 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 1598cb547..b2fdeead9 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 @@ -247,7 +247,7 @@ public class BukkitWorld extends AbstractWorld { //FAWE start - safe edit region testCoords(pt); //FAWE end - return getWorld().getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).getLightLevel(); + return getWorld().getBlockAt(pt.x(), pt.y(), pt.z()).getLightLevel(); } @Override @@ -284,7 +284,7 @@ public class BukkitWorld extends AbstractWorld { return false; } - Block block = getWorld().getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()); + Block block = getWorld().getBlockAt(pt.x(), pt.y(), pt.z()); BlockState state = PaperLib.getBlockState(block, false).getState(); if (!(state instanceof InventoryHolder)) { return false; @@ -363,8 +363,8 @@ public class BukkitWorld extends AbstractWorld { //FAWE end World world = getWorld(); //FAWE start - int X = pt.getBlockX() >> 4; - int Z = pt.getBlockZ() >> 4; + int X = pt.x() >> 4; + int Z = pt.z() >> 4; if (Fawe.isMainThread()) { world.getChunkAt(X, Z); } else if (PaperLib.isPaper()) { @@ -413,7 +413,7 @@ public class BukkitWorld extends AbstractWorld { public void fixAfterFastMode(Iterable chunks) { World world = getWorld(); for (BlockVector2 chunkPos : chunks) { - world.refreshChunk(chunkPos.getBlockX(), chunkPos.getBlockZ()); + world.refreshChunk(chunkPos.x(), chunkPos.z()); } } @@ -495,13 +495,13 @@ public class BukkitWorld extends AbstractWorld { //FAWE start - safe edit region testCoords(pt); //FAWE end - getWorld().getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).breakNaturally(); + getWorld().getBlockAt(pt.x(), pt.y(), pt.z()).breakNaturally(); } //FAWE start @Override public Collection getBlockDrops(BlockVector3 position) { - return getWorld().getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ()).getDrops().stream() + return getWorld().getBlockAt(position.x(), position.y(), position.z()).getDrops().stream() .map(BukkitAdapter::adapt).collect(Collectors.toList()); } //FAWE end @@ -538,7 +538,7 @@ public class BukkitWorld extends AbstractWorld { } } if (WorldEditPlugin.getInstance().getLocalConfiguration().unsupportedVersionEditing) { - Block bukkitBlock = getWorld().getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ()); + Block bukkitBlock = getWorld().getBlockAt(position.x(), position.y(), position.z()); return BukkitAdapter.adapt(bukkitBlock.getBlockData()); } else { throw new RuntimeException(new UnsupportedVersionEditException()); @@ -562,7 +562,7 @@ public class BukkitWorld extends AbstractWorld { } } } - Block bukkitBlock = getWorld().getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ()); + Block bukkitBlock = getWorld().getBlockAt(position.x(), position.y(), position.z()); bukkitBlock.setBlockData(BukkitAdapter.adapt(block), sideEffects.doesApplyAny()); return true; } @@ -584,8 +584,8 @@ public class BukkitWorld extends AbstractWorld { if (!Settings.settings().REGION_RESTRICTIONS_OPTIONS.RESTRICT_TO_SAFE_RANGE) { return; } - int x = position.getX(); - int z = position.getZ(); + int x = position.x(); + int z = position.z(); if (x > 30000000 || z > 30000000 || x < -30000000 || z < -30000000) { throw FaweCache.OUTSIDE_SAFE_REGION; } @@ -636,9 +636,9 @@ public class BukkitWorld extends AbstractWorld { testCoords(position); //FAWE end if (HAS_3D_BIOMES) { - return BukkitAdapter.adapt(getWorld().getBiome(position.getBlockX(), position.getBlockY(), position.getBlockZ())); + return BukkitAdapter.adapt(getWorld().getBiome(position.x(), position.y(), position.z())); } else { - return BukkitAdapter.adapt(getWorld().getBiome(position.getBlockX(), position.getBlockZ())); + return BukkitAdapter.adapt(getWorld().getBiome(position.x(), position.z())); } } @@ -649,9 +649,9 @@ public class BukkitWorld extends AbstractWorld { testCoords(position); //FAWE end if (HAS_3D_BIOMES) { - getWorld().setBiome(position.getBlockX(), position.getBlockY(), position.getBlockZ(), BukkitAdapter.adapt(biome)); + getWorld().setBiome(position.x(), position.y(), position.z(), BukkitAdapter.adapt(biome)); } else { - getWorld().setBiome(position.getBlockX(), position.getBlockZ(), BukkitAdapter.adapt(biome)); + getWorld().setBiome(position.x(), position.z(), BukkitAdapter.adapt(biome)); } return true; } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/FaweAPI.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/FaweAPI.java index 4c5339017..acc0d8bf3 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/FaweAPI.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/FaweAPI.java @@ -339,11 +339,11 @@ public class FaweAPI { final BlockVector3 bot = selection.getMinimumPoint(); final BlockVector3 top = selection.getMaximumPoint(); - final int minX = bot.getBlockX() >> 4; - final int minZ = bot.getBlockZ() >> 4; + final int minX = bot.x() >> 4; + final int minZ = bot.z() >> 4; - final int maxX = top.getBlockX() >> 4; - final int maxZ = top.getBlockZ() >> 4; + final int maxX = top.x() >> 4; + final int maxZ = top.z() >> 4; int count = 0; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/BlendBall.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/BlendBall.java index 902e48a9b..ec3e0766e 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/BlendBall.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/BlendBall.java @@ -50,9 +50,9 @@ public class BlendBall implements Brush { final int outsetSize = (int) (size + 1); double brushSizeSquared = size * size; - int tx = position.getBlockX(); - int ty = position.getBlockY(); - int tz = position.getBlockZ(); + int tx = position.x(); + int ty = position.y(); + int tz = position.z(); int[] frequency = new int[BlockTypes.size()]; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/CatenaryBrush.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/CatenaryBrush.java index e380e74b0..7ad15cef4 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/CatenaryBrush.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/CatenaryBrush.java @@ -81,9 +81,9 @@ public class CatenaryBrush implements Brush, ResettableTool { return pos1.add(pos2).divide(2).toBlockPoint(); } double curveLen = pos1.distance(pos2) * lenPercent; - double dy = pos2.getY() - pos1.getY(); - double dx = pos2.getX() - pos1.getX(); - double dz = pos2.getZ() - pos1.getZ(); + double dy = pos2.y() - pos1.y(); + double dx = pos2.x() - pos1.x(); + double dz = pos2.z() - pos1.z(); double dh = Math.sqrt(dx * dx + dz * dz); double g = Math.sqrt(curveLen * curveLen - dy * dy) / 2; double a = 0.00001; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/CommandBrush.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/CommandBrush.java index 227960c1d..b71578b55 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/CommandBrush.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/CommandBrush.java @@ -54,9 +54,9 @@ public class CommandBrush implements Brush { position.subtract(radius, radius, radius), position.add(radius, radius, radius) ); - String replaced = command.replace("{x}", Integer.toString(position.getBlockX())) - .replace("{y}", Integer.toString(position.getBlockY())) - .replace("{z}", Integer.toString(position.getBlockZ())) + String replaced = command.replace("{x}", Integer.toString(position.x())) + .replace("{y}", Integer.toString(position.y())) + .replace("{z}", Integer.toString(position.z())) .replace("{world}", editSession.getWorld().getName()) .replace("{size}", Integer.toString(radius)); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/CopyPastaBrush.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/CopyPastaBrush.java index 4aeb2daeb..b635c1e7d 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/CopyPastaBrush.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/CopyPastaBrush.java @@ -65,11 +65,11 @@ public class CopyPastaBrush implements Brush, ResettableTool { mask = Masks.alwaysTrue(); } final ResizableClipboardBuilder builder = new ResizableClipboardBuilder(editSession.getWorld()); - final int minY = position.getBlockY(); + final int minY = position.y(); mask = new AbstractDelegateMask(mask) { @Override public boolean test(BlockVector3 vector) { - if (super.test(vector) && vector.getBlockY() >= minY) { + if (super.test(vector) && vector.y() >= minY) { BaseBlock block = editSession.getFullBlock(vector); if (!block.getBlockType().getMaterial().isAir()) { builder.add(vector, BlockTypes.AIR.getDefaultState().toBaseBlock(), block); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/ErodeBrush.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/ErodeBrush.java index 21879751c..da52bf504 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/ErodeBrush.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/ErodeBrush.java @@ -63,9 +63,9 @@ public class ErodeBrush implements Brush { Clipboard buffer1 = new CPUOptimizedClipboard(region); Clipboard buffer2 = new CPUOptimizedClipboard(region); - final int bx = target.getBlockX(); - final int by = target.getBlockY(); - final int bz = target.getBlockZ(); + final int bx = target.x(); + final int by = target.y(); + final int bz = target.z(); for (int x = -brushSize, relx = 0; x <= brushSize && relx < buffer1.getWidth(); x++, relx++) { int x0 = x + bx; @@ -106,7 +106,7 @@ public class ErodeBrush implements Brush { for (BlockVector3 pos : finalBuffer) { BlockState block = pos.getBlock(finalBuffer); - es.setBlock(pos.getX() + bx - brushSize, pos.getY() + by - brushSize, pos.getZ() + bz - brushSize, block); + es.setBlock(pos.x() + bx - brushSize, pos.y() + by - brushSize, pos.z() + bz - brushSize, block); } } @@ -139,9 +139,9 @@ public class ErodeBrush implements Brush { int highest = 1; for (BlockVector3 offs : FACES_TO_CHECK) { BaseBlock next = current.getFullBlock( - relx + offs.getBlockX(), - rely + offs.getBlockY(), - relz + offs.getBlockZ() + relx + offs.x(), + rely + offs.y(), + relz + offs.z() ); if (!next.getBlockType().getMaterial().isMovementBlocker()) { continue; @@ -190,9 +190,9 @@ public class ErodeBrush implements Brush { int total = 0; for (BlockVector3 offs : FACES_TO_CHECK) { BaseBlock next = current.getFullBlock( - relx + offs.getBlockX(), - rely + offs.getBlockY(), - relz + offs.getBlockZ() + relx + offs.x(), + rely + offs.y(), + relz + offs.z() ); if (next.getMaterial().isMovementBlocker()) { continue; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/FallingSphere.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/FallingSphere.java index fd720c54e..d54bbebb6 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/FallingSphere.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/FallingSphere.java @@ -12,9 +12,9 @@ public class FallingSphere implements Brush { @Override public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException { - int px = position.getBlockX(); - int py = position.getBlockY(); - int pz = position.getBlockZ(); + int px = position.x(); + int py = position.y(); + int pz = position.z(); int maxY = editSession.getMaxY(); int minY = editSession.getMinY(); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/InspectBrush.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/InspectBrush.java index 5ad9b818a..1ef2a27fa 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/InspectBrush.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/InspectBrush.java @@ -14,7 +14,6 @@ import com.sk89q.worldedit.command.tool.BrushTool; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Platform; -import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.util.Location; @@ -25,7 +24,6 @@ import com.sk89q.worldedit.util.formatting.text.event.HoverEvent; import com.sk89q.worldedit.util.formatting.text.format.TextColor; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BlockState; -import org.apache.logging.log4j.Logger; import java.io.IOException; import java.util.Iterator; @@ -80,9 +78,9 @@ public class InspectBrush extends BrushTool { return true; } BlockVector3 target = targetVector.toBlockPoint(); - final int x = target.getBlockX(); - final int y = target.getBlockY(); - final int z = target.getBlockZ(); + final int x = target.x(); + final int y = target.y(); + final int z = target.z(); World world = player.getWorld(); RollbackDatabase db = DBHandler.dbHandler().getDatabase(world); int count = 0; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/RecurseBrush.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/RecurseBrush.java index 869d45150..f87fee30e 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/RecurseBrush.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/RecurseBrush.java @@ -35,7 +35,7 @@ public record RecurseBrush(boolean dfs) implements Brush { DFSRecursiveVisitor visitor = new DFSRecursiveVisitor(mask, replace, Integer.MAX_VALUE, Integer.MAX_VALUE) { @Override public boolean isVisitable(BlockVector3 from, BlockVector3 to) { - int y = to.getBlockY(); + int y = to.y(); return y < maxY && radMask.test(to) && super.isVisitable(from, to); } }; @@ -45,7 +45,7 @@ public record RecurseBrush(boolean dfs) implements Brush { RecursiveVisitor visitor = new RecursiveVisitor(mask, replace, radius, editSession.getMinY(), editSession.getMaxY()) { @Override public boolean isVisitable(BlockVector3 from, BlockVector3 to) { - int y = to.getBlockY(); + int y = to.y(); return y < maxY && super.isVisitable(from, to); } }; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/RockBrush.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/RockBrush.java index 4196a7e11..27937b836 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/RockBrush.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/RockBrush.java @@ -19,15 +19,15 @@ public record RockBrush(double amplitude, double frequency, Vector3 radius) impl double seedY = ThreadLocalRandom.current().nextDouble(); double seedZ = ThreadLocalRandom.current().nextDouble(); - int px = position.getBlockX(); - int py = position.getBlockY(); - int pz = position.getBlockZ(); + int px = position.x(); + int py = position.y(); + int pz = position.z(); double distort = this.frequency / size; - double modX = 1D / radius.getX(); - double modY = 1D / radius.getY(); - double modZ = 1D / radius.getZ(); + double modX = 1D / radius.x(); + double modY = 1D / radius.y(); + double modZ = 1D / radius.z(); int radiusSqr = (int) (size * size); int sizeInt = (int) size * 2; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/ScatterBrush.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/ScatterBrush.java index e14d0c599..26cf07558 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/ScatterBrush.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/ScatterBrush.java @@ -67,15 +67,15 @@ public class ScatterBrush implements Brush { } BlockVector3 patternSize = pattern.size(); BlockVector3Set placed = BlockVector3Set.getAppropriateVectorSet(patternSize.add(distance, distance, distance)); - placed.setOffset(position.getX(), position.getY(), position.getZ()); + placed.setOffset(position.x(), position.y(), position.z()); int maxFails = 1000; for (int i = 0; i < count; i++) { int index = ThreadLocalRandom.current().nextInt(length); BlockVector3 pos = visited.get(index); if (pos != null && canApply(pos)) { - int x = pos.getBlockX(); - int y = pos.getBlockY(); - int z = pos.getBlockZ(); + int x = pos.x(); + int y = pos.y(); + int z = pos.z(); if (placed.containsRadius(x, y, z, distance)) { if (maxFails-- <= 0) { break; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/ScatterCommand.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/ScatterCommand.java index 1d7841355..9e2c16555 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/ScatterCommand.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/ScatterCommand.java @@ -45,9 +45,9 @@ public class ScatterCommand extends ScatterBrush { position.subtract(radius, radius, radius), position.add(radius, radius, radius) ); - String replaced = command.replace("{x}", Integer.toString(position.getBlockX())) - .replace("{y}", Integer.toString(position.getBlockY())) - .replace("{z}", Integer.toString(position.getBlockZ())) + String replaced = command.replace("{x}", Integer.toString(position.x())) + .replace("{y}", Integer.toString(position.y())) + .replace("{z}", Integer.toString(position.z())) .replace("{world}", editSession.getWorld().getName()) .replace("{size}", Integer.toString(radius)); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/ScatterOverlayBrush.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/ScatterOverlayBrush.java index cd7ce9aaa..d6a991234 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/ScatterOverlayBrush.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/ScatterOverlayBrush.java @@ -16,9 +16,9 @@ public class ScatterOverlayBrush extends ScatterBrush { @Override public void apply(EditSession editSession, LocalBlockVectorSet placed, BlockVector3 pt, Pattern p, double size) throws MaxChangedBlocksException { - final int x = pt.getBlockX(); - final int y = pt.getBlockY(); - final int z = pt.getBlockZ(); + final int x = pt.x(); + final int y = pt.y(); + final int z = pt.z(); BlockVector3 dir = getDirection(pt); if (dir == null) { getDir: @@ -37,7 +37,7 @@ public class ScatterOverlayBrush extends ScatterBrush { return; } } - editSession.setBlock(x + dir.getBlockX(), y + dir.getBlockY(), z + dir.getBlockZ(), p); + editSession.setBlock(x + dir.x(), y + dir.y(), z + dir.z(), p); } } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/ShatterBrush.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/ShatterBrush.java index 41b36e12c..196b71f50 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/ShatterBrush.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/ShatterBrush.java @@ -80,13 +80,13 @@ public class ShatterBrush extends ScatterBrush { } for (int i1 = 0; i1 < BreadthFirstSearch.DIAGONAL_DIRECTIONS.length; i1++) { BlockVector3 direction = BreadthFirstSearch.DIAGONAL_DIRECTIONS[i1]; - int x2 = x + direction.getBlockX(); - int y2 = y + direction.getBlockY(); - int z2 = z + direction.getBlockZ(); + int x2 = x + direction.x(); + int y2 = y + direction.y(); + int z2 = z + direction.z(); // Check boundary - int dx = position.getBlockX() - x2; - int dy = position.getBlockY() - y2; - int dz = position.getBlockZ() - z2; + int dx = position.x() - x2; + int dy = position.y() - y2; + int dz = position.z() - z2; int dSqr = (dx * dx) + (dy * dy) + (dz * dz); if (dSqr <= radius2) { BlockVector3 bv = mutable.setComponents(x2, y2, z2); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/SplineBrush.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/SplineBrush.java index 55d8fd96a..e1fa38708 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/SplineBrush.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/SplineBrush.java @@ -130,9 +130,9 @@ public class SplineBrush implements Brush, ResettableTool { private Vector3 getCentroid(Collection points) { MutableVector3 sum = new MutableVector3(); for (BlockVector3 p : points) { - sum.mutX(sum.getX() + p.getX()); - sum.mutY(sum.getY() + p.getY()); - sum.mutZ(sum.getZ() + p.getZ()); + sum.mutX(sum.x() + p.x()); + sum.mutY(sum.y() + p.y()); + sum.mutZ(sum.z() + p.z()); } return sum.multiply(1.0 / points.size()); } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/SurfaceSpline.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/SurfaceSpline.java index f652c4f94..8c94e76ad 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/SurfaceSpline.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/brush/SurfaceSpline.java @@ -38,16 +38,16 @@ public class SurfaceSpline implements Brush { int minY = editSession.getMinY(); if (path.isEmpty() || !pos.equals(path.get(path.size() - 1))) { int max = editSession.getNearestSurfaceTerrainBlock( - pos.getBlockX(), - pos.getBlockZ(), - pos.getBlockY(), + pos.x(), + pos.z(), + pos.y(), minY, maxY ); if (max == -1) { return; } - path.add(BlockVector3.at(pos.getBlockX(), max, pos.getBlockZ())); + path.add(BlockVector3.at(pos.x(), max, pos.z())); if (editSession.getActor() != null) { editSession.getActor().print(Caption.of("fawe.worldedit.brush.spline.primary.2")); } @@ -69,9 +69,9 @@ public class SurfaceSpline implements Brush { LocalBlockVectorSet vset = new LocalBlockVectorSet(); for (double loop = 0; loop <= 1; loop += 1D / splinelength / quality) { final Vector3 tipv = interpol.getPosition(loop); - final int tipx = MathMan.roundInt(tipv.getX()); - final int tipz = (int) tipv.getZ(); - int tipy = MathMan.roundInt(tipv.getY()); + final int tipx = MathMan.roundInt(tipv.x()); + final int tipz = (int) tipv.z(); + int tipy = MathMan.roundInt(tipv.y()); tipy = editSession.getNearestSurfaceTerrainBlock(tipx, tipz, tipy, minY, maxY, Integer.MIN_VALUE, Integer.MAX_VALUE); if (tipy == Integer.MIN_VALUE || tipy == Integer.MAX_VALUE) { continue; @@ -88,15 +88,15 @@ public class SurfaceSpline implements Brush { LocalBlockVectorSet newSet = new LocalBlockVectorSet(); final int ceilrad = (int) Math.ceil(radius); for (BlockVector3 v : vset) { - final int tipx = v.getBlockX(); - final int tipz = v.getBlockZ(); + final int tipx = v.x(); + final int tipz = v.z(); for (int loopx = tipx - ceilrad; loopx <= tipx + ceilrad; loopx++) { for (int loopz = tipz - ceilrad; loopz <= tipz + ceilrad; loopz++) { if (MathMan.hypot2(loopx - tipx, 0, loopz - tipz) <= radius2) { int y = editSession.getNearestSurfaceTerrainBlock( loopx, loopz, - v.getBlockY(), + v.y(), minY, maxY, Integer.MIN_VALUE, diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/sweep/ClipboardSpline.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/sweep/ClipboardSpline.java index 87f1495f5..281c78c74 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/sweep/ClipboardSpline.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/sweep/ClipboardSpline.java @@ -83,7 +83,7 @@ public class ClipboardSpline extends Spline { Region region = clipboard.getRegion(); BlockVector3 origin = clipboard.getOrigin(); // center = region.getCenter().setY(origin.getY() - 1); - center = region.getCenter().withY(origin.getY() - 1).toBlockPoint(); + center = region.getCenter().withY(origin.y() - 1).toBlockPoint(); this.centerOffset = center.subtract(center.round()); this.center = center.subtract(centerOffset); this.transform = transform; @@ -108,15 +108,15 @@ public class ClipboardSpline extends Spline { clipboardHolder.setTransform(transform); BlockVector3 functionOffset = target.subtract(clipboard.getOrigin()); - final int offX = functionOffset.getBlockX(); - final int offY = functionOffset.getBlockY(); - final int offZ = functionOffset.getBlockZ(); + final int offX = functionOffset.x(); + final int offY = functionOffset.y(); + final int offZ = functionOffset.z(); Operation operation = clipboardHolder .createPaste(editSession) .to(target) .ignoreAirBlocks(true) - .filter(v -> buffer.add(v.getBlockX() + offX, v.getBlockY() + offY, v.getBlockZ() + offZ)) + .filter(v -> buffer.add(v.x() + offX, v.y() + offY, v.z() + offZ)) .build(); Operations.completeLegacy(operation); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/sweep/Spline.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/sweep/Spline.java index 945c10f5a..872ec495e 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/sweep/Spline.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/sweep/Spline.java @@ -121,7 +121,7 @@ public abstract class Spline { * 2 dimensional "cross" product. cross2D(v1, v2) = |v1|*|v2|*sin(theta) or v1 X v2 taking Y to be 0 */ private double cross2D(Vector2 v1, Vector2 v2) { - return v1.getX() * v2.getZ() - v2.getX() * v1.getZ(); + return v1.x() * v2.z() - v2.x() * v1.z(); } /** @@ -144,7 +144,7 @@ public abstract class Spline { // Calculate rotation from spline Vector3 deriv = interpolation.get1stDerivative(position); - Vector2 deriv2D = Vector2.at(deriv.getX(), deriv.getZ()).normalize(); + Vector2 deriv2D = Vector2.at(deriv.x(), deriv.z()).normalize(); double angle = Math.toDegrees( -Math.atan2(cross2D(direction, deriv2D), direction.dot(deriv2D)) ); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/sweep/SweepBrush.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/sweep/SweepBrush.java index fa4bb971c..603fb4302 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/sweep/SweepBrush.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/sweep/SweepBrush.java @@ -79,13 +79,13 @@ public class SweepBrush implements Brush, ResettableTool { Clipboard clipboard = holder.getClipboard(); BlockVector3 dimensions = clipboard.getDimensions(); - double quality = Math.max(dimensions.getBlockX(), dimensions.getBlockZ()); + double quality = Math.max(dimensions.x(), dimensions.z()); AffineTransform transform = new AffineTransform(); ClipboardSpline spline = new ClipboardSpline(editSession, holder, interpol, transform, nodes.size()); - if (dimensions.getBlockX() > dimensions.getBlockZ()) { + if (dimensions.x() > dimensions.z()) { spline.setDirection(Vector2.at(0, 1)); } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/database/RollbackDatabase.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/database/RollbackDatabase.java index 1677521fe..f8207f2dc 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/database/RollbackDatabase.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/database/RollbackDatabase.java @@ -179,13 +179,13 @@ public class RollbackDatabase extends AsyncNotifyQueue { } try (PreparedStatement stmt = connection.prepareStatement(stmtStr.formatted(this.prefix))) { stmt.setInt(1, (int) (minTime / 1000)); - stmt.setInt(2, pos1.getBlockX()); - stmt.setInt(3, pos2.getBlockX()); - stmt.setInt(4, pos1.getBlockZ()); - stmt.setInt(5, pos2.getBlockZ()); + stmt.setInt(2, pos1.x()); + stmt.setInt(3, pos2.x()); + stmt.setInt(4, pos1.z()); + stmt.setInt(5, pos2.z()); // Keep 128 offset for backwards-compatibility - stmt.setInt(6, pos1.getBlockY() - 128); - stmt.setInt(7, pos2.getBlockY() - 128); + stmt.setInt(6, pos1.y() - 128); + stmt.setInt(7, pos2.y() - 128); if (uuid != null) { byte[] uuidBytes = toBytes(uuid); stmt.setBytes(8, uuidBytes); @@ -210,13 +210,13 @@ public class RollbackDatabase extends AsyncNotifyQueue { .array(); stmt.setBytes(1, uuidBytes); stmt.setInt(2, (int) (minTime / 1000)); - stmt.setInt(3, pos1.getBlockX()); - stmt.setInt(4, pos2.getBlockX()); - stmt.setInt(5, pos1.getBlockZ()); - stmt.setInt(6, pos2.getBlockZ()); + stmt.setInt(3, pos1.x()); + stmt.setInt(4, pos2.x()); + stmt.setInt(5, pos1.z()); + stmt.setInt(6, pos2.z()); // Keep 128 offset for backwards-compatibility - stmt.setInt(7, pos1.getBlockY() - 128); - stmt.setInt(8, pos2.getBlockY() - 128); + stmt.setInt(7, pos1.y() - 128); + stmt.setInt(8, pos2.y() - 128); } } return count; @@ -262,13 +262,13 @@ public class RollbackDatabase extends AsyncNotifyQueue { BlockVector3 pos1 = change.getMinimumPoint(); BlockVector3 pos2 = change.getMaximumPoint(); - stmt.setInt(4, pos1.getX()); - stmt.setInt(5, pos2.getX()); - stmt.setInt(6, pos1.getZ()); - stmt.setInt(7, pos2.getZ()); + stmt.setInt(4, pos1.x()); + stmt.setInt(5, pos2.x()); + stmt.setInt(6, pos1.z()); + stmt.setInt(7, pos2.z()); // Keep 128 offset for backwards-compatibility - stmt.setInt(8, pos1.getY() - 128); - stmt.setInt(9, pos2.getY() - 128); + stmt.setInt(8, pos1.y() - 128); + stmt.setInt(9, pos2.y() - 128); stmt.setString(10, change.getCommand()); stmt.setInt(11, change.size()); stmt.executeUpdate(); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/BlockTranslateExtent.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/BlockTranslateExtent.java index d7b8a986e..7f84be430 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/BlockTranslateExtent.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/BlockTranslateExtent.java @@ -24,7 +24,7 @@ public class BlockTranslateExtent extends AbstractDelegateExtent { @Override public > boolean setBlock(BlockVector3 location, T block) throws WorldEditException { - return getExtent().setBlock(location.getX() + dx, location.getY() + dy, location.getZ() + dz, block); + return getExtent().setBlock(location.x() + dx, location.y() + dy, location.z() + dz, block); } @Override @@ -49,7 +49,7 @@ public class BlockTranslateExtent extends AbstractDelegateExtent { @Override public BlockState getBlock(BlockVector3 location) { - return getBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ()); + return getBlock(location.x(), location.y(), location.z()); } @Override diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/FaweRegionExtent.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/FaweRegionExtent.java index 84044f9b2..103dd8824 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/FaweRegionExtent.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/FaweRegionExtent.java @@ -64,11 +64,11 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc @Override public final boolean contains(BlockVector3 p) { - return contains(p.getBlockX(), p.getBlockY(), p.getBlockZ()); + return contains(p.x(), p.y(), p.z()); } public final boolean contains(BlockVector2 p) { - return contains(p.getBlockX(), p.getBlockZ()); + return contains(p.x(), p.z()); } @Override @@ -96,7 +96,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc @Override public BiomeType getBiome(BlockVector3 position) { - return getBiomeType(position.getX(), position.getY(), position.getZ()); + return getBiomeType(position.x(), position.y(), position.z()); } @Override @@ -112,7 +112,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc @Override public BaseBlock getFullBlock(BlockVector3 position) { - return getFullBlock(position.getX(), position.getY(), position.getZ()); + return getFullBlock(position.x(), position.y(), position.z()); } @Override @@ -128,7 +128,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc @Override public BlockState getBlock(BlockVector3 position) { - return getBlock(position.getX(), position.getY(), position.getZ()); + return getBlock(position.x(), position.y(), position.z()); } @Override diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/HistoryExtent.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/HistoryExtent.java index 2fc5133c6..d85594215 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/HistoryExtent.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/HistoryExtent.java @@ -66,7 +66,7 @@ public class HistoryExtent extends AbstractDelegateExtent { @Override public > boolean setBlock(BlockVector3 location, B block) throws WorldEditException { - return setBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ(), block); + return setBlock(location.x(), location.y(), location.z(), block); } @Nullable @@ -111,7 +111,7 @@ public class HistoryExtent extends AbstractDelegateExtent { public boolean setBiome(BlockVector3 position, BiomeType newBiome) { BiomeType oldBiome = this.getBiome(position); if (!oldBiome.getId().equals(newBiome.getId())) { - this.changeSet.addBiomeChange(position.getBlockX(), position.getBlockY(), position.getBlockZ(), oldBiome, newBiome); + this.changeSet.addBiomeChange(position.x(), position.y(), position.z(), oldBiome, newBiome); return getExtent().setBiome(position, newBiome); } else { return false; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/LimitExtent.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/LimitExtent.java index 24d440c57..d02ff9320 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/LimitExtent.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/LimitExtent.java @@ -373,12 +373,12 @@ public class LimitExtent extends AbstractDelegateExtent { size = ((Collection) positions).size(); } else if (positions instanceof Region) { BlockVector3 dim = ((Region) positions).getDimensions(); - size = dim.getX() * dim.getY() * dim.getZ(); + size = dim.x() * dim.y() * dim.z(); } else if (positions instanceof Extent) { BlockVector3 min = ((Extent) positions).getMinimumPoint(); BlockVector3 max = ((Extent) positions).getMinimumPoint(); BlockVector3 dim = max.subtract(min).add(BlockVector3.ONE); - size = dim.getX() * dim.getY() * dim.getZ(); + size = dim.x() * dim.y() * dim.z(); } else { ExtentFilterBlock block = new ExtentFilterBlock(this); for (BlockVector3 pos : positions) { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/PositionTransformExtent.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/PositionTransformExtent.java index 6d74acc16..d5e8e57e8 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/PositionTransformExtent.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/PositionTransformExtent.java @@ -38,9 +38,9 @@ public class PositionTransformExtent extends ResettableExtent { if (min == null) { min = pos; } - mutable.mutX(pos.getX() - min.getX()); - mutable.mutY(pos.getY() - min.getY()); - mutable.mutZ(pos.getZ() - min.getZ()); + mutable.mutX(pos.x() - min.x()); + mutable.mutY(pos.y() - min.y()); + mutable.mutZ(pos.z() - min.z()); MutableVector3 tmp = new MutableVector3(transform.apply(mutable.toVector3())); return min.add(tmp.roundHalfUp().toBlockPoint()); } @@ -49,9 +49,9 @@ public class PositionTransformExtent extends ResettableExtent { if (min == null) { min = BlockVector3.at(x, y, z); } - mutable.mutX(x - min.getX()); - mutable.mutY(y - min.getY()); - mutable.mutZ(z - min.getZ()); + mutable.mutX(x - min.x()); + mutable.mutY(y - min.y()); + mutable.mutZ(z - min.z()); MutableVector3 tmp = new MutableVector3(transform.apply(mutable.toVector3())); return min.add(tmp.roundHalfUp().toBlockPoint()); } @@ -73,10 +73,10 @@ public class PositionTransformExtent extends ResettableExtent { @Override public BiomeType getBiome(BlockVector3 position) { - mutable.mutX(position.getBlockX()); - mutable.mutZ(position.getBlockZ()); - mutable.mutY(position.getBlockY()); - return super.getBiome(getPos(mutable.getX(), mutable.getY(), mutable.getZ())); + mutable.mutX(position.x()); + mutable.mutZ(position.z()); + mutable.mutY(position.y()); + return super.getBiome(getPos(mutable.x(), mutable.y(), mutable.z())); } @Override @@ -92,10 +92,10 @@ public class PositionTransformExtent extends ResettableExtent { @Override public boolean setBiome(BlockVector3 position, BiomeType biome) { - mutable.mutX(position.getBlockX()); - mutable.mutZ(position.getBlockZ()); - mutable.mutY(position.getBlockY()); - return super.setBiome(getPos(mutable.getX(), mutable.getY(), mutable.getZ()), biome); + mutable.mutX(position.x()); + mutable.mutZ(position.z()); + mutable.mutY(position.y()); + return super.setBiome(getPos(mutable.x(), mutable.y(), mutable.z()), biome); } public void setTransform(Transform transform) { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/ProcessedWEExtent.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/ProcessedWEExtent.java index 5abe90348..e08e1535f 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/ProcessedWEExtent.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/ProcessedWEExtent.java @@ -80,12 +80,12 @@ public class ProcessedWEExtent extends AbstractDelegateExtent { @Override public > boolean setBlock(BlockVector3 location, B block) throws WorldEditException { - return setBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ(), block); + return setBlock(location.x(), location.y(), location.z(), block); } @Override public BlockState getBlock(BlockVector3 location) { - return getBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ()); + return getBlock(location.x(), location.y(), location.z()); } @Override diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/SourceMaskExtent.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/SourceMaskExtent.java index 6c2230372..6da0a2ac6 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/SourceMaskExtent.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/SourceMaskExtent.java @@ -41,8 +41,8 @@ public class SourceMaskExtent extends TemporalExtent { @Override public > boolean setBlock(BlockVector3 location, T block) throws WorldEditException { - set(location.getBlockX(), location.getBlockY(), location.getBlockZ(), block); - return mask.test(location) && super.setBlock(location.getX(), location.getY(), location.getZ(), block); + set(location.x(), location.y(), location.z(), block); + return mask.test(location) && super.setBlock(location.x(), location.y(), location.z(), block); } @Override diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/TemporalExtent.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/TemporalExtent.java index ac36bef5a..ff0fa5106 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/TemporalExtent.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/TemporalExtent.java @@ -44,7 +44,7 @@ public class TemporalExtent extends PassthroughExtent { @Override public BlockState getBlock(BlockVector3 position) { - if (position.getX() == x && position.getY() == y && position.getZ() == z) { + if (position.x() == x && position.y() == y && position.z() == z) { return block.toImmutableState(); } return super.getBlock(position); @@ -60,7 +60,7 @@ public class TemporalExtent extends PassthroughExtent { @Override public BaseBlock getFullBlock(BlockVector3 position) { - if (position.getX() == x && position.getY() == y && position.getZ() == z) { + if (position.x() == x && position.y() == y && position.z() == z) { if (block instanceof BaseBlock) { return (BaseBlock) block; } else { @@ -72,7 +72,7 @@ public class TemporalExtent extends PassthroughExtent { @Override public BiomeType getBiome(BlockVector3 position) { - if (position.getX() == bx && position.getZ() == bz) { + if (position.x() == bx && position.z() == bz) { return biome; } return super.getBiome(position); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/TransformExtent.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/TransformExtent.java index 250227439..c424c0f8c 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/TransformExtent.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/TransformExtent.java @@ -55,13 +55,13 @@ public class TransformExtent extends BlockTransformExtent { if (min == null) { min = pos; } - mutable1.mutX(pos.getX() - min.getX()); - mutable1.mutY(pos.getY() - min.getY()); - mutable1.mutZ(pos.getZ() - min.getZ()); + mutable1.mutX(pos.x() - min.x()); + mutable1.mutY(pos.y() - min.y()); + mutable1.mutZ(pos.z() - min.z()); Vector3 tmp = getTransform().apply(mutable1); - mutable2.mutX(tmp.getX() + min.getX()); - mutable2.mutY(tmp.getY() + min.getY()); - mutable2.mutZ(tmp.getZ() + min.getZ()); + mutable2.mutX(tmp.x() + min.x()); + mutable2.mutY(tmp.y() + min.y()); + mutable2.mutZ(tmp.z() + min.z()); return mutable2; } @@ -69,20 +69,20 @@ public class TransformExtent extends BlockTransformExtent { if (min == null) { min = BlockVector3.at(x, y, z); } - mutable1.mutX(x - min.getX()); - mutable1.mutY(y - min.getY()); - mutable1.mutZ(z - min.getZ()); + mutable1.mutX(x - min.x()); + mutable1.mutY(y - min.y()); + mutable1.mutZ(z - min.z()); Vector3 tmp = getTransform().apply(mutable1); - mutable2.mutX(tmp.getX() + min.getX()); - mutable2.mutY(tmp.getY() + min.getY()); - mutable2.mutZ(tmp.getZ() + min.getZ()); + mutable2.mutX(tmp.x() + min.x()); + mutable2.mutY(tmp.y() + min.y()); + mutable2.mutZ(tmp.z() + min.z()); return tmp.toBlockPoint(); } @Override public BlockState getBlock(int x, int y, int z) { BlockVector3 p = getPos(x, y, z); - return transform(super.getBlock(p.getX(), p.getY(), p.getZ())); + return transform(super.getBlock(p.x(), p.y(), p.z())); } @Override @@ -93,7 +93,7 @@ public class TransformExtent extends BlockTransformExtent { @Override public BiomeType getBiomeType(int x, int y, int z) { BlockVector3 p = getPos(x, y, z); - return super.getBiomeType(p.getX(), y, p.getZ()); + return super.getBiomeType(p.x(), y, p.z()); } @Override @@ -114,7 +114,7 @@ public class TransformExtent extends BlockTransformExtent { @Override public boolean setBiome(int x, int y, int z, BiomeType biome) { BlockVector3 p = getPos(x, y, z); - return super.setBiome(p.getX(), p.getY(), p.getZ(), biome); + return super.setBiome(p.x(), p.y(), p.z(), biome); } } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/CPUOptimizedClipboard.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/CPUOptimizedClipboard.java index 1a30a0df8..6a306fc44 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/CPUOptimizedClipboard.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/CPUOptimizedClipboard.java @@ -41,7 +41,7 @@ public class CPUOptimizedClipboard extends LinearClipboard { @Override public boolean setBiome(BlockVector3 position, BiomeType biome) { - return setBiome(position.getX(), position.getY(), position.getZ(), biome); + return setBiome(position.x(), position.y(), position.z(), biome); } @Override @@ -92,7 +92,7 @@ public class CPUOptimizedClipboard extends LinearClipboard { @Override public BiomeType getBiome(BlockVector3 position) { - return getBiome(getBiomeIndex(position.getX(), position.getY(), position.getZ())); + return getBiome(getBiomeIndex(position.x(), position.y(), position.z())); } public void convertTilesToIndex() { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/DiskOptimizedClipboard.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/DiskOptimizedClipboard.java index 76f22a194..f42cdbbff 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/DiskOptimizedClipboard.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/DiskOptimizedClipboard.java @@ -359,7 +359,7 @@ public class DiskOptimizedClipboard extends LinearClipboard { @Override public boolean setBiome(BlockVector3 position, BiomeType biome) { - return setBiome(position.getX(), position.getY(), position.getZ(), biome); + return setBiome(position.x(), position.y(), position.z(), biome); } @Override @@ -417,7 +417,7 @@ public class DiskOptimizedClipboard extends LinearClipboard { @Override public BiomeType getBiome(BlockVector3 position) { - return getBiome(getBiomeIndex(position.getX(), position.getY(), position.getZ())); + return getBiome(getBiomeIndex(position.x(), position.y(), position.z())); } public BlockArrayClipboard toClipboard() { @@ -438,9 +438,9 @@ public class DiskOptimizedClipboard extends LinearClipboard { super.setOrigin(origin); origin = origin.subtract(offset); try { - byteBuffer.putShort(10, (short) origin.getBlockX()); - byteBuffer.putShort(12, (short) origin.getBlockY()); - byteBuffer.putShort(14, (short) origin.getBlockZ()); + byteBuffer.putShort(10, (short) origin.x()); + byteBuffer.putShort(12, (short) origin.y()); + byteBuffer.putShort(14, (short) origin.z()); } catch (Throwable e) { e.printStackTrace(); } @@ -450,9 +450,9 @@ public class DiskOptimizedClipboard extends LinearClipboard { protected void setOffset(BlockVector3 offset) { super.setOffset(offset); try { - byteBuffer.putShort(16, (short) offset.getBlockX()); - byteBuffer.putShort(18, (short) offset.getBlockY()); - byteBuffer.putShort(20, (short) offset.getBlockZ()); + byteBuffer.putShort(16, (short) offset.x()); + byteBuffer.putShort(18, (short) offset.y()); + byteBuffer.putShort(20, (short) offset.z()); } catch (Throwable e) { e.printStackTrace(); } @@ -588,9 +588,9 @@ public class DiskOptimizedClipboard extends LinearClipboard { CompoundTag data = entity.getState().getNbtData(); HashMap value = new HashMap<>(data.getValue()); List pos = new ArrayList<>(3); - pos.add(new DoubleTag(entity.getLocation().getX())); - pos.add(new DoubleTag(entity.getLocation().getX())); - pos.add(new DoubleTag(entity.getLocation().getX())); + pos.add(new DoubleTag(entity.getLocation().x())); + pos.add(new DoubleTag(entity.getLocation().x())); + pos.add(new DoubleTag(entity.getLocation().x())); value.put("Pos", new ListTag(DoubleTag.class, pos)); nbtOS.writeTag(new CompoundTag(value)); } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/MemoryOptimizedClipboard.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/MemoryOptimizedClipboard.java index 449795e5d..6c7a910f2 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/MemoryOptimizedClipboard.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/MemoryOptimizedClipboard.java @@ -64,7 +64,7 @@ public class MemoryOptimizedClipboard extends LinearClipboard { @Override public boolean setBiome(BlockVector3 position, BiomeType biome) { - return setBiome(position.getX(), position.getY(), position.getZ(), biome); + return setBiome(position.x(), position.y(), position.z(), biome); } @Override @@ -115,7 +115,7 @@ public class MemoryOptimizedClipboard extends LinearClipboard { @Override public BiomeType getBiome(BlockVector3 position) { - return getBiome(getBiomeIndex(position.getX(), position.getY(), position.getZ())); + return getBiome(getBiomeIndex(position.x(), position.y(), position.z())); } private int getOrdinal(int index) { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/SimpleClipboard.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/SimpleClipboard.java index c01abd787..f902f6007 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/SimpleClipboard.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/SimpleClipboard.java @@ -70,17 +70,17 @@ public abstract class SimpleClipboard implements Clipboard { @Override public final int getWidth() { - return size.getBlockX(); + return size.x(); } @Override public final int getHeight() { - return size.getBlockY(); + return size.y(); } @Override public final int getLength() { - return size.getBlockZ(); + return size.z(); } @Override diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/WorldCopyClipboard.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/WorldCopyClipboard.java index cdd4ae8df..4bb50ca73 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/WorldCopyClipboard.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/WorldCopyClipboard.java @@ -56,7 +56,7 @@ public class WorldCopyClipboard extends ReadOnlyClipboard { @Override public BiomeType getBiome(BlockVector3 position) { - return getExtent().getBiomeType(position.getX(), position.getY(), position.getZ()); + return getExtent().getBiomeType(position.x(), position.y(), position.z()); } @Override diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/FastSchematicReader.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/FastSchematicReader.java index d884e0151..156e38544 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/FastSchematicReader.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/FastSchematicReader.java @@ -396,8 +396,8 @@ public class FastSchematicReader extends NBTSchematicReader { int locY = loc.getBlockY(); int locZ = loc.getBlockZ(); BlockVector3 max = min.add(dimensions).subtract(BlockVector3.ONE); - if (locX < min.getX() || locY < min.getY() || locZ < min.getZ() - || locX > max.getX() || locY > max.getY() || locZ > max.getZ()) { + if (locX < min.x() || locY < min.y() || locZ < min.z() + || locX > max.x() || locY > max.y() || locZ > max.z()) { for (Entity e : clipboard.getEntities()) { clipboard.removeEntity(e); } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/FastSchematicWriter.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/FastSchematicWriter.java index db3452d29..5218b1c1e 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/FastSchematicWriter.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/FastSchematicWriter.java @@ -114,15 +114,15 @@ public class FastSchematicWriter implements ClipboardWriter { // The Sponge format Offset refers to the 'min' points location in the world. That's our 'Origin' out.writeNamedTag("Offset", new int[]{ - min.getBlockX(), - min.getBlockY(), - min.getBlockZ(), + min.x(), + min.y(), + min.z(), }); out.writeLazyCompoundTag("Metadata", out1 -> { - out1.writeNamedTag("WEOffsetX", offset.getBlockX()); - out1.writeNamedTag("WEOffsetY", offset.getBlockY()); - out1.writeNamedTag("WEOffsetZ", offset.getBlockZ()); + out1.writeNamedTag("WEOffsetX", offset.x()); + out1.writeNamedTag("WEOffsetY", offset.y()); + out1.writeNamedTag("WEOffsetZ", offset.z()); out1.writeNamedTag("FAWEVersion", Fawe.instance().getVersion().build); }); @@ -162,9 +162,9 @@ public class FastSchematicWriter implements ClipboardWriter { // Dum. values.remove("id"); values.put("Pos", new IntArrayTag(new int[]{ - pos.getX(), - pos.getY(), - pos.getZ() + pos.x(), + pos.y(), + pos.z() })); numTiles++; @@ -282,10 +282,10 @@ public class FastSchematicWriter implements ClipboardWriter { int length = clipboard.getRegion().getLength(); MutableBlockVector3 mutable = new MutableBlockVector3(); for (int z = 0, i = 0; z < length; z++) { - int z0 = min.getBlockZ() + z; + int z0 = min.z() + z; for (int x = 0; x < width; x++, i++) { - int x0 = min.getBlockX() + x; - BiomeType biome = clipboard.getBiome(mutable.setComponents(x0, min.getY(), z0)); + int x0 = min.x() + x; + BiomeType biome = clipboard.getBiome(mutable.setComponents(x0, min.y(), z0)); task.applyInt(i, biome.getInternalId()); } } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/schematic/MinecraftStructure.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/schematic/MinecraftStructure.java index 66deefeb7..d52d74b5a 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/schematic/MinecraftStructure.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/schematic/MinecraftStructure.java @@ -213,8 +213,8 @@ public class MinecraftStructure implements ClipboardReader, ClipboardWriter { if (block.getBlockType() != BlockTypes.STRUCTURE_VOID) { int combined = block.getInternalId(); int index = indexes.get(combined); - List pos = Arrays.asList(point.getX() - min.getX(), - point.getY() - min.getY(), point.getZ() - min.getZ() + List pos = Arrays.asList(point.x() - min.x(), + point.y() - min.y(), point.z() - min.z() ); if (!block.hasNbtData()) { blocks.add(FaweCache.INSTANCE.asMap("state", index, "pos", pos)); @@ -231,7 +231,7 @@ public class MinecraftStructure implements ClipboardReader, ClipboardWriter { ArrayList> entities = new ArrayList<>(); for (Entity entity : clipboard.getEntities()) { Location loc = entity.getLocation(); - List pos = Arrays.asList(loc.getX(), loc.getY(), loc.getZ()); + List pos = Arrays.asList(loc.x(), loc.y(), loc.z()); List blockPos = Arrays.asList(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); BaseEntity state = entity.getState(); if (state != null) { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/schematic/PNGWriter.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/schematic/PNGWriter.java index b5cbc7fb2..48a3315d5 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/schematic/PNGWriter.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/schematic/PNGWriter.java @@ -75,9 +75,9 @@ public class PNGWriter implements ClipboardWriter { MutableBlockVector3 mutableLeft = new MutableBlockVector3(0, 0, 0); BlockVector3 min = clipboard.getMinimumPoint(); - int y0 = min.getBlockY(); - int z0 = min.getBlockZ(); - int x0 = min.getBlockX(); + int y0 = min.y(); + int z0 = min.z(); + int x0 = min.x(); for (int x = x0; x < x0 + width; x++) { mutable.mutX(x); mutableTop.mutX(x); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/ArrayImageMask.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/ArrayImageMask.java index 4976af5f7..07c9acac1 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/ArrayImageMask.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/ArrayImageMask.java @@ -20,7 +20,7 @@ public class ArrayImageMask implements FilterBlockMask { @Override public boolean applyBlock(FilterBlock block) { - int height = image.getRGB(block.getX(), block.getZ()) & 0xFF; + int height = image.getRGB(block.x(), block.z()) & 0xFF; return height == 255 || height > 0 && !white && random.nextInt(256) <= height; } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/block/AbstractSingleFilterBlock.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/block/AbstractSingleFilterBlock.java index 95e50dc76..5d64ead7c 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/block/AbstractSingleFilterBlock.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/filter/block/AbstractSingleFilterBlock.java @@ -83,18 +83,18 @@ public abstract class AbstractSingleFilterBlock extends FilterBlock { @Override public BlockVector3 getMinimumPoint() { - return at(getX(), getY(), getZ()); + return at(x(), y(), z()); } @Override public BlockVector3 getMaximumPoint() { - return at(getX(), getY(), getZ()); + return at(x(), y(), z()); } @Override public > boolean setBlock(int x, int y, int z, T block) throws WorldEditException { - if (x == this.getX() && y == this.getY() && z == this.getZ()) { + if (x == this.x() && y == this.y() && z == this.z()) { setFullBlock(block.toBaseBlock()); return true; } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/EntityInBlockRemovingProcessor.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/EntityInBlockRemovingProcessor.java index 58baf8633..693356a7a 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/EntityInBlockRemovingProcessor.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/EntityInBlockRemovingProcessor.java @@ -30,9 +30,9 @@ public class EntityInBlockRemovingProcessor implements IBatchProcessor { continue; } BlockVector3 pos = tag.getEntityPosition().toBlockPoint(); - int x = pos.getX() & 15; - int y = pos.getY(); - int z = pos.getZ() & 15; + int x = pos.x() & 15; + int y = pos.y(); + int z = pos.z() & 15; if (!set.hasSection(y >> 4)) { continue; } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/lighting/NMSRelighter.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/lighting/NMSRelighter.java index e38df12f5..dbe717e49 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/lighting/NMSRelighter.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/lighting/NMSRelighter.java @@ -273,9 +273,9 @@ public class NMSRelighter implements Relighter { int lightLevel = (int) val[1]; this.computeRemoveBlockLight( - node.getX() - 1, - node.getY(), - node.getZ(), + node.x() - 1, + node.y(), + node.z(), lightLevel, lightRemovalQueue, lightPropagationQueue, @@ -283,20 +283,20 @@ public class NMSRelighter implements Relighter { visited ); this.computeRemoveBlockLight( - node.getX() + 1, - node.getY(), - node.getZ(), + node.x() + 1, + node.y(), + node.z(), lightLevel, lightRemovalQueue, lightPropagationQueue, removalVisited, visited ); - if (node.getY() > minY) { + if (node.y() > minY) { this.computeRemoveBlockLight( - node.getX(), - node.getY() - 1, - node.getZ(), + node.x(), + node.y() - 1, + node.z(), lightLevel, lightRemovalQueue, lightPropagationQueue, @@ -304,11 +304,11 @@ public class NMSRelighter implements Relighter { visited ); } - if (node.getY() < maxY) { + if (node.y() < maxY) { this.computeRemoveBlockLight( - node.getX(), - node.getY() + 1, - node.getZ(), + node.x(), + node.y() + 1, + node.z(), lightLevel, lightRemovalQueue, lightPropagationQueue, @@ -317,9 +317,9 @@ public class NMSRelighter implements Relighter { ); } this.computeRemoveBlockLight( - node.getX(), - node.getY(), - node.getZ() - 1, + node.x(), + node.y(), + node.z() - 1, lightLevel, lightRemovalQueue, lightPropagationQueue, @@ -327,9 +327,9 @@ public class NMSRelighter implements Relighter { visited ); this.computeRemoveBlockLight( - node.getX(), - node.getY(), - node.getZ() + 1, + node.x(), + node.y(), + node.z() + 1, lightLevel, lightRemovalQueue, lightPropagationQueue, @@ -340,27 +340,27 @@ public class NMSRelighter implements Relighter { while (!lightPropagationQueue.isEmpty()) { MutableBlockVector3 node = lightPropagationQueue.poll(); - ChunkHolder iChunk = (ChunkHolder) queue.getOrCreateChunk(node.getX() >> 4, node.getZ() >> 4); + ChunkHolder iChunk = (ChunkHolder) queue.getOrCreateChunk(node.x() >> 4, node.z() >> 4); if (!iChunk.isInit()) { - iChunk.init(queue, node.getX() >> 4, node.getZ() >> 4); + iChunk.init(queue, node.x() >> 4, node.z() >> 4); } - int lightLevel = iChunk.getEmittedLight(node.getX() & 15, node.getY(), node.getZ() & 15); - BlockState state = this.queue.getBlock(node.getX(), node.getY(), node.getZ()); + int lightLevel = iChunk.getEmittedLight(node.x() & 15, node.y(), node.z() & 15); + BlockState state = this.queue.getBlock(node.x(), node.y(), node.z()); String id = state.getBlockType().getId().toLowerCase(Locale.ROOT); if (lightLevel <= 1) { continue; } if (id.contains("slab")) { boolean top = state.getState(slabHalf).equalsIgnoreCase("top"); - computeSlab(node.getX(), node.getY(), node.getZ(), lightLevel, lightPropagationQueue, visited, top); + computeSlab(node.x(), node.y(), node.z(), lightLevel, lightPropagationQueue, visited, top); } else if (id.contains("stair")) { boolean top = state.getState(stairHalf).equalsIgnoreCase("top"); Direction direction = getStairDir(state); String shape = getStairShape(state); computeStair( - node.getX(), - node.getY(), - node.getZ(), + node.x(), + node.y(), + node.z(), lightLevel, lightPropagationQueue, visited, @@ -369,7 +369,7 @@ public class NMSRelighter implements Relighter { shape ); } else { - computeNormal(node.getX(), node.getY(), node.getZ(), lightLevel, lightPropagationQueue, visited); + computeNormal(node.x(), node.y(), node.z(), lightLevel, lightPropagationQueue, visited); } } } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/transform/OffsetTransform.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/transform/OffsetTransform.java index a8ade6df1..c2536deca 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/transform/OffsetTransform.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/transform/OffsetTransform.java @@ -30,9 +30,9 @@ public class OffsetTransform extends ResettableExtent { @Override public boolean setBiome(BlockVector3 location, BiomeType biome) { - int x = location.getX() + dx; - int y = location.getX() + dy; - int z = location.getX() + dz; + int x = location.x() + dx; + int y = location.x() + dy; + int z = location.x() + dz; if (!getExtent().contains(x, y, z)) { return false; } @@ -53,9 +53,9 @@ public class OffsetTransform extends ResettableExtent { @Override public > boolean setBlock(BlockVector3 location, T block) throws WorldEditException { - int x = location.getX() + dx; - int y = location.getX() + dy; - int z = location.getX() + dz; + int x = location.x() + dx; + int y = location.x() + dy; + int z = location.x() + dz; if (!getExtent().contains(x, y, z)) { return false; } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/transform/RandomOffsetTransform.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/transform/RandomOffsetTransform.java index 268255bf2..4ad3189c7 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/transform/RandomOffsetTransform.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/transform/RandomOffsetTransform.java @@ -34,9 +34,9 @@ public class RandomOffsetTransform extends ResettableExtent { @Override public boolean setBiome(BlockVector3 position, BiomeType biome) { - int x = position.getBlockX() + random.nextInt(1 + (dx << 1)) - dx; - int y = position.getBlockY() + random.nextInt(1 + (dy << 1)) - dy; - int z = position.getBlockZ() + random.nextInt(1 + (dz << 1)) - dz; + int x = position.x() + random.nextInt(1 + (dx << 1)) - dx; + int y = position.y() + random.nextInt(1 + (dy << 1)) - dy; + int z = position.z() + random.nextInt(1 + (dz << 1)) - dz; if (!getExtent().contains(x, y, z)) { return false; } @@ -57,9 +57,9 @@ public class RandomOffsetTransform extends ResettableExtent { @Override public > boolean setBlock(BlockVector3 pos, T block) throws WorldEditException { - int x = pos.getBlockX() + random.nextInt(1 + (dx << 1)) - dx; - int y = pos.getBlockY() + random.nextInt(1 + (dy << 1)) - dy; - int z = pos.getBlockZ() + random.nextInt(1 + (dz << 1)) - dz; + int x = pos.x() + random.nextInt(1 + (dx << 1)) - dx; + int y = pos.y() + random.nextInt(1 + (dy << 1)) - dy; + int z = pos.z() + random.nextInt(1 + (dz << 1)) - dz; if (!getExtent().contains(x, y, z)) { return false; } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/transform/ScaleTransform.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/transform/ScaleTransform.java index 29af87055..c81d123df 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/transform/ScaleTransform.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/transform/ScaleTransform.java @@ -55,9 +55,9 @@ public class ScaleTransform extends ResettableExtent { if (min == null) { min = pos; } - mutable.mutX(min.getX() + (pos.getX() - min.getX()) * dx); - mutable.mutY(min.getY() + (pos.getY() - min.getY()) * dy); - mutable.mutZ(min.getZ() + (pos.getZ() - min.getZ()) * dz); + mutable.mutX(min.x() + (pos.x() - min.x()) * dx); + mutable.mutY(min.y() + (pos.y() - min.y()) * dy); + mutable.mutZ(min.z() + (pos.z() - min.z()) * dz); return new MutableVector3(mutable); } @@ -65,9 +65,9 @@ public class ScaleTransform extends ResettableExtent { if (min == null) { min = BlockVector3.at(x, y, z); } - mutable.mutX(min.getX() + (x - min.getX()) * dx); - mutable.mutY(min.getY() + (y - min.getY()) * dy); - mutable.mutZ(min.getZ() + (z - min.getZ()) * dz); + mutable.mutX(min.x() + (x - min.x()) * dx); + mutable.mutY(min.y() + (y - min.y()) * dy); + mutable.mutZ(min.z() + (z - min.z()) * dz); return new MutableVector3(mutable); } @@ -77,15 +77,15 @@ public class ScaleTransform extends ResettableExtent { boolean result = false; MutableVector3 vector3 = getPos(location); MutableBlockVector3 pos = new MutableBlockVector3(); - double sx = vector3.getX(); - double sy = vector3.getY(); - double sz = vector3.getZ(); + double sx = vector3.x(); + double sy = vector3.y(); + double sz = vector3.z(); double ex = sx + dx; double ey = Math.max(minY, Math.min(maxy, sy + dy)); double ez = sz + dz; - for (pos.mutY(sy); pos.getY() < ey; pos.mutY(pos.getY() + 1)) { - for (pos.mutZ(sz); pos.getZ() < ez; pos.mutZ(pos.getZ() + 1)) { - for (pos.mutX(sx); pos.getX() < ex; pos.mutX(pos.getX() + 1)) { + for (pos.mutY(sy); pos.y() < ey; pos.mutY(pos.y() + 1)) { + for (pos.mutZ(sz); pos.z() < ez; pos.mutZ(pos.z() + 1)) { + for (pos.mutX(sx); pos.x() < ex; pos.mutX(pos.x() + 1)) { if (!getExtent().contains(pos)) { continue; } @@ -101,15 +101,15 @@ public class ScaleTransform extends ResettableExtent { boolean result = false; MutableVector3 vector3 = getPos(position); MutableBlockVector3 pos = new MutableBlockVector3(); - double sx = vector3.getX(); - double sy = vector3.getY(); - double sz = vector3.getZ(); + double sx = vector3.x(); + double sy = vector3.y(); + double sz = vector3.z(); double ex = sx + dx; double ey = Math.max(minY, Math.min(maxy, sy + dy)); double ez = sz + dz; - for (pos.mutY(sy); pos.getY() < ey; pos.mutY(pos.getY() + 1)) { - for (pos.mutZ(sz); pos.getZ() < ez; pos.mutZ(pos.getZ() + 1)) { - for (pos.mutX(sx); pos.getX() < ex; pos.mutX(pos.getX() + 1)) { + for (pos.mutY(sy); pos.y() < ey; pos.mutY(pos.y() + 1)) { + for (pos.mutZ(sz); pos.z() < ez; pos.mutZ(pos.z() + 1)) { + for (pos.mutX(sx); pos.x() < ex; pos.mutX(pos.x() + 1)) { if (!getExtent().contains(pos)) { continue; } @@ -126,15 +126,15 @@ public class ScaleTransform extends ResettableExtent { boolean result = false; MutableVector3 vector3 = getPos(x1, y1, z1); MutableBlockVector3 pos = new MutableBlockVector3(); - double sx = vector3.getX(); - double sy = vector3.getY(); - double sz = vector3.getZ(); - double ex = vector3.getX() + dx; + double sx = vector3.x(); + double sy = vector3.y(); + double sz = vector3.z(); + double ex = vector3.x() + dx; double ey = Math.min(maxy, sy + dy); - double ez = vector3.getZ() + dz; - for (pos.mutY(sy); pos.getY() < ey; pos.mutY(pos.getY() + 1)) { - for (pos.mutZ(sz); pos.getZ() < ez; pos.mutZ(pos.getZ() + 1)) { - for (pos.mutX(sx); pos.getX() < ex; pos.mutX(pos.getX() + 1)) { + double ez = vector3.z() + dz; + for (pos.mutY(sy); pos.y() < ey; pos.mutY(pos.y() + 1)) { + for (pos.mutZ(sz); pos.z() < ez; pos.mutZ(pos.z() + 1)) { + for (pos.mutX(sx); pos.x() < ex; pos.mutX(pos.x() + 1)) { if (!getExtent().contains(pos)) { continue; } @@ -150,15 +150,15 @@ public class ScaleTransform extends ResettableExtent { boolean result = false; MutableVector3 vector3 = getPos(x1, y1, z1); MutableBlockVector3 pos = new MutableBlockVector3(); - double sx = vector3.getX(); - double sy = vector3.getY(); - double sz = vector3.getZ(); + double sx = vector3.x(); + double sy = vector3.y(); + double sz = vector3.z(); double ex = sx + dx; double ey = Math.max(minY, Math.min(maxy, sy + dy)); double ez = sz + dz; - for (pos.mutY(sy); pos.getY() < ey; pos.mutY(pos.getY() + 1)) { - for (pos.mutZ(sz); pos.getZ() < ez; pos.mutZ(pos.getZ() + 1)) { - for (pos.mutX(sx); pos.getX() < ex; pos.mutX(pos.getX() + 1)) { + for (pos.mutY(sy); pos.y() < ey; pos.mutY(pos.y() + 1)) { + for (pos.mutZ(sz); pos.z() < ez; pos.mutZ(pos.z() + 1)) { + for (pos.mutX(sx); pos.x() < ex; pos.mutX(pos.x() + 1)) { if (!getExtent().contains(pos)) { continue; } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/transform/SelectTransform.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/transform/SelectTransform.java index 57f77b2fe..b3be0a43a 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/transform/SelectTransform.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/transform/SelectTransform.java @@ -27,11 +27,11 @@ public abstract class SelectTransform extends ResettableExtent { public abstract AbstractDelegateExtent getExtent(int x, int z); public Extent getExtent(BlockVector3 pos) { - return getExtent(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ()); + return getExtent(pos.x(), pos.y(), pos.z()); } public Extent getExtent(BlockVector2 pos) { - return getExtent(pos.getBlockX(), pos.getBlockZ()); + return getExtent(pos.x(), pos.z()); } @Override diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/SurfaceRegionFunction.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/SurfaceRegionFunction.java index 5f946c933..a6b9ace56 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/SurfaceRegionFunction.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/SurfaceRegionFunction.java @@ -26,8 +26,8 @@ public class SurfaceRegionFunction implements FlatRegionFunction { @Override public boolean apply(BlockVector2 position) throws WorldEditException { - int x = position.getBlockX(); - int z = position.getBlockZ(); + int x = position.x(); + int z = position.z(); int layer = extent.getNearestSurfaceTerrainBlock(x, z, lastY, minY, maxY, false); if (layer != -1) { lastY = layer; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/block/BiomeCopy.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/block/BiomeCopy.java index 3926c19a6..457fff477 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/block/BiomeCopy.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/block/BiomeCopy.java @@ -21,11 +21,11 @@ public class BiomeCopy implements RegionFunction { @Override public boolean apply(BlockVector3 position) throws WorldEditException { - int x = position.getBlockX(); - int y = position.getBlockY(); - int z = position.getBlockZ(); - if (x != mutableVector.getBlockX() || z != mutableVector.getBlockZ() || y != mutableVector - .getBlockY()) { + int x = position.x(); + int y = position.y(); + int z = position.z(); + if (x != mutableVector.x() || z != mutableVector.z() || y != mutableVector + .y()) { mutableVector.setComponents(x, y, z); return destination.setBiome(mutableVector, source.getBiome(mutableVector)); } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/generator/CavesGen.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/generator/CavesGen.java index 28bfa0a4c..b9a403f27 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/generator/CavesGen.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/generator/CavesGen.java @@ -72,8 +72,8 @@ public class CavesGen extends GenBase { int maxAngle, double paramDouble4 ) throws WorldEditException { - int bx = chunkPos.getBlockX() << 4; - int bz = chunkPos.getBlockZ() << 4; + int bx = chunkPos.x() << 4; + int bz = chunkPos.z() << 4; double real_x = bx + 7; double real_z = bz + 7; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/generator/GenBase.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/generator/GenBase.java index af1a4e66e..f0637d127 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/generator/GenBase.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/generator/GenBase.java @@ -26,8 +26,8 @@ public abstract class GenBase { public void generate(BlockVector2 chunkPos, Extent chunk) throws WorldEditException { int i = this.checkAreaSize; - int chunkX = chunkPos.getBlockX(); - int chunkZ = chunkPos.getBlockZ(); + int chunkX = chunkPos.x(); + int chunkZ = chunkPos.z(); for (int x = chunkX - i; x <= chunkX + i; x++) { for (int z = chunkZ - i; z <= chunkZ + i; z++) { generateChunk(x, z, chunkPos, chunk); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/generator/SchemGen.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/generator/SchemGen.java index 1ced63f19..250914c05 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/generator/SchemGen.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/generator/SchemGen.java @@ -36,7 +36,7 @@ public class SchemGen implements Resource { int y = extent.getNearestSurfaceTerrainBlock( x, z, - mutable.getBlockY(), + mutable.y(), this.extent.getMinY(), this.extent.getMaxY(), Integer.MIN_VALUE, diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/AdjacentAnyMask.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/AdjacentAnyMask.java index 39bb0c41d..956daf67d 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/AdjacentAnyMask.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/AdjacentAnyMask.java @@ -44,9 +44,9 @@ public class AdjacentAnyMask extends AbstractMask implements ResettableMask { } public BlockVector3 direction(BlockVector3 v) { - int x = v.getBlockX(); - int y = v.getBlockY(); - int z = v.getBlockZ(); + int x = v.x(); + int y = v.y(); + int z = v.z(); if (mask.test(mutable.setComponents(x + 1, y, z))) { return mutable.setComponents(1, 0, 0); } else if (mask.test(mutable.setComponents(x - 1, y, z))) { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/AdjacentMask.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/AdjacentMask.java index 23065ea7b..981492e0e 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/AdjacentMask.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/AdjacentMask.java @@ -22,9 +22,9 @@ public class AdjacentMask extends AbstractMask { @Override public boolean test(BlockVector3 bv) { vector.setComponents(bv); - double x = bv.getX(); - double y = bv.getY(); - double z = bv.getZ(); + double x = bv.x(); + double y = bv.y(); + double z = bv.z(); vector.mutX(x + 1); int count = 0; if (mask.test(vector) && ++count == min && max >= 8) { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/AngleMask.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/AngleMask.java index 52de762ae..01cf15708 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/AngleMask.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/AngleMask.java @@ -127,9 +127,9 @@ public class AngleMask extends AbstractExtentMask implements ResettableMask { } private boolean adjacentAir(Extent extent, MutableBlockVector3 mutable) { - int x = mutable.getBlockX(); - int y = mutable.getBlockY(); - int z = mutable.getBlockZ(); + int x = mutable.x(); + int y = mutable.y(); + int z = mutable.z(); if (!mask.test(extent, mutable.setComponents(x + 1, y, z))) { return true; } @@ -154,23 +154,23 @@ public class AngleMask extends AbstractExtentMask implements ResettableMask { if (!mask.test(vector)) { return false; } - int y = vector.getBlockY(); + int y = vector.y(); if (overlay) { MutableBlockVector3 mutable = new MutableBlockVector3(vector); if (y < maxY && !adjacentAir(null, mutable)) { return false; } } - int x = vector.getBlockX(); - int z = vector.getBlockZ(); + int x = vector.x(); + int z = vector.z(); return testSlope(getExtent(), x, y, z); } @Override public boolean test(final Extent extent, final BlockVector3 vector) { - int x = vector.getBlockX(); - int y = vector.getBlockY(); - int z = vector.getBlockZ(); + int x = vector.x(); + int y = vector.y(); + int z = vector.z(); if ((lastX == (lastX = x) & lastZ == (lastZ = z))) { int height = getHeight(extent, x, y, z); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/CachedMask.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/CachedMask.java index 27e4b9961..5bb757eb2 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/CachedMask.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/CachedMask.java @@ -60,9 +60,9 @@ public class CachedMask extends AbstractDelegateMask implements ResettableMask { @Override public boolean test(BlockVector3 vector) { - int x = vector.getX(); - int y = vector.getY(); - int z = vector.getZ(); + int x = vector.x(); + int y = vector.y(); + int z = vector.z(); try { boolean check = cache_checked.add(x, y, z); if (!check) { @@ -88,9 +88,9 @@ public class CachedMask extends AbstractDelegateMask implements ResettableMask { if (!hasExtent || !(extent instanceof AbstractExtentMask)) { return test(vector); } - int x = vector.getX(); - int y = vector.getY(); - int z = vector.getZ(); + int x = vector.x(); + int y = vector.y(); + int z = vector.z(); AbstractExtentMask mask = (AbstractExtentMask) getMask(); try { boolean check = cache_checked.add(x, y, z); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/ImageBrushMask.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/ImageBrushMask.java index ec31337de..d8ff64a76 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/ImageBrushMask.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/ImageBrushMask.java @@ -62,17 +62,17 @@ public class ImageBrushMask extends AbstractExtentMask { @Override public boolean test(BlockVector3 vector) { if (solid.test(vector)) { - int dx = vector.getBlockX() - center.getBlockX(); - int dy = vector.getBlockY() - center.getBlockY(); - int dz = vector.getBlockZ() - center.getBlockZ(); + int dx = vector.x() - center.x(); + int dy = vector.y() - center.y(); + int dz = vector.z() - center.z(); Vector3 pos1 = transform.apply(mutable.setComponents(dx - 0.5, dy - 0.5, dz - 0.5)); - int x1 = (int) (pos1.getX() * scale + centerImageX); - int z1 = (int) (pos1.getZ() * scale + centerImageZ); + int x1 = (int) (pos1.x() * scale + centerImageX); + int z1 = (int) (pos1.z() * scale + centerImageZ); Vector3 pos2 = transform.apply(mutable.setComponents(dx + 0.5, dy + 0.5, dz + 0.5)); - int x2 = (int) (pos2.getX() * scale + centerImageX); - int z2 = (int) (pos2.getZ() * scale + centerImageZ); + int x2 = (int) (pos2.x() * scale + centerImageX); + int z2 = (int) (pos2.z() * scale + centerImageZ); if (x2 < x1) { int tmp = x1; x1 = x2; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/LayerBrushMask.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/LayerBrushMask.java index 825039ed0..7f30ab64a 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/LayerBrushMask.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/LayerBrushMask.java @@ -40,20 +40,20 @@ public class LayerBrushMask extends AbstractExtentMask { BlockState previous2 = layers[depth - 2]; for (BlockVector3 dir : BreadthFirstSearch.DEFAULT_DIRECTIONS) { mutable.setComponents( - pos.getBlockX() + dir.getBlockX(), - pos.getBlockY() + dir.getBlockY(), - pos.getBlockZ() + dir.getBlockZ() + pos.x() + dir.x(), + pos.y() + dir.y(), + pos.z() + dir.z() ); if (visitor.isVisited(mutable) && editSession.getBlock( - mutable.getBlockX(), - mutable.getBlockY(), - mutable.getBlockZ() + mutable.x(), + mutable.y(), + mutable.z() ) == previous) { - mutable.setComponents(pos.getBlockX() + dir.getBlockX() * 2, pos.getBlockY() + dir.getBlockY() * 2, - pos.getBlockZ() + dir.getBlockZ() * 2 + mutable.setComponents(pos.x() + dir.x() * 2, pos.y() + dir.y() * 2, + pos.z() + dir.z() * 2 ); if (visitor.isVisited(mutable) - && editSession.getBlock(mutable.getBlockX(), mutable.getBlockY(), mutable.getBlockZ()) == previous2) { + && editSession.getBlock(mutable.x(), mutable.y(), mutable.z()) == previous2) { found = true; break; } else { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/PlaneMask.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/PlaneMask.java index 6b8b1e4a1..5de393940 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/PlaneMask.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/PlaneMask.java @@ -15,9 +15,9 @@ public class PlaneMask extends AbstractMask implements ResettableMask { public boolean test(BlockVector3 vector) { switch (mode) { case -1: - originX = vector.getBlockX(); - originY = vector.getBlockY(); - originZ = vector.getBlockZ(); + originX = vector.x(); + originY = vector.y(); + originZ = vector.z(); mode = 0; return true; case 0: @@ -25,13 +25,13 @@ public class PlaneMask extends AbstractMask implements ResettableMask { case 2: case 4: int original = mode; - if (originX != vector.getBlockX()) { + if (originX != vector.x()) { mode &= 1; } - if (originY != vector.getBlockY()) { + if (originY != vector.y()) { mode &= 2; } - if (originZ != vector.getBlockZ()) { + if (originZ != vector.z()) { mode &= 4; } if (Integer.bitCount(mode) >= 3) { @@ -39,13 +39,13 @@ public class PlaneMask extends AbstractMask implements ResettableMask { return false; } default: - if (originX != vector.getBlockX() && (mode & 1) == 0) { + if (originX != vector.x() && (mode & 1) == 0) { return false; } - if (originZ != vector.getBlockZ() && (mode & 4) == 0) { + if (originZ != vector.z() && (mode & 4) == 0) { return false; } - return originY == vector.getBlockY() || (mode & 2) != 0; + return originY == vector.y() || (mode & 2) != 0; } } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/RadiusMask.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/RadiusMask.java index b99e56ddc..c8893ae79 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/RadiusMask.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/RadiusMask.java @@ -30,17 +30,17 @@ public class RadiusMask extends AbstractMask implements ResettableMask { if (pos == null) { pos = to.toImmutable(); } - int dx = pos.getBlockX() - to.getBlockX(); + int dx = pos.x() - to.x(); int d = dx * dx; if (d > maxSqr) { return false; } - int dz = pos.getBlockZ() - to.getBlockZ(); + int dz = pos.z() - to.z(); d += dz * dz; if (d > maxSqr) { return false; } - int dy = pos.getBlockY() - to.getBlockY(); + int dy = pos.y() - to.y(); d += dy * dy; return d >= minSqr && d <= maxSqr; } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/SimplexMask.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/SimplexMask.java index d337cd61a..a56238918 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/SimplexMask.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/SimplexMask.java @@ -19,7 +19,7 @@ public class SimplexMask extends AbstractMask { @Override public boolean test(BlockVector3 vector) { - double value = SimplexNoise.noise(vector.getBlockX() * scale, vector.getBlockY() * scale, vector.getBlockZ() * scale); + double value = SimplexNoise.noise(vector.x() * scale, vector.y() * scale, vector.z() * scale); return value >= min && value <= max; } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/StencilBrushMask.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/StencilBrushMask.java index 3100f6a9e..25ee249d8 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/StencilBrushMask.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/StencilBrushMask.java @@ -64,13 +64,13 @@ public class StencilBrushMask extends AbstractExtentMask { @Override public boolean test(BlockVector3 vector) { if (solid.test(vector)) { - int dx = vector.getBlockX() - center.getBlockX(); - int dy = vector.getBlockY() - center.getBlockY(); - int dz = vector.getBlockZ() - center.getBlockZ(); + int dx = vector.x() - center.x(); + int dy = vector.y() - center.y(); + int dz = vector.z() - center.z(); Vector3 srcPos = transform.apply(mutable.setComponents(dx, dy, dz)); - dx = MathMan.roundInt(srcPos.getX()); - dz = MathMan.roundInt(srcPos.getZ()); + dx = MathMan.roundInt(srcPos.x()); + dz = MathMan.roundInt(srcPos.z()); int distance = dx * dx + dz * dz; if (distance > size2 || Math.abs(dx) > 256 || Math.abs(dz) > 256) { @@ -83,7 +83,7 @@ public class StencilBrushMask extends AbstractExtentMask { return true; } if (val >= 255 || ThreadLocalRandom.current().nextInt(maxY) < val) { - editSession.setBlock(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ(), pattern); + editSession.setBlock(vector.x(), vector.y(), vector.z(), pattern); } return true; } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/SurfaceAngleMask.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/SurfaceAngleMask.java index ce42a2d7e..15b347dbc 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/SurfaceAngleMask.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/SurfaceAngleMask.java @@ -24,7 +24,7 @@ public class SurfaceAngleMask extends AbstractExtentMask { @Override public boolean test(BlockVector3 vector) { if (!vector.getBlock(getExtent()).isAir() && nextToAir(vector)) { - double angle = 1 - getAverageAirDirection(vector.toVector3(), size).getY(); + double angle = 1 - getAverageAirDirection(vector.toVector3(), size).y(); return (angle >= (min / 90.0) && angle <= (max / 90.0)); } return false; @@ -33,7 +33,7 @@ public class SurfaceAngleMask extends AbstractExtentMask { @Override public boolean test(Extent extent, BlockVector3 vector) { if (!vector.getBlock(getExtent()).isAir() && nextToAir(vector)) { - double angle = 1 - getAverageAirDirection(vector.toVector3(), size).getY(); + double angle = 1 - getAverageAirDirection(vector.toVector3(), size).y(); return (angle >= (min / 90.0) && angle <= (max / 90.0)); } return false; @@ -44,7 +44,7 @@ public class SurfaceAngleMask extends AbstractExtentMask { for (int i = -size; i <= size; i++) { for (int j = -size; j <= size; j++) { for (int k = -size; k <= size; k++) { - Vector3 block = Vector3.at(currentLocation.getX(), currentLocation.getY(), currentLocation.getZ()).add( + Vector3 block = Vector3.at(currentLocation.x(), currentLocation.y(), currentLocation.z()).add( 0.5, 0.5, 0.5 @@ -65,13 +65,13 @@ public class SurfaceAngleMask extends AbstractExtentMask { double y = 0.0; double z = 0.0; for (Vector3 vector3 : airDirections) { - x += vector3.getX(); - y += vector3.getY(); - z += vector3.getZ(); + x += vector3.x(); + y += vector3.y(); + z += vector3.z(); } Vector3 averageAirDirection = Vector3.at(x / airDirections.size(), y / airDirections.size(), z / airDirections.size()); - return (Double.isNaN(averageAirDirection.getY()) ? Vector3.ZERO : averageAirDirection.normalize()); + return (Double.isNaN(averageAirDirection.y()) ? Vector3.ZERO : averageAirDirection.normalize()); } @Override diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/WallMakeMask.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/WallMakeMask.java index 4246f8a82..9d7b7a729 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/WallMakeMask.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/WallMakeMask.java @@ -14,8 +14,8 @@ public class WallMakeMask implements Mask { @Override public boolean test(BlockVector3 position) { - int x = position.getBlockX(); - int z = position.getBlockZ(); + int x = position.x(); + int z = position.z(); return !region.contains(x, z + 1) || !region.contains(x, z - 1) || !region.contains(x + 1, z) || !region.contains( x - 1, z diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/WallMask.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/WallMask.java index 40a323e51..eee5ab286 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/WallMask.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/WallMask.java @@ -23,9 +23,9 @@ public class WallMask extends AbstractMask { public boolean test(BlockVector3 bv) { vector.setComponents(bv); int count = 0; - double x = vector.getX(); - double y = vector.getY(); - double z = vector.getZ(); + double x = vector.x(); + double y = vector.y(); + double z = vector.z(); vector.mutX(x + 1); if (mask.test(vector) && ++count == min && max >= 8) { vector.mutX(x); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/XAxisMask.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/XAxisMask.java index 7531d1465..82c0eca02 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/XAxisMask.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/XAxisMask.java @@ -16,9 +16,9 @@ public class XAxisMask extends AbstractMask implements ResettableMask { @Override public boolean test(BlockVector3 vector) { if (layer == -1) { - layer = vector.getBlockX(); + layer = vector.x(); } - return vector.getBlockX() == layer; + return vector.x() == layer; } @Override diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/YAxisMask.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/YAxisMask.java index ee852e70e..15ee08192 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/YAxisMask.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/YAxisMask.java @@ -14,9 +14,9 @@ public class YAxisMask extends AbstractMask implements ResettableMask { @Override public boolean test(BlockVector3 vector) { if (layer == -1) { - layer = vector.getBlockY(); + layer = vector.y(); } - return vector.getBlockY() == layer; + return vector.y() == layer; } @Override diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/ZAxisMask.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/ZAxisMask.java index 269fc5dd8..648b712d2 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/ZAxisMask.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/mask/ZAxisMask.java @@ -14,9 +14,9 @@ public class ZAxisMask extends AbstractMask implements ResettableMask { @Override public boolean test(BlockVector3 vector) { if (layer == -1) { - layer = vector.getBlockZ(); + layer = vector.z(); } - return vector.getBlockZ() == layer; + return vector.z() == layer; } @Override diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/AngleColorPattern.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/AngleColorPattern.java index a13061951..9f2becf76 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/AngleColorPattern.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/AngleColorPattern.java @@ -42,9 +42,9 @@ public class AngleColorPattern extends AnglePattern { public > int getSlope(T block, BlockVector3 vector, Extent extent) { int slope = super.getSlope(block, vector, extent); if (slope != -1) { - int x = vector.getBlockX(); - int y = vector.getBlockY(); - int z = vector.getBlockZ(); + int x = vector.x(); + int y = vector.y(); + int z = vector.z(); int height = extent.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY); if (height > minY) { BlockState below = extent.getBlock(x, height - 1, z); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/AnglePattern.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/AnglePattern.java index 224d64434..caebfd6ff 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/AnglePattern.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/AnglePattern.java @@ -31,9 +31,9 @@ public abstract class AnglePattern extends AbstractPattern { } public > int getSlope(T block, BlockVector3 vector, Extent extent) { - int x = vector.getBlockX(); - int y = vector.getBlockY(); - int z = vector.getBlockZ(); + int x = vector.x(); + int y = vector.y(); + int z = vector.z(); if (!block.getBlockType().getMaterial().isMovementBlocker()) { return -1; } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/BufferedPattern2D.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/BufferedPattern2D.java index 99414ca25..483629af4 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/BufferedPattern2D.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/BufferedPattern2D.java @@ -33,7 +33,7 @@ public class BufferedPattern2D extends BufferedPattern { @Override public boolean set(BlockVector3 pos) { - return set.add(pos.getBlockX(), 0, pos.getBlockY()); + return set.add(pos.x(), 0, pos.y()); } } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/ExpressionPattern.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/ExpressionPattern.java index 638872ea8..9276acb40 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/ExpressionPattern.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/ExpressionPattern.java @@ -50,7 +50,7 @@ public class ExpressionPattern extends AbstractPattern { if (expression.getEnvironment() instanceof WorldEditExpressionEnvironment) { ((WorldEditExpressionEnvironment) expression.getEnvironment()).setCurrentBlock(vector.toVector3()); } - double combined = expression.evaluate(vector.getX(), vector.getY(), vector.getZ()); + double combined = expression.evaluate(vector.x(), vector.y(), vector.z()); return BlockState.getFromOrdinal((int) combined).toBaseBlock(); } catch (EvaluationException e) { e.printStackTrace(); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/Linear2DBlockPattern.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/Linear2DBlockPattern.java index 13df9ca6f..d30206534 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/Linear2DBlockPattern.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/Linear2DBlockPattern.java @@ -37,7 +37,7 @@ public class Linear2DBlockPattern extends AbstractPattern { @Override public BaseBlock applyBlock(BlockVector3 position) { - int index = (position.getBlockX() / this.xScale + position.getBlockZ() / this.zScale) % patternsArray.length; + int index = (position.x() / this.xScale + position.z() / this.zScale) % patternsArray.length; if (index < 0) { index += patternsArray.length; } @@ -46,8 +46,8 @@ public class Linear2DBlockPattern extends AbstractPattern { @Override public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException { - int index = (floorDiv(get.getBlockX(), this.xScale) - + floorDiv(get.getBlockZ(), this.zScale)) % patternsArray.length; + int index = (floorDiv(get.x(), this.xScale) + + floorDiv(get.z(), this.zScale)) % patternsArray.length; if (index < 0) { index += patternsArray.length; } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/Linear3DBlockPattern.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/Linear3DBlockPattern.java index 6c9d039d0..de6e3257b 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/Linear3DBlockPattern.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/Linear3DBlockPattern.java @@ -40,8 +40,8 @@ public class Linear3DBlockPattern extends AbstractPattern { @Override public BaseBlock applyBlock(BlockVector3 position) { - int index = (position.getBlockX() / this.xScale - + position.getBlockY() / this.yScale + position.getBlockZ() / this.zScale) % patternsArray.length; + int index = (position.x() / this.xScale + + position.y() / this.yScale + position.z() / this.zScale) % patternsArray.length; if (index < 0) { index += patternsArray.length; } @@ -50,8 +50,8 @@ public class Linear3DBlockPattern extends AbstractPattern { @Override public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException { - int index = (floorDiv(get.getBlockX(), this.xScale) - + floorDiv(get.getBlockY(), this.yScale) + floorDiv(get.getBlockZ(), this.zScale)) % patternsArray.length; + int index = (floorDiv(get.x(), this.xScale) + + floorDiv(get.y(), this.yScale) + floorDiv(get.z(), this.zScale)) % patternsArray.length; if (index < 0) { index += patternsArray.length; } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/NoXPattern.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/NoXPattern.java index b4e9aac37..2d4da9528 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/NoXPattern.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/NoXPattern.java @@ -24,15 +24,15 @@ public class NoXPattern extends AbstractPattern { @Override public BaseBlock applyBlock(BlockVector3 pos) { - mutable.mutY(pos.getY()); - mutable.mutZ(pos.getZ()); + mutable.mutY(pos.y()); + mutable.mutZ(pos.z()); return pattern.applyBlock(mutable); } @Override public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException { - mutable.mutY(get.getY()); - mutable.mutZ(get.getZ()); + mutable.mutY(get.y()); + mutable.mutZ(get.z()); return pattern.apply(extent, mutable, set); } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/NoYPattern.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/NoYPattern.java index 2fefaedfc..12ef8174d 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/NoYPattern.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/NoYPattern.java @@ -24,15 +24,15 @@ public class NoYPattern extends AbstractPattern { @Override public BaseBlock applyBlock(BlockVector3 pos) { - mutable.mutX(pos.getX()); - mutable.mutZ(pos.getZ()); + mutable.mutX(pos.x()); + mutable.mutZ(pos.z()); return pattern.applyBlock(mutable); } @Override public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException { - mutable.mutX(get.getX()); - mutable.mutZ(get.getZ()); + mutable.mutX(get.x()); + mutable.mutZ(get.z()); return pattern.apply(extent, mutable, set); } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/NoZPattern.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/NoZPattern.java index 8c100c5e3..f4d2a47ed 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/NoZPattern.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/NoZPattern.java @@ -1,7 +1,6 @@ package com.fastasyncworldedit.core.function.pattern; import com.fastasyncworldedit.core.math.MutableBlockVector3; -import com.fastasyncworldedit.core.queue.Filter; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.pattern.AbstractPattern; @@ -25,15 +24,15 @@ public class NoZPattern extends AbstractPattern { @Override public BaseBlock applyBlock(BlockVector3 pos) { - mutable.mutX(pos.getX()); - mutable.mutY(pos.getY()); + mutable.mutX(pos.x()); + mutable.mutY(pos.y()); return pattern.applyBlock(mutable); } @Override public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException { - mutable.mutX(get.getX()); - mutable.mutY(get.getY()); + mutable.mutX(get.x()); + mutable.mutY(get.y()); return pattern.apply(extent, mutable, set); } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/OffsetPattern.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/OffsetPattern.java index 9a5ca2ceb..5866766ef 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/OffsetPattern.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/OffsetPattern.java @@ -40,10 +40,10 @@ public class OffsetPattern extends AbstractPattern { @Override public BaseBlock applyBlock(BlockVector3 position) { - mutable.mutX(position.getX() + dx); - mutable.mutY(position.getY() + dy); - mutable.mutZ(position.getZ() + dz); - if (mutable.getY() < minY || mutable.getY() > maxY) { + mutable.mutX(position.x() + dx); + mutable.mutY(position.y() + dy); + mutable.mutZ(position.z() + dz); + if (mutable.y() < minY || mutable.y() > maxY) { return BlockTypes.AIR.getDefaultState().toBaseBlock(); } return pattern.applyBlock(mutable); @@ -51,10 +51,10 @@ public class OffsetPattern extends AbstractPattern { @Override public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException { - mutable.mutX(get.getX() + dx); - mutable.mutY(get.getY() + dy); - mutable.mutZ(get.getZ() + dz); - if (mutable.getY() < extent.getMinY() || mutable.getY() > extent.getMaxY()) { + mutable.mutX(get.x() + dx); + mutable.mutY(get.y() + dy); + mutable.mutZ(get.z() + dz); + if (mutable.y() < extent.getMinY() || mutable.y() > extent.getMaxY()) { return false; } return pattern.apply(extent, get, mutable); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/RandomOffsetPattern.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/RandomOffsetPattern.java index c68bb24b1..5dc012f66 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/RandomOffsetPattern.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/RandomOffsetPattern.java @@ -52,10 +52,10 @@ public class RandomOffsetPattern extends AbstractPattern { @Override public BaseBlock applyBlock(BlockVector3 position) { - mutable.mutX((position.getX() + r.nextInt(dx2) - dx)); - mutable.mutY((position.getY() + r.nextInt(dy2) - dy)); - mutable.mutZ((position.getZ() + r.nextInt(dz2) - dz)); - if (mutable.getY() < minY || mutable.getY() > maxY) { + mutable.mutX((position.x() + r.nextInt(dx2) - dx)); + mutable.mutY((position.y() + r.nextInt(dy2) - dy)); + mutable.mutZ((position.z() + r.nextInt(dz2) - dz)); + if (mutable.y() < minY || mutable.y() > maxY) { return BlockTypes.AIR.getDefaultState().toBaseBlock(); } return pattern.applyBlock(mutable); @@ -63,10 +63,10 @@ public class RandomOffsetPattern extends AbstractPattern { @Override public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException { - mutable.mutX((set.getX() + r.nextInt(dx2) - dx)); - mutable.mutY((set.getY() + r.nextInt(dy2) - dy)); - mutable.mutZ((set.getZ() + r.nextInt(dz2) - dz)); - if (mutable.getY() < extent.getMinY() || mutable.getY() > extent.getMaxY()) { + mutable.mutX((set.x() + r.nextInt(dx2) - dx)); + mutable.mutY((set.y() + r.nextInt(dy2) - dy)); + mutable.mutZ((set.z() + r.nextInt(dz2) - dz)); + if (mutable.y() < extent.getMinY() || mutable.y() > extent.getMaxY()) { return false; } return pattern.apply(extent, get, mutable); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/RelativePattern.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/RelativePattern.java index 541aaa494..22e3a8d0b 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/RelativePattern.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/RelativePattern.java @@ -35,10 +35,10 @@ public class RelativePattern extends AbstractPattern implements ResettablePatter if (origin == null) { origin = pos; } - mutable.mutX(pos.getX() - origin.getX()); - mutable.mutY(pos.getY() - origin.getY()); - mutable.mutZ(pos.getZ() - origin.getZ()); - if (mutable.getY() < minY || mutable.getY() > maxY) { + mutable.mutX(pos.x() - origin.x()); + mutable.mutY(pos.y() - origin.y()); + mutable.mutZ(pos.z() - origin.z()); + if (mutable.y() < minY || mutable.y() > maxY) { return BlockTypes.AIR.getDefaultState().toBaseBlock(); } return pattern.applyBlock(mutable); @@ -49,10 +49,10 @@ public class RelativePattern extends AbstractPattern implements ResettablePatter if (origin == null) { origin = set; } - mutable.mutX(set.getX() - origin.getX()); - mutable.mutY(set.getY() - origin.getY()); - mutable.mutZ(set.getZ() - origin.getZ()); - if (mutable.getY() < extent.getMinY() || mutable.getY() > extent.getMaxY()) { + mutable.mutX(set.x() - origin.x()); + mutable.mutY(set.y() - origin.y()); + mutable.mutZ(set.z() - origin.z()); + if (mutable.y() < extent.getMinY() || mutable.y() > extent.getMaxY()) { return false; } return pattern.apply(extent, get, mutable); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/SolidRandomOffsetPattern.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/SolidRandomOffsetPattern.java index 54ecf6676..698c0f199 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/SolidRandomOffsetPattern.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/SolidRandomOffsetPattern.java @@ -63,13 +63,13 @@ public class SolidRandomOffsetPattern extends AbstractPattern { @Override public BaseBlock applyBlock(BlockVector3 position) { - mutable.mutX(position.getX() + r.nextInt(dx2) - dx); - mutable.mutY(position.getY() + r.nextInt(dy2) - dy); - mutable.mutZ(position.getZ() + r.nextInt(dz2) - dz); - if (mutable.getY() < minY || mutable.getY() > maxY) { + mutable.mutX(position.x() + r.nextInt(dx2) - dx); + mutable.mutY(position.y() + r.nextInt(dy2) - dy); + mutable.mutZ(position.z() + r.nextInt(dz2) - dz); + if (mutable.y() < minY || mutable.y() > maxY) { return BlockTypes.AIR.getDefaultState().toBaseBlock(); } - if (mutable.getY() < minY || mutable.getY() > maxY) { + if (mutable.y() < minY || mutable.y() > maxY) { return BlockTypes.AIR.getDefaultState().toBaseBlock(); } BaseBlock block = pattern.applyBlock(mutable); @@ -81,10 +81,10 @@ public class SolidRandomOffsetPattern extends AbstractPattern { @Override public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException { - mutable.mutX(set.getX() + r.nextInt(dx2) - dx); - mutable.mutY(set.getY() + r.nextInt(dy2) - dy); - mutable.mutZ(set.getZ() + r.nextInt(dz2) - dz); - if (mutable.getY() < extent.getMinY() || mutable.getY() > extent.getMaxY()) { + mutable.mutX(set.x() + r.nextInt(dx2) - dx); + mutable.mutY(set.y() + r.nextInt(dy2) - dy); + mutable.mutZ(set.z() + r.nextInt(dz2) - dz); + if (mutable.y() < extent.getMinY() || mutable.y() > extent.getMaxY()) { return false; } BaseBlock block = pattern.applyBlock(mutable); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/SurfaceRandomOffsetPattern.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/SurfaceRandomOffsetPattern.java index 03e3126be..a7a1a3e2e 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/SurfaceRandomOffsetPattern.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/SurfaceRandomOffsetPattern.java @@ -62,9 +62,9 @@ public class SurfaceRandomOffsetPattern extends AbstractPattern { next = buffer[i]; BlockVector3 dir = BreadthFirstSearch.DIAGONAL_DIRECTIONS[i]; next.setComponents( - cur.getBlockX() + dir.getBlockX(), - cur.getBlockY() + dir.getBlockY(), - cur.getBlockZ() + dir.getBlockZ() + cur.x() + dir.x(), + cur.y() + dir.y(), + cur.z() + dir.z() ); if (allowed(next)) { allowed[index++] = next; @@ -74,7 +74,7 @@ public class SurfaceRandomOffsetPattern extends AbstractPattern { return cur; } next = allowed[ThreadLocalRandom.current().nextInt(index)]; - cur.setComponents(next.getBlockX(), next.getBlockY(), next.getBlockZ()); + cur.setComponents(next.x(), next.y(), next.z()); } return cur; } @@ -85,9 +85,9 @@ public class SurfaceRandomOffsetPattern extends AbstractPattern { if (!block.getBlockType().getMaterial().isMovementBlocker()) { return false; } - int x = v.getBlockX(); - int y = v.getBlockY(); - int z = v.getBlockZ(); + int x = v.x(); + int y = v.y(); + int z = v.z(); v.mutY(y + 1); if (y < maxY && canPassthrough(v)) { v.mutY(y); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/visitor/AboveVisitor.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/visitor/AboveVisitor.java index d2503447b..67a48e2f7 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/visitor/AboveVisitor.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/visitor/AboveVisitor.java @@ -40,7 +40,7 @@ public class AboveVisitor extends RecursiveVisitor { @Override public boolean isVisitable(BlockVector3 from, BlockVector3 to) { - return (from.getBlockY() >= baseY) && super.isVisitable(from, to); + return (from.y() >= baseY) && super.isVisitable(from, to); } } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/visitor/DFSVisitor.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/visitor/DFSVisitor.java index 58b6f0e41..6a84af071 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/visitor/DFSVisitor.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/visitor/DFSVisitor.java @@ -64,13 +64,13 @@ public abstract class DFSVisitor implements Operation { IntTriple[] array = new IntTriple[directions.size()]; for (int i = 0; i < array.length; i++) { BlockVector3 dir = directions.get(i); - array[i] = new IntTriple(dir.getBlockX(), dir.getBlockY(), dir.getBlockZ()); + array[i] = new IntTriple(dir.x(), dir.y(), dir.z()); } return array; } public void visit(final BlockVector3 pos) { - Node node = new Node(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ()); + Node node = new Node(pos.x(), pos.y(), pos.z()); if (!this.hashQueue.contains(node)) { isVisitable(pos, pos); // Ignore this, just to initialize mask on this point queue.addFirst(new NodePair(null, node, 0)); @@ -102,7 +102,7 @@ public abstract class DFSVisitor implements Operation { mutable2.mutY(from.getY() + direction.y()); mutable2.mutZ(from.getZ() + direction.z()); if (isVisitable(mutable, mutable2)) { - Node adjacent = new Node(mutable2.getBlockX(), mutable2.getBlockY(), mutable2.getBlockZ()); + Node adjacent = new Node(mutable2.x(), mutable2.y(), mutable2.z()); if (!adjacent.equals(current.from)) { AtomicInteger adjacentCount = visited.get(adjacent); if (adjacentCount == null) { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/visitor/DirectionalVisitor.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/visitor/DirectionalVisitor.java index b7b14059b..f77b0b66b 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/visitor/DirectionalVisitor.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/visitor/DirectionalVisitor.java @@ -52,22 +52,22 @@ public class DirectionalVisitor extends RecursiveVisitor { @Override public boolean isVisitable(final BlockVector3 from, final BlockVector3 to) { - int dx = to.getBlockX() - from.getBlockX(); - int dz = to.getBlockZ() - from.getBlockZ(); - int dy = to.getBlockY() - from.getBlockY(); + int dx = to.x() - from.x(); + int dz = to.z() - from.z(); + int dy = to.y() - from.y(); if (dx != 0) { - if (dirVec.getBlockX() != 0 && dirVec.getBlockX() != dx) { + if (dirVec.x() != 0 && dirVec.x() != dx) { return false; } } if (dy != 0) { - if (dirVec.getBlockY() != 0 && dirVec.getBlockY() != dy) { + if (dirVec.y() != 0 && dirVec.y() != dy) { return false; } } if (dz != 0) { - if (dirVec.getBlockZ() != 0 && dirVec.getBlockZ() != dz) { + if (dirVec.z() != 0 && dirVec.z() != dz) { return false; } } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/history/RollbackOptimizedHistory.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/history/RollbackOptimizedHistory.java index 1f01f99de..e11fda2b1 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/history/RollbackOptimizedHistory.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/history/RollbackOptimizedHistory.java @@ -84,12 +84,12 @@ public class RollbackOptimizedHistory extends DiskStorageHistory { } public void setDimensions(BlockVector3 pos1, BlockVector3 pos2) { - this.minX = pos1.getBlockX(); - this.minY = pos1.getBlockY(); - this.minZ = pos1.getBlockZ(); - this.maxX = pos2.getBlockX(); - this.maxY = pos2.getBlockY(); - this.maxZ = pos2.getBlockZ(); + this.minX = pos1.x(); + this.minY = pos1.y(); + this.minZ = pos1.z(); + this.maxX = pos2.x(); + this.maxY = pos2.y(); + this.maxZ = pos2.z(); } public void setTime(long time) { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/history/changeset/AbstractChangeSet.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/history/changeset/AbstractChangeSet.java index 4bbe1a109..e5820fd44 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/history/changeset/AbstractChangeSet.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/history/changeset/AbstractChangeSet.java @@ -127,18 +127,18 @@ public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor { if (!tilesFrom.isEmpty()) { for (Map.Entry entry : tilesFrom.entrySet()) { BlockVector3 pos = entry.getKey(); - BlockState fromBlock = get.getBlock(pos.getX() & 15, pos.getY(), pos.getZ() & 15); - BlockState toBlock = set.getBlock(pos.getX() & 15, pos.getY(), pos.getZ() & 15); + BlockState fromBlock = get.getBlock(pos.x() & 15, pos.y(), pos.z() & 15); + BlockState toBlock = set.getBlock(pos.x() & 15, pos.y(), pos.z() & 15); if (fromBlock != toBlock || tilesTo.containsKey(pos)) { - addTileRemove(MainUtil.setPosition(entry.getValue(), entry.getKey().getX(), entry.getKey().getY(), - entry.getKey().getZ())); + addTileRemove(MainUtil.setPosition(entry.getValue(), entry.getKey().x(), entry.getKey().y(), + entry.getKey().z())); } } } if (!tilesTo.isEmpty()) { for (Map.Entry entry : tilesTo.entrySet()) { BlockVector3 pos = entry.getKey(); - addTileCreate(MainUtil.setPosition(entry.getValue(), pos.getX() + bx, pos.getY(), pos.getZ() + bz)); + addTileCreate(MainUtil.setPosition(entry.getValue(), pos.x() + bx, pos.y(), pos.z() + bz)); } } Set entRemoves = set.getEntityRemoves(); @@ -310,9 +310,9 @@ public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor { } public void add(BlockVector3 loc, BaseBlock from, BaseBlock to) { - int x = loc.getBlockX(); - int y = loc.getBlockY(); - int z = loc.getBlockZ(); + int x = loc.x(); + int y = loc.y(); + int z = loc.z(); add(x, y, z, from, to); } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/history/changeset/BlockBagChangeSet.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/history/changeset/BlockBagChangeSet.java index 22833d3b5..c0dc9756c 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/history/changeset/BlockBagChangeSet.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/history/changeset/BlockBagChangeSet.java @@ -68,9 +68,9 @@ public class BlockBagChangeSet extends AbstractDelegateChangeSet { @Override public void add(BlockVector3 loc, BaseBlock from, BaseBlock to) { - int x = loc.getBlockX(); - int y = loc.getBlockY(); - int z = loc.getBlockZ(); + int x = loc.x(); + int y = loc.y(); + int z = loc.z(); add(x, y, z, from, to); } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/BlockVector3ChunkMap.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/BlockVector3ChunkMap.java index a9f8a0210..919556847 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/BlockVector3ChunkMap.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/BlockVector3ChunkMap.java @@ -31,7 +31,7 @@ public class BlockVector3ChunkMap implements IAdaptedMap implements int cx = (int) MathMan.untripleWorldCoordX(triple); int cy = (int) MathMan.untripleWorldCoordY(triple); int cz = (int) MathMan.untripleWorldCoordZ(triple); - pos.mutX((cx << 11) + pos.getBlockX()); - pos.mutY((cy << 9) + pos.getBlockY()); - pos.mutZ((cz << 11) + pos.getBlockZ()); + pos.mutX((cx << 11) + pos.x()); + pos.mutY((cy << 9) + pos.y()); + pos.mutZ((cz << 11) + pos.z()); return pos.toImmutable(); } } @@ -124,7 +124,7 @@ public class BlockVectorSet extends AbstractCollection implements @Override public boolean contains(Object o) { if (o instanceof BlockVector3 v) { - return contains(v.getBlockX(), v.getBlockY(), v.getBlockZ()); + return contains(v.x(), v.y(), v.z()); } return false; } @@ -166,9 +166,9 @@ public class BlockVectorSet extends AbstractCollection implements int cy = (int) MathMan.untripleWorldCoordY(triple); int cz = (int) MathMan.untripleWorldCoordZ(triple); return mutable.setComponents( - (cx << 11) + localPos.getBlockX(), - (cy << 9) + localPos.getBlockY(), - (cz << 11) + localPos.getBlockZ() + (cx << 11) + localPos.x(), + (cy << 9) + localPos.y(), + (cz << 11) + localPos.z() ); } }; @@ -176,7 +176,7 @@ public class BlockVectorSet extends AbstractCollection implements @Override public boolean add(BlockVector3 vector) { - return add(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ()); + return add(vector.x(), vector.y(), vector.z()); } public boolean add(int x, int y, int z) { @@ -209,7 +209,7 @@ public class BlockVectorSet extends AbstractCollection implements @Override public boolean remove(Object o) { if (o instanceof BlockVector3 v) { - return remove(v.getBlockX(), v.getBlockY(), v.getBlockZ()); + return remove(v.x(), v.y(), v.z()); } return false; } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/LocalBlockVectorSet.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/LocalBlockVectorSet.java index 2ed3a2f63..72287b0a1 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/LocalBlockVectorSet.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/LocalBlockVectorSet.java @@ -90,7 +90,7 @@ public class LocalBlockVectorSet implements BlockVector3Set { @Override public boolean contains(Object o) { if (o instanceof BlockVector3 v) { - return contains(v.getBlockX(), v.getBlockY(), v.getBlockZ()); + return contains(v.x(), v.y(), v.z()); } return false; } @@ -302,14 +302,14 @@ public class LocalBlockVectorSet implements BlockVector3Set { */ @Override public boolean add(BlockVector3 vector) { - return add(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ()); + return add(vector.x(), vector.y(), vector.z()); } private int getIndex(BlockVector3 vector) { return MathMan.tripleSearchCoords( - vector.getBlockX() - offsetX, - vector.getBlockY() - offsetY, - vector.getBlockZ() - offsetZ + vector.x() - offsetX, + vector.y() - offsetY, + vector.z() - offsetZ ); } @@ -342,7 +342,7 @@ public class LocalBlockVectorSet implements BlockVector3Set { public boolean remove(Object o) { if (o instanceof BlockVector3) { BlockVector3 v = (BlockVector3) o; - return remove(v.getBlockX(), v.getBlockY(), v.getBlockZ()); + return remove(v.x(), v.y(), v.z()); } return false; } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/heightmap/HeightMap.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/heightmap/HeightMap.java index f9b2ce914..eeafc8646 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/heightmap/HeightMap.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/heightmap/HeightMap.java @@ -10,7 +10,6 @@ import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.util.Location; -import java.lang.reflect.InvocationTargetException; import java.util.concurrent.ThreadLocalRandom; public interface HeightMap { @@ -45,7 +44,7 @@ public interface HeightMap { boolean layers ) throws MaxChangedBlocksException { BlockVector3 top = session.getMaximumPoint(); - int maxY = top.getBlockY(); + int maxY = top.y(); Location min = new Location(session.getWorld(), pos.subtract(size, size, size).toVector3()); BlockVector3 max = pos.add(size, maxY, size); Region region = new CuboidRegion(session.getWorld(), min.toBlockPoint(), max); @@ -81,9 +80,9 @@ public interface HeightMap { int maxY = session.getMaxY(); int minY = session.getMinY(); int diameter = 2 * size + 1; - int centerX = pos.getBlockX(); - int centerZ = pos.getBlockZ(); - int centerY = pos.getBlockY(); + int centerX = pos.x(); + int centerZ = pos.z(); + int centerY = pos.y(); int[] oldData = new int[diameter * diameter]; int[] newData = new int[oldData.length]; if (layers) { // Pixel accuracy @@ -92,7 +91,7 @@ public interface HeightMap { } if (towards) { double sizePowInv = 1d / Math.pow(size, yscale); - int targetY = pos.getBlockY(); + int targetY = pos.y(); int tmpY = targetY; for (int x = -size; x <= size; x++) { int xx = centerX + x; @@ -133,7 +132,7 @@ public interface HeightMap { } } } else { - int height = pos.getBlockY(); + int height = pos.y(); for (int x = -size; x <= size; x++) { int xx = centerX + x; for (int z = -size; z <= size; z++) { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/heightmap/RotatableHeightMap.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/heightmap/RotatableHeightMap.java index 291f8e754..a452a80f4 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/heightmap/RotatableHeightMap.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/heightmap/RotatableHeightMap.java @@ -24,7 +24,7 @@ public class RotatableHeightMap extends AbstractDelegateHeightMap { mutable.mutX(x); mutable.mutZ(z); BlockVector3 pos = transform.apply(mutable.setComponents(x, 0, z)).toBlockPoint(); - return super.getHeight(pos.getBlockX(), pos.getBlockZ()); + return super.getHeight(pos.x(), pos.z()); } } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/heightmap/ScalableHeightMap.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/heightmap/ScalableHeightMap.java index c4481da46..bc845127d 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/heightmap/ScalableHeightMap.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/heightmap/ScalableHeightMap.java @@ -56,22 +56,22 @@ public class ScalableHeightMap implements HeightMap { public static ScalableHeightMap fromClipboard(Clipboard clipboard, int minY, int maxY) { BlockVector3 dim = clipboard.getDimensions(); - char[][] heightArray = new char[dim.getBlockX()][dim.getBlockZ()]; - int clipMinX = clipboard.getMinimumPoint().getBlockX(); - int clipMinZ = clipboard.getMinimumPoint().getBlockZ(); - int clipMinY = clipboard.getMinimumPoint().getBlockY(); - int clipMaxY = clipboard.getMaximumPoint().getBlockY(); + char[][] heightArray = new char[dim.x()][dim.z()]; + int clipMinX = clipboard.getMinimumPoint().x(); + int clipMinZ = clipboard.getMinimumPoint().z(); + int clipMinY = clipboard.getMinimumPoint().y(); + int clipMaxY = clipboard.getMaximumPoint().y(); int clipHeight = clipMaxY - clipMinY + 1; HashSet visited = new HashSet<>(); MutableBlockVector3 bv = new MutableBlockVector3(); for (BlockVector3 pos : clipboard.getRegion()) { - IntPair pair = new IntPair(pos.getBlockX(), pos.getBlockZ()); + IntPair pair = new IntPair(pos.x(), pos.z()); if (visited.contains(pair)) { continue; } visited.add(pair); - int xx = pos.getBlockX(); - int zz = pos.getBlockZ(); + int xx = pos.x(); + int zz = pos.z(); int highestY = clipMinY; bv.setComponents(pos); for (int y = clipMinY; y <= clipMaxY; y++) { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/random/SimplexNoiseGenerator.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/random/SimplexNoiseGenerator.java index 8d8aeedf5..d690509dc 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/random/SimplexNoiseGenerator.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/math/random/SimplexNoiseGenerator.java @@ -8,12 +8,12 @@ public class SimplexNoiseGenerator implements NoiseGenerator { @Override public float noise(Vector2 position) { - return convert(SimplexNoise.noise(position.getX(), position.getZ())); + return convert(SimplexNoise.noise(position.x(), position.z())); } @Override public float noise(Vector3 position) { - return convert(SimplexNoise.noise(position.getX(), position.getY(), position.getZ())); + return convert(SimplexNoise.noise(position.x(), position.y(), position.z())); } private float convert(double d) { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IChunkExtent.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IChunkExtent.java index ec6162798..a56fe27d5 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IChunkExtent.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IChunkExtent.java @@ -52,8 +52,8 @@ public interface IChunkExtent extends Extent { @Override default boolean setBiome(BlockVector3 position, BiomeType biome) { - final IChunk chunk = getOrCreateChunk(position.getX() >> 4, position.getZ() >> 4); - return chunk.setBiome(position.getX() & 15, position.getY(), position.getZ() & 15, biome); + final IChunk chunk = getOrCreateChunk(position.x() >> 4, position.z() >> 4); + return chunk.setBiome(position.x() & 15, position.y(), position.z() & 15, biome); } @Override @@ -76,8 +76,8 @@ public interface IChunkExtent extends Extent { @Override default BiomeType getBiome(BlockVector3 position) { - final IChunk chunk = getOrCreateChunk(position.getX() >> 4, position.getZ() >> 4); - return chunk.getBiomeType(position.getX() & 15, position.getY(), position.getZ() & 15); + final IChunk chunk = getOrCreateChunk(position.x() >> 4, position.z() >> 4); + return chunk.getBiomeType(position.x() & 15, position.y(), position.z() & 15); } @Override @@ -129,9 +129,9 @@ public interface IChunkExtent extends Extent { //Set pos List posList = new ArrayList<>(); - posList.add(new DoubleTag(location.getX())); - posList.add(new DoubleTag(location.getY())); - posList.add(new DoubleTag(location.getZ())); + posList.add(new DoubleTag(location.x())); + posList.add(new DoubleTag(location.y())); + posList.add(new DoubleTag(location.z())); map.put("Pos", new ListTag(DoubleTag.class, posList)); NBTUtils.addUUIDToMap(map, uuid); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IChunkGet.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IChunkGet.java index 458b1858c..b2ac59cb2 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IChunkGet.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IChunkGet.java @@ -25,7 +25,7 @@ public interface IChunkGet extends IBlocks, Trimable, InputExtent, ITileInput { @Override default BiomeType getBiome(BlockVector3 position) { - return getBiomeType(position.getX(), position.getY(), position.getZ()); + return getBiomeType(position.x(), position.y(), position.z()); } @Override diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IChunkSet.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IChunkSet.java index 1af60b3a2..bc621e66a 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IChunkSet.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IChunkSet.java @@ -25,7 +25,7 @@ public interface IChunkSet extends IBlocks, OutputExtent { @Override default boolean setBiome(BlockVector3 position, BiomeType biome) { - return setBiome(position.getX(), position.getY(), position.getZ(), biome); + return setBiome(position.x(), position.y(), position.z(), biome); } @Override diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IQueueExtent.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IQueueExtent.java index 104167d30..c13373d9a 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IQueueExtent.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IQueueExtent.java @@ -152,7 +152,7 @@ public interface IQueueExtent extends Flushable, Trimable, ICh final Set chunks = region.getChunks(); ChunkFilterBlock block = null; for (BlockVector2 chunk : chunks) { - block = apply(block, filter, region, chunk.getX(), chunk.getZ(), full); + block = apply(block, filter, region, chunk.x(), chunk.z(), full); } flush(); return filter; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/ParallelQueueExtent.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/ParallelQueueExtent.java index e88a9ccd3..38546ed1b 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/ParallelQueueExtent.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/ParallelQueueExtent.java @@ -135,7 +135,7 @@ public class ParallelQueueExtent extends PassthroughExtent { // if PQE is ever used with PARALLEL_THREADS = 1, or only one chunk is edited, just run sequentially while (chunksIter.hasNext()) { BlockVector2 pos = chunksIter.next(); - getExtent().apply(null, filter, region, pos.getX(), pos.getZ(), full); + getExtent().apply(null, filter, region, pos.x(), pos.z(), full); } } else { final ForkJoinTask[] tasks = IntStream.range(0, size).mapToObj(i -> handler.submit(() -> { @@ -159,8 +159,8 @@ public class ParallelQueueExtent extends PassthroughExtent { break; } final BlockVector2 pos = chunksIter.next(); - chunkX = pos.getX(); - chunkZ = pos.getZ(); + chunkX = pos.x(); + chunkZ = pos.z(); } block = queue.apply(block, newFilter, region, chunkX, chunkZ, full); } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/SingleThreadQueueExtent.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/SingleThreadQueueExtent.java index 6e06ce348..789547d83 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/SingleThreadQueueExtent.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/SingleThreadQueueExtent.java @@ -356,7 +356,7 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen break; } loadCount++; - addChunkLoad(from.getBlockX(), from.getBlockZ()); + addChunkLoad(from.x(), from.z()); } } } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/CharSetBlocks.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/CharSetBlocks.java index 9ab8734ea..da28e5925 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/CharSetBlocks.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/CharSetBlocks.java @@ -128,7 +128,7 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet { @Override public > boolean setBlock(BlockVector3 position, T block) throws WorldEditException { - return setBlock(position.getX(), position.getY(), position.getZ(), block); + return setBlock(position.x(), position.y(), position.z(), block); } @Override @@ -255,7 +255,7 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet { @Override public boolean setBiome(BlockVector3 position, BiomeType biome) { - return setBiome(position.getX(), position.getY(), position.getZ(), biome); + return setBiome(position.x(), position.y(), position.z(), biome); } @Override diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/ThreadUnsafeCharBlocks.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/ThreadUnsafeCharBlocks.java index ca0dd3442..54331279f 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/ThreadUnsafeCharBlocks.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/ThreadUnsafeCharBlocks.java @@ -218,7 +218,7 @@ public class ThreadUnsafeCharBlocks implements IChunkSet, IBlocks { @Override public boolean setBiome(BlockVector3 position, BiomeType biome) { - return setBiome(position.getX(), position.getY(), position.getZ(), biome); + return setBiome(position.x(), position.y(), position.z(), biome); } public void set(int x, int y, int z, char value) { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/preloader/AsyncPreloader.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/preloader/AsyncPreloader.java index 7a74ed8ac..672ecfc93 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/preloader/AsyncPreloader.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/preloader/AsyncPreloader.java @@ -111,8 +111,8 @@ public class AsyncPreloader implements Preloader, Runnable { while (chunksIter.hasNext() && pair.getValue() == chunks) { // Ensure the queued load is still valid BlockVector2 chunk = chunksIter.next(); if (Settings.settings().REGION_RESTRICTIONS_OPTIONS.RESTRICT_TO_SAFE_RANGE) { - int x = chunk.getX(); - int z = chunk.getZ(); + int x = chunk.x(); + int z = chunk.z(); // if any chunk coord is outside 30 million blocks if (x > 1875000 || z > 1875000 || x < -1875000 || z < -1875000) { continue; @@ -130,7 +130,7 @@ public class AsyncPreloader implements Preloader, Runnable { } private void queueLoad(World world, BlockVector2 chunk) { - world.checkLoadedChunk(BlockVector3.at(chunk.getX() << 4, 0, chunk.getZ() << 4)); + world.checkLoadedChunk(BlockVector3.at(chunk.x() << 4, 0, chunk.z() << 4)); } } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/regions/FuzzyRegion.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/regions/FuzzyRegion.java index 58061bfa0..e080baeaf 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/regions/FuzzyRegion.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/regions/FuzzyRegion.java @@ -52,7 +52,7 @@ public class FuzzyRegion extends AbstractRegion { */ public void select(BlockVector3 position) { RecursiveVisitor search = new RecursiveVisitor(mask, p -> { - setMinMax(p.getBlockX(), p.getBlockY(), p.getBlockZ()); + setMinMax(p.x(), p.y(), p.z()); return true; }, 256, extent.getMinY(), extent.getMaxY(), extent); search.setVisited(set); @@ -120,7 +120,7 @@ public class FuzzyRegion extends AbstractRegion { @Override public boolean contains(BlockVector3 position) { - return contains(position.getBlockX(), position.getBlockY(), position.getBlockZ()); + return contains(position.x(), position.y(), position.z()); } @Override diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/regions/PolyhedralRegion.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/regions/PolyhedralRegion.java index 03dd750a5..dbfe840c8 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/regions/PolyhedralRegion.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/regions/PolyhedralRegion.java @@ -261,27 +261,27 @@ public class PolyhedralRegion extends AbstractRegion { if (!isDefined()) { return false; } - final int x = position.getBlockX(); - final int y = position.getBlockY(); - final int z = position.getBlockZ(); + final int x = position.x(); + final int y = position.y(); + final int z = position.z(); final BlockVector3 min = getMinimumPoint(); final BlockVector3 max = getMaximumPoint(); - if (x < min.getBlockX()) { + if (x < min.x()) { return false; } - if (x > max.getBlockX()) { + if (x > max.x()) { return false; } - if (z < min.getBlockZ()) { + if (z < min.z()) { return false; } - if (z > max.getBlockZ()) { + if (z > max.z()) { return false; } - if (y < min.getBlockY()) { + if (y < min.y()) { return false; } - if (y > max.getBlockY()) { + if (y > max.y()) { return false; } return containsRaw(position); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/regions/RegionWrapper.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/regions/RegionWrapper.java index e382583aa..40d0075e5 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/regions/RegionWrapper.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/regions/RegionWrapper.java @@ -44,12 +44,12 @@ public class RegionWrapper extends CuboidRegion { public RegionWrapper(final BlockVector3 pos1, final BlockVector3 pos2) { super(pos1, pos2); - this.minX = Math.min(pos1.getBlockX(), pos2.getBlockX()); - this.minZ = Math.min(pos1.getBlockZ(), pos2.getBlockZ()); - this.maxX = Math.max(pos1.getBlockX(), pos2.getBlockX()); - this.maxZ = Math.max(pos1.getBlockZ(), pos2.getBlockZ()); - this.minY = Math.min(pos1.getBlockY(), pos2.getBlockY()); - this.maxY = Math.max(pos1.getBlockY(), pos2.getBlockY()); + this.minX = Math.min(pos1.x(), pos2.x()); + this.minZ = Math.min(pos1.z(), pos2.z()); + this.maxX = Math.max(pos1.x(), pos2.x()); + this.maxZ = Math.max(pos1.z(), pos2.z()); + this.minY = Math.min(pos1.y(), pos2.y()); + this.maxY = Math.max(pos1.y(), pos2.y()); } public static RegionWrapper GLOBAL() { @@ -61,12 +61,12 @@ public class RegionWrapper extends CuboidRegion { super.recalculate(); BlockVector3 pos1 = getMinimumPoint(); BlockVector3 pos2 = getMaximumPoint(); - this.minX = Math.min(pos1.getBlockX(), pos2.getBlockX()); - this.minZ = Math.min(pos1.getBlockZ(), pos2.getBlockZ()); - this.maxX = Math.max(pos1.getBlockX(), pos2.getBlockX()); - this.maxZ = Math.max(pos1.getBlockZ(), pos2.getBlockZ()); - this.minY = Math.min(pos1.getBlockY(), pos2.getBlockY()); - this.maxY = Math.max(pos1.getBlockY(), pos2.getBlockY()); + this.minX = Math.min(pos1.x(), pos2.x()); + this.minZ = Math.min(pos1.z(), pos2.z()); + this.maxX = Math.max(pos1.x(), pos2.x()); + this.maxZ = Math.max(pos1.z(), pos2.z()); + this.minY = Math.min(pos1.y(), pos2.y()); + this.maxY = Math.max(pos1.y(), pos2.y()); } @Override diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/regions/Triangle.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/regions/Triangle.java index 46e934bee..2bb9fc5ac 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/regions/Triangle.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/regions/Triangle.java @@ -28,9 +28,9 @@ public class Triangle { private final double b; public Triangle(BlockVector3 pos1, BlockVector3 pos2, BlockVector3 pos3) { - verts[0] = new double[]{pos1.getBlockX(), pos1.getBlockY(), pos1.getBlockZ()}; - verts[1] = new double[]{pos2.getBlockX(), pos2.getBlockY(), pos2.getBlockZ()}; - verts[2] = new double[]{pos3.getBlockX(), pos3.getBlockY(), pos3.getBlockZ()}; + verts[0] = new double[]{pos1.x(), pos1.y(), pos1.z()}; + verts[1] = new double[]{pos2.x(), pos2.y(), pos2.z()}; + verts[2] = new double[]{pos3.x(), pos3.y(), pos3.z()}; radius[0] = RADIUS; radius[1] = RADIUS; radius[2] = RADIUS; @@ -72,9 +72,9 @@ public class Triangle { } public boolean contains(BlockVector3 pos) { - center[0] = pos.getBlockX() + RADIUS; - center[1] = pos.getBlockY() + RADIUS; - center[2] = pos.getBlockZ() + RADIUS; + center[0] = pos.x() + RADIUS; + center[1] = pos.y() + RADIUS; + center[2] = pos.z() + RADIUS; return overlaps(center, radius, verts); } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/regions/filter/CuboidRegionFilter.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/regions/filter/CuboidRegionFilter.java index d354eae3b..72413e115 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/regions/filter/CuboidRegionFilter.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/regions/filter/CuboidRegionFilter.java @@ -19,10 +19,10 @@ public abstract class CuboidRegionFilter implements RegionFilter { public abstract void calculateRegions(); public void add(BlockVector2 pos1, BlockVector2 pos2) { - int ccx1 = pos1.getBlockX() >> 9; - int ccz1 = pos1.getBlockZ() >> 9; - int ccx2 = pos2.getBlockX() >> 9; - int ccz2 = pos2.getBlockZ() >> 9; + int ccx1 = pos1.x() >> 9; + int ccz1 = pos1.z() >> 9; + int ccx2 = pos2.x() >> 9; + int ccz2 = pos2.z() >> 9; for (int x = ccx1; x <= ccx2; x++) { for (int z = ccz1; z <= ccz2; z++) { if (!occupiedRegions.containsKey(x, z)) { @@ -39,10 +39,10 @@ public abstract class CuboidRegionFilter implements RegionFilter { } } } - int cx1 = pos1.getBlockX() >> 4; - int cz1 = pos1.getBlockZ() >> 4; - int cx2 = pos2.getBlockX() >> 4; - int cz2 = pos2.getBlockZ() >> 4; + int cx1 = pos1.x() >> 4; + int cz1 = pos1.z() >> 4; + int cx2 = pos2.x() >> 4; + int cz2 = pos2.z() >> 4; for (int chunkZ = cz1; chunkZ <= cz2; chunkZ++) { for (int chunkX = cx1; chunkX <= cx2; chunkX++) { unoccupiedChunks.remove(chunkX, chunkZ); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/MainUtil.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/MainUtil.java index 1c5fe044a..117ab8fab 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/MainUtil.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/MainUtil.java @@ -450,9 +450,9 @@ public class MainUtil { Location loc = entity.getLocation(); // Create a copy, because the list is immutable... List posList = new ArrayList<>(pos.getValue()); - posList.set(0, new DoubleTag(loc.getX())); - posList.set(1, new DoubleTag(loc.getY())); - posList.set(2, new DoubleTag(loc.getZ())); + posList.set(0, new DoubleTag(loc.x())); + posList.set(1, new DoubleTag(loc.y())); + posList.set(2, new DoubleTag(loc.z())); map.put("Pos", new ListTag(pos.getType(), posList)); } return new CompoundTag(map); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/WEManager.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/WEManager.java index b31853dd0..00ededf1a 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/WEManager.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/WEManager.java @@ -183,8 +183,8 @@ public class WEManager { BlockVector3 rg2P1 = region2.getMinimumPoint(); BlockVector3 rg2P2 = region2.getMaximumPoint(); - return rg1P1.getBlockX() <= rg2P2.getBlockX() && rg1P2.getBlockX() >= rg2P1.getBlockX() - && rg1P1.getBlockZ() <= rg2P2.getBlockZ() && rg1P2.getBlockZ() >= rg2P1.getBlockZ(); + return rg1P1.x() <= rg2P2.x() && rg1P2.x() >= rg2P1.x() + && rg1P1.z() <= rg2P2.z() && rg1P2.z() >= rg2P1.z(); } public boolean regionContains(Region selection, HashSet mask) { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/BlockSet.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/BlockSet.java index 0706a39d2..06e7d7cff 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/BlockSet.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/BlockSet.java @@ -35,7 +35,7 @@ public abstract class BlockSet extends AbstractRegion { @Override public boolean contains(BlockVector3 obj) { - return contains(obj.getX(), obj.getY(), obj.getZ()); + return contains(obj.x(), obj.y(), obj.z()); } protected final int lowestBit(long bitBuffer) { @@ -71,11 +71,11 @@ public abstract class BlockSet extends AbstractRegion { @Override public boolean add(BlockVector3 p) { - return add(p.getX(), p.getY(), p.getZ()); + return add(p.x(), p.y(), p.z()); } public boolean remove(BlockVector3 p) { - return remove(p.getX(), p.getY(), p.getZ()); + return remove(p.x(), p.y(), p.z()); } @Override diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/BlockVector3Set.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/BlockVector3Set.java index cadc35fc8..8bf9463f9 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/BlockVector3Set.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/BlockVector3Set.java @@ -23,11 +23,11 @@ public interface BlockVector3Set extends Set { // Set default offset as many operations utilising a region are likely to start in a corner, this initialising the // LocalBlockVectorSet poorly // This needs to be ceiling as LocalBlockVector extends 1 block further "negative" - int offsetX = (int) Math.ceil((min.getX() + max.getX()) / 2d); - int offsetZ = (int) Math.ceil((min.getZ() + max.getZ()) / 2d); + int offsetX = (int) Math.ceil((min.x() + max.x()) / 2d); + int offsetZ = (int) Math.ceil((min.z() + max.z()) / 2d); int offsetY; if (region.getMinimumY() < -128 || region.getMaximumY() > 320) { - offsetY = (min.getY() + max.getY()) / 2; + offsetY = (min.y() + max.y()) / 2; } else { offsetY = 128; } @@ -43,7 +43,7 @@ public interface BlockVector3Set extends Set { * @return Appropriate {@link BlockVector3Set} implementation */ static BlockVector3Set getAppropriateVectorSet(BlockVector3 size) { - if (size.getBlockX() > 2048 || size.getBlockZ() > 2048 || size.getBlockY() > 512) { + if (size.x() > 2048 || size.z() > 2048 || size.y() > 512) { return new BlockVectorSet(); } else { return new LocalBlockVectorSet(); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/MemBlockSet.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/MemBlockSet.java index 33fc963c3..68990cad1 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/MemBlockSet.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/collection/MemBlockSet.java @@ -1,7 +1,6 @@ package com.fastasyncworldedit.core.util.collection; import com.fastasyncworldedit.core.FaweCache; -import com.fastasyncworldedit.core.math.MutableBlockVector2; import com.fastasyncworldedit.core.math.MutableBlockVector3; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; @@ -167,9 +166,9 @@ public final class MemBlockSet extends BlockSet { @Override public boolean contains(Object o) { if (o instanceof BlockVector2 other) { - IRow rowx = rows[other.getX() - getChunkOffsetX()]; + IRow rowx = rows[other.x() - getChunkOffsetX()]; if (rowx instanceof RowX) { - return ((RowX) rowx).rows[other.getZ() - getChunkOffsetZ()] instanceof RowZ; + return ((RowX) rowx).rows[other.z() - getChunkOffsetZ()] instanceof RowZ; } } return false; @@ -269,11 +268,11 @@ public final class MemBlockSet extends BlockSet { @Override public boolean contains(Object o) { if (o instanceof BlockVector3 other) { - IRow rowx = rows[other.getX() - getChunkOffsetX()]; + IRow rowx = rows[other.x() - getChunkOffsetX()]; if (rowx instanceof RowX) { - IRow rowz = ((RowX) rowx).rows[other.getZ()]; + IRow rowz = ((RowX) rowx).rows[other.z()]; if (rowz instanceof RowZ) { - return ((RowZ) rowz).rows[other.getY() - (minSectionPosition << 4) - getChunkOffsetZ()] instanceof RowY; + return ((RowZ) rowz).rows[other.y() - (minSectionPosition << 4) - getChunkOffsetZ()] instanceof RowY; } } } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/world/SimpleWorld.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/world/SimpleWorld.java index dcc65ae21..1619f114f 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/world/SimpleWorld.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/world/SimpleWorld.java @@ -58,12 +58,12 @@ public interface SimpleWorld extends World { @Override default int getMaxY() { - return getMaximumPoint().getBlockY(); + return getMaximumPoint().y(); } @Override default int getMinY() { - return getMinimumPoint().getBlockY(); + return getMinimumPoint().y(); } @Override diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/wrappers/AsyncPlayer.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/wrappers/AsyncPlayer.java index 700070611..077e87e8c 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/wrappers/AsyncPlayer.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/wrappers/AsyncPlayer.java @@ -97,7 +97,7 @@ public class AsyncPlayer extends PlayerProxy { return false; } - while (y <= world.getMaximumPoint().getY()) { + while (y <= world.getMaximumPoint().y()) { // Found a ceiling! if (world.getBlock(mutable.mutY(y)).getBlockType().getMaterial() .isMovementBlocker()) { diff --git a/worldedit-core/src/main/java/com/sk89q/util/yaml/YAMLNode.java b/worldedit-core/src/main/java/com/sk89q/util/yaml/YAMLNode.java index d4cc816e7..a894cbe14 100644 --- a/worldedit-core/src/main/java/com/sk89q/util/yaml/YAMLNode.java +++ b/worldedit-core/src/main/java/com/sk89q/util/yaml/YAMLNode.java @@ -161,28 +161,28 @@ public class YAMLNode { if (value instanceof Vector3) { Map out = new LinkedHashMap<>(); Vector3 vec = (Vector3) value; - out.put("x", vec.getX()); - out.put("y", vec.getY()); - out.put("z", vec.getZ()); + out.put("x", vec.x()); + out.put("y", vec.y()); + out.put("z", vec.z()); return out; } else if (value instanceof BlockVector3) { Map out = new LinkedHashMap<>(); BlockVector3 vec = (BlockVector3) value; - out.put("x", vec.getBlockX()); - out.put("y", vec.getBlockY()); - out.put("z", vec.getBlockZ()); + out.put("x", vec.x()); + out.put("y", vec.y()); + out.put("z", vec.z()); return out; } else if (value instanceof Vector2) { Map out = new LinkedHashMap<>(); Vector2 vec = (Vector2) value; - out.put("x", vec.getX()); - out.put("z", vec.getZ()); + out.put("x", vec.x()); + out.put("z", vec.z()); return out; } else if (value instanceof BlockVector2) { Map out = new LinkedHashMap<>(); BlockVector2 vec = (BlockVector2) value; - out.put("x", vec.getBlockX()); - out.put("z", vec.getBlockZ()); + out.put("x", vec.x()); + out.put("z", vec.z()); return out; } 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 ecf859896..2e5e3c2ef 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -903,7 +903,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { @Override public boolean setBiome(BlockVector3 position, BiomeType biome) { //FAWE start - use extent - if (position.getY() < this.minY || position.getY() > this.maxY) { + if (position.y() < this.minY || position.y() > this.maxY) { return false; } this.changes++; @@ -984,7 +984,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { public > boolean setBlock(BlockVector3 position, B block, Stage stage) throws WorldEditException { //FAWE start - accumulate changes - if (position.getBlockY() < this.minY || position.getBlockY() > this.maxY) { + if (position.y() < this.minY || position.y() > this.maxY) { return false; } @@ -1014,7 +1014,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { */ @Deprecated public > boolean rawSetBlock(BlockVector3 position, B block) { - if (position.getBlockY() < this.minY || position.getBlockY() > this.maxY) { + if (position.y() < this.minY || position.y() > this.maxY) { return false; } @@ -1037,7 +1037,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { * @return whether the block changed */ public > boolean smartSetBlock(BlockVector3 position, B block) { - if (position.getBlockY() < this.minY || position.getBlockY() > this.maxY) { + if (position.y() < this.minY || position.y() > this.maxY) { return false; } @@ -1052,7 +1052,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { @Override @Deprecated public > boolean setBlock(BlockVector3 position, B block) throws MaxChangedBlocksException { - if (position.getBlockY() < this.minY || position.getBlockY() > this.maxY) { + if (position.y() < this.minY || position.y() > this.maxY) { return false; } @@ -1114,7 +1114,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { * @throws MaxChangedBlocksException thrown if too many blocks are changed */ public boolean setBlock(BlockVector3 position, Pattern pattern) throws MaxChangedBlocksException { - if (position.getBlockY() < this.minY || position.getBlockY() > this.maxY) { + if (position.y() < this.minY || position.y() > this.maxY) { return false; } @@ -1349,12 +1349,12 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { public > int fall(final Region region, boolean fullHeight, final B replace) { FlatRegion flat = asFlatRegion(region); - final int startPerformY = region.getMinimumPoint().getBlockY(); + final int startPerformY = region.getMinimumPoint().y(); final int startCheckY = fullHeight ? getMinY() : startPerformY; - final int endY = region.getMaximumPoint().getBlockY(); + final int endY = region.getMaximumPoint().y(); RegionVisitor visitor = new RegionVisitor(flat, pos -> { - int x = pos.getX(); - int z = pos.getZ(); + int x = pos.x(); + int z = pos.z(); int freeSpot = startCheckY; for (int y = startCheckY; y <= endY; y++) { if (y < startPerformY) { @@ -1479,8 +1479,8 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { // Avoid int overflow (negative coordinate space allows for overflow back round to positive if the depth is large enough). // Depth is always 1 or greater, thus the lower bound should always be <= origin y. - int lowerBound = origin.getBlockY() - depth + 1; - if (lowerBound > origin.getBlockY()) { + int lowerBound = origin.y() - depth + 1; + if (lowerBound > origin.y()) { lowerBound = Integer.MIN_VALUE; } @@ -1488,7 +1488,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))), new BoundedHeightMask( Math.max(lowerBound, minY), - Math.min(maxY, origin.getBlockY()) + Math.min(maxY, origin.y()) ), Masks.negate(new ExistingBlockMask(this)) ); @@ -1502,7 +1502,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { if (recursive) { visitor = new RecursiveVisitor(mask, replace, (int) (radius * 2 + 1), minY, maxY, this); } else { - visitor = new DownwardVisitor(mask, replace, origin.getBlockY(), (int) (radius * 2 + 1), minY, maxY, this); + visitor = new DownwardVisitor(mask, replace, origin.y(), (int) (radius * 2 + 1), minY, maxY, this); } //FAWE end @@ -1600,11 +1600,11 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { Vector3 center = region.getCenter(); Region centerRegion = new CuboidRegion( getWorld(), // Causes clamping of Y range - BlockVector3.at(((int) center.getX()), ((int) center.getY()), ((int) center.getZ())), + BlockVector3.at(((int) center.x()), ((int) center.y()), ((int) center.z())), BlockVector3.at( - MathUtils.roundHalfUp(center.getX()), - MathUtils.roundHalfUp(center.getY()), - MathUtils.roundHalfUp(center.getZ()) + MathUtils.roundHalfUp(center.x()), + MathUtils.roundHalfUp(center.y()), + MathUtils.roundHalfUp(center.z()) ) ); return setBlocks(centerRegion, pattern); @@ -1754,8 +1754,8 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { BlockReplace replace = new BlockReplace(this, pattern); RegionOffset offset = new RegionOffset(BlockVector3.UNIT_Y, replace); //FAWE start - int minY = region.getMinimumPoint().getBlockY(); - int maxY = Math.min(getMaximumPoint().getBlockY(), region.getMaximumPoint().getBlockY() + 1); + int minY = region.getMinimumPoint().y(); + int maxY = Math.min(getMaximumPoint().y(), region.getMaximumPoint().y() + 1); SurfaceRegionFunction surface = new SurfaceRegionFunction(this, offset, minY, maxY); FlatRegionVisitor visitor = new FlatRegionVisitor(asFlatRegion(region), surface, this); //FAWE end @@ -1905,7 +1905,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { BlockVector3 disAbs = displace.abs(); - if (disAbs.getBlockX() < size.getBlockX() && disAbs.getBlockY() < size.getBlockY() && disAbs.getBlockZ() < size.getBlockZ()) { + if (disAbs.x() < size.x() && disAbs.y() < size.y() && disAbs.z() < size.z()) { // Buffer if overlapping enableQueue(); } @@ -2068,7 +2068,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { // There are boundaries that the routine needs to stay in Mask mask = new MaskIntersection( - new BoundedHeightMask(minY, Math.min(origin.getBlockY(), maxY)), + new BoundedHeightMask(minY, Math.min(origin.y(), maxY)), new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))), blockMask ); @@ -2156,15 +2156,15 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { } else if (height < 0) { height = -height; //FAWE start - mutableBlockVector3.mutY(mutableBlockVector3.getY() - height); + mutableBlockVector3.mutY(mutableBlockVector3.y() - height); //FAWE end } //FAWE start - if (mutableBlockVector3.getBlockY() < getWorld().getMinY()) { + if (mutableBlockVector3.y() < getWorld().getMinY()) { mutableBlockVector3.mutY(world.getMinY()); - } else if (mutableBlockVector3.getBlockY() + height - 1 > maxY) { - height = maxY - mutableBlockVector3.getBlockY() + 1; + } else if (mutableBlockVector3.y() + height - 1 > maxY) { + height = maxY - mutableBlockVector3.y() + 1; } //FAWE end @@ -2172,9 +2172,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { final double invRadiusZ = 1 / radiusZ; //FAWE start - int px = mutableBlockVector3.getBlockX(); - int py = mutableBlockVector3.getBlockY(); - int pz = mutableBlockVector3.getBlockZ(); + int px = mutableBlockVector3.x(); + int py = mutableBlockVector3.y(); + int pz = mutableBlockVector3.z(); final int ceilRadiusX = (int) Math.ceil(radiusX); final int ceilRadiusZ = (int) Math.ceil(radiusZ); @@ -2319,9 +2319,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { double ry2 = Math.pow(height, 2); double rz2 = Math.pow(radiusZ, 2); - int cx = pos.getX(); - int cy = pos.getY(); - int cz = pos.getZ(); + int cx = pos.x(); + int cy = pos.y(); + int cz = pos.z(); for (int y = 0; y < height; ++y) { double ySquaredMinusHeightOverHeightSquared = Math.pow(y - height, 2) / ry2; @@ -2403,18 +2403,18 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { radiusZ += 0.5; normal = normal.normalize(); - double nx = normal.getX(); - double ny = normal.getY(); - double nz = normal.getZ(); + double nx = normal.x(); + double ny = normal.y(); + double nz = normal.z(); final double invRadiusX = 1 / radiusX; final double invRadiusY = 1 / radiusY; final double invRadiusZ = 1 / radiusZ; - int px = pos.getBlockX(); - int py = pos.getBlockY(); - int pz = pos.getBlockZ(); + int px = pos.x(); + int py = pos.y(); + int pz = pos.z(); final int ceilRadiusX = (int) Math.ceil(radiusX); final int ceilRadiusY = (int) Math.ceil(radiusY); @@ -2545,9 +2545,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { final double invRadiusY = 1 / radiusY; final double invRadiusZ = 1 / radiusZ; - int px = pos.getBlockX(); - int py = pos.getBlockY(); - int pz = pos.getBlockZ(); + int px = pos.x(); + int py = pos.y(); + int pz = pos.z(); final int ceilRadiusX = (int) Math.ceil(radiusX); final int ceilRadiusY = (int) Math.ceil(radiusY); @@ -2654,9 +2654,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { */ public int makePyramid(BlockVector3 position, Pattern block, int size, boolean filled) throws MaxChangedBlocksException { //FAWE start - abbreviated logic - int bx = position.getX(); - int by = position.getY(); - int bz = position.getZ(); + int bx = position.x(); + int by = position.y(); + int bz = position.z(); int height = size; int yy, xx, x_x, zz, z_z; @@ -2715,9 +2715,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { int affected = 0; double radiusSq = radius * radius; - int ox = position.getBlockX(); - int oy = position.getBlockY(); - int oz = position.getBlockZ(); + int ox = position.x(); + int oy = position.y(); + int oz = position.z(); BlockState air = BlockTypes.AIR.getDefaultState(); BlockState water = BlockTypes.WATER.getDefaultState(); @@ -2804,7 +2804,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { public int simulateSnow(BlockVector3 position, double radius, int height) throws MaxChangedBlocksException { - return simulateSnow(new CylinderRegion(position, Vector2.at(radius, radius), position.getBlockY(), height), false); + return simulateSnow(new CylinderRegion(position, Vector2.at(radius, radius), position.y(), height), false); } /** @@ -2860,9 +2860,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { int affected = 0; final double radiusSq = radius * radius; - final int ox = position.getBlockX(); - final int oy = position.getBlockY(); - final int oz = position.getBlockZ(); + final int ox = position.x(); + final int oy = position.y(); + final int oz = position.z(); final BlockState grass = BlockTypes.GRASS_BLOCK.getDefaultState(); @@ -3077,7 +3077,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { } } if (expression.evaluate( - new double[]{scaled.getX(), scaled.getY(), scaled.getZ(), typeVar, dataVar}, + new double[]{scaled.x(), scaled.y(), scaled.z(), typeVar, dataVar}, timeout ) <= 0) { return null; @@ -3180,10 +3180,10 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { final Vector3 scaled = position.toVector3().subtract(zero).divide(unit); // transform - expression.evaluate(new double[]{scaled.getX(), scaled.getY(), scaled.getZ()}, timeout); - int xv = (int) Math.floor(x.getValue() * unit.getX() + zero2.getX()); - int yv = (int) Math.floor(y.getValue() * unit.getY() + zero2.getY()); - int zv = (int) Math.floor(z.getValue() * unit.getZ() + zero2.getZ()); + expression.evaluate(new double[]{scaled.x(), scaled.y(), scaled.z()}, timeout); + int xv = (int) Math.floor(x.getValue() * unit.x() + zero2.x()); + int yv = (int) Math.floor(y.getValue() * unit.y() + zero2.y()); + int zv = (int) Math.floor(z.getValue() * unit.z() + zero2.z()); BlockState get; if (yv >= minY && yv <= maxY) { @@ -3222,12 +3222,12 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { final BlockVector3 min = region.getMinimumPoint(); final BlockVector3 max = region.getMaximumPoint(); - final int minX = min.getBlockX(); - final int minY = min.getBlockY(); - final int minZ = min.getBlockZ(); - final int maxX = max.getBlockX(); - final int maxY = max.getBlockY(); - final int maxZ = max.getBlockZ(); + final int minX = min.x(); + final int minY = min.y(); + final int minZ = min.z(); + final int maxX = max.x(); + final int maxY = max.y(); + final int maxZ = max.z(); //FAWE start - mutable MutableBlockVector3 mutable = new MutableBlockVector3(); @@ -3316,12 +3316,12 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { public int drawLine(Pattern pattern, BlockVector3 pos1, BlockVector3 pos2, double radius, boolean filled, boolean flat) throws MaxChangedBlocksException { - int x1 = pos1.getBlockX(); - int y1 = pos1.getBlockY(); - int z1 = pos1.getBlockZ(); - int x2 = pos2.getBlockX(); - int y2 = pos2.getBlockY(); - int z2 = pos2.getBlockZ(); + int x1 = pos1.x(); + int y1 = pos1.y(); + int z1 = pos1.z(); + int x2 = pos2.x(); + int y2 = pos2.y(); + int z2 = pos2.z(); int tipx = x1; int tipy = y1; int tipz = z1; @@ -3416,12 +3416,12 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { BlockVector3 pos1 = vectors.get(i); BlockVector3 pos2 = vectors.get(i + 1); - int x1 = pos1.getBlockX(); - int y1 = pos1.getBlockY(); - int z1 = pos1.getBlockZ(); - int x2 = pos2.getBlockX(); - int y2 = pos2.getBlockY(); - int z2 = pos2.getBlockZ(); + int x1 = pos1.x(); + int y1 = pos1.y(); + int z1 = pos1.z(); + int x2 = pos2.x(); + int y2 = pos2.y(); + int z2 = pos2.z(); int tipx = x1; int tipy = y1; int tipz = z1; @@ -3532,9 +3532,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { int ceilrad = (int) Math.ceil(radius); for (BlockVector3 v : vset) { - int tipx = v.getBlockX(); - int tipy = v.getBlockY(); - int tipz = v.getBlockZ(); + int tipx = v.x(); + int tipy = v.y(); + int tipz = v.z(); for (int loopx = tipx - ceilrad; loopx <= tipx + ceilrad; loopx++) { for (int loopy = tipy - ceilrad; loopy <= tipy + ceilrad; loopy++) { @@ -3557,13 +3557,13 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { final LocalBlockVectorSet returnset = new LocalBlockVectorSet(); final int ceilrad = (int) Math.ceil(radius); for (BlockVector3 v : vset) { - final int tipx = v.getBlockX(); - final int tipy = v.getBlockY(); - final int tipz = v.getBlockZ(); + final int tipx = v.x(); + final int tipy = v.y(); + final int tipz = v.z(); for (int loopx = tipx - ceilrad; loopx <= tipx + ceilrad; loopx++) { for (int loopz = tipz - ceilrad; loopz <= tipz + ceilrad; loopz++) { if (MathMan.hypot(loopx - tipx, 0, loopz - tipz) <= radius) { - returnset.add(loopx, v.getBlockY(), loopz); + returnset.add(loopx, v.y(), loopz); } } } @@ -3576,9 +3576,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { final LocalBlockVectorSet newset = new LocalBlockVectorSet(); newset.addAll(vset); for (BlockVector3 v : newset) { - final int x = v.getX(); - final int y = v.getY(); - final int z = v.getZ(); + final int x = v.x(); + final int y = v.y(); + final int z = v.z(); if (!(newset.contains(x + 1, y, z) && newset.contains(x - 1, y, z) && newset.contains(x, y, z + 1) @@ -3595,9 +3595,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { final LocalBlockVectorSet newset = new LocalBlockVectorSet(); newset.addAll(vset); for (BlockVector3 v : newset) { - final int x = v.getX(); - final int y = v.getY(); - final int z = v.getZ(); + final int x = v.x(); + final int y = v.y(); + final int z = v.z(); if (!(newset.contains(x + 1, y, z) && newset.contains(x - 1, y, z) && newset.contains(x, y + 1, z) @@ -3668,9 +3668,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { @Override protected BiomeType getBiome(int x, int y, int z, BiomeType defaultBiomeType) { environment.setCurrentBlock(x, y, z); - double scaledX = (x - zero.getX()) / unit.getX(); - double scaledY = (y - zero.getY()) / unit.getY(); - double scaledZ = (z - zero.getZ()) / unit.getZ(); + double scaledX = (x - zero.x()) / unit.x(); + double scaledY = (y - zero.y()) / unit.y(); + double scaledZ = (z - zero.z()) / unit.z(); try { if (expression.evaluate(new double[]{scaledX, scaledY, scaledZ}, timeout) <= 0) { @@ -3717,9 +3717,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { } private void setExistingBlocks(BlockVector3 pos1, BlockVector3 pos2) { - for (int x = pos1.getX(); x <= pos2.getX(); x++) { - for (int z = pos1.getBlockZ(); z <= pos2.getBlockZ(); z++) { - for (int y = pos1.getY(); y <= pos2.getY(); y++) { + for (int x = pos1.x(); x <= pos2.x(); x++) { + for (int z = pos1.z(); z <= pos2.z(); z++) { + for (int y = pos1.y(); y <= pos2.y(); y++) { setBlock(x, y, z, getFullBlock(x, y, z)); } } @@ -3735,10 +3735,10 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { if (fe != null && cuboid) { BlockVector3 max = region.getMaximumPoint(); BlockVector3 min = region.getMinimumPoint(); - if (!fe.contains(max.getBlockX(), max.getBlockY(), max.getBlockZ()) && !fe.contains( - min.getBlockX(), - min.getBlockY(), - min.getBlockZ() + if (!fe.contains(max.x(), max.y(), max.z()) && !fe.contains( + min.x(), + min.y(), + min.z() )) { throw FaweCache.OUTSIDE_REGION; } @@ -3748,17 +3748,17 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { MutableBlockVector3 mutable2 = new MutableBlockVector3(); MutableBlockVector2 mutable2D = new MutableBlockVector2(); for (BlockVector2 chunk : chunks) { - final int cx = chunk.getBlockX(); - final int cz = chunk.getBlockZ(); + final int cx = chunk.x(); + final int cz = chunk.z(); final int bx = cx << 4; final int bz = cz << 4; final BlockVector3 cmin = BlockVector3.at(bx, 0, bz); final BlockVector3 cmax = cmin.add(15, maxY, 15); final boolean containsBot1 = - fe == null || fe.contains(cmin.getBlockX(), cmin.getBlockY(), cmin.getBlockZ()); + fe == null || fe.contains(cmin.x(), cmin.y(), cmin.z()); final boolean containsBot2 = region.contains(cmin); final boolean containsTop1 = - fe == null || fe.contains(cmax.getBlockX(), cmax.getBlockY(), cmax.getBlockZ()); + fe == null || fe.contains(cmax.x(), cmax.y(), cmax.z()); final boolean containsTop2 = region.contains(cmax); if (containsBot2 && containsTop2 && !containsBot1 && !containsTop1) { continue; @@ -3917,15 +3917,15 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { double seedY = ThreadLocalRandom.current().nextDouble(); double seedZ = ThreadLocalRandom.current().nextDouble(); - int px = position.getBlockX(); - int py = position.getBlockY(); - int pz = position.getBlockZ(); + int px = position.x(); + int py = position.y(); + int pz = position.z(); double distort = frequency / size; - double modX = 1d / radius.getX(); - double modY = 1d / radius.getY(); - double modZ = 1d / radius.getZ(); + double modX = 1d / radius.x(); + double modY = 1d / radius.y(); + double modZ = 1d / radius.z(); int r = (int) size; int radiusSqr = (int) (size * size); int sizeInt = (int) size * 2; @@ -3986,9 +3986,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { // so it must be set each time mutable.setComponents(xr, yr, zr); Vector3 pt = transform.apply(mutable); - x = MathMan.roundInt(pt.getX()); - y = MathMan.roundInt(pt.getY()); - z = MathMan.roundInt(pt.getZ()); + x = MathMan.roundInt(pt.x()); + y = MathMan.roundInt(pt.y()); + z = MathMan.roundInt(pt.z()); xScaled = Math.abs(x) * modX; yScaled = Math.abs(y) * modY; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java index bdd6a4ed4..7160be750 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java @@ -462,7 +462,7 @@ public class BrushCommands { @Arg(desc = "double", def = "50") double amplitude ) throws WorldEditException { - double max = MathMan.max(radius.getX(), radius.getY(), radius.getZ()); + double max = MathMan.max(radius.x(), radius.y(), radius.z()); worldEdit.checkMaxBrushRadius( max, context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player")) @@ -1368,15 +1368,15 @@ public class BrushCommands { BlockVector3 size = clipboard.getDimensions(); worldEdit.checkMaxBrushRadius( - size.getBlockX() / 2D - 1, + size.x() / 2D - 1, context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player")) ); worldEdit.checkMaxBrushRadius( - size.getBlockY() / 2D - 1, + size.y() / 2D - 1, context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player")) ); worldEdit.checkMaxBrushRadius( - size.getBlockZ() / 2D - 1, + size.z() / 2D - 1, context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player")) ); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java index 177366651..b4037ba15 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java @@ -150,8 +150,8 @@ public class ClipboardCommands { BlockVector3 max = region.getMaximumPoint(); long volume = - ((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min - .getZ() + 1); + ((long) max.x() - (long) min.x() + 1) * ((long) max.y() - (long) min.y() + 1) * ((long) max.z() - (long) min + .z() + 1); FaweLimit limit = actor.getLimit(); if (volume >= limit.MAX_CHECKS) { throw FaweCache.MAX_CHECKS; @@ -184,8 +184,8 @@ public class ClipboardCommands { ) throws WorldEditException { BlockVector3 min = region.getMinimumPoint(); BlockVector3 max = region.getMaximumPoint(); - long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min - .getZ() + 1)); + long volume = (((long) max.x() - (long) min.x() + 1) * ((long) max.y() - (long) min.y() + 1) * ((long) max.z() - (long) min + .z() + 1)); FaweLimit limit = actor.getLimit(); if (volume >= limit.MAX_CHECKS) { throw FaweCache.MAX_CHECKS; @@ -257,8 +257,8 @@ public class ClipboardCommands { BlockVector3 min = region.getMinimumPoint(); BlockVector3 max = region.getMaximumPoint(); - long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min - .getZ() + 1)); + long volume = (((long) max.x() - (long) min.x() + 1) * ((long) max.y() - (long) min.y() + 1) * ((long) max.z() - (long) min + .z() + 1)); FaweLimit limit = actor.getLimit(); if (volume >= limit.MAX_CHECKS) { throw FaweCache.MAX_CHECKS; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/FlattenedClipboardTransform.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/FlattenedClipboardTransform.java index 14e3d3307..d32504ad4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/FlattenedClipboardTransform.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/FlattenedClipboardTransform.java @@ -79,12 +79,12 @@ public class FlattenedClipboardTransform { Vector3[] corners = new Vector3[]{ minimum, maximum, - minimum.withX(maximum.getX()), - minimum.withY(maximum.getY()), - minimum.withZ(maximum.getZ()), - maximum.withX(minimum.getX()), - maximum.withY(minimum.getY()), - maximum.withZ(minimum.getZ()) + minimum.withX(maximum.x()), + minimum.withY(maximum.y()), + minimum.withZ(maximum.z()), + maximum.withX(minimum.x()), + maximum.withY(minimum.y()), + maximum.withZ(minimum.z()) }; for (int i = 0; i < corners.length; i++) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java index 90b59cb52..4b2f98e0c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java @@ -440,13 +440,13 @@ public class GenerationCommands { zero = max.add(min).multiply(0.5); unit = max.subtract(zero); - if (unit.getX() == 0) { + if (unit.x() == 0) { unit = unit.withX(1.0); } - if (unit.getY() == 0) { + if (unit.y() == 0) { unit = unit.withY(1.0); } - if (unit.getZ() == 0) { + if (unit.z() == 0) { unit = unit.withZ(1.0); } } @@ -526,13 +526,13 @@ public class GenerationCommands { zero = max.add(min).multiply(0.5); unit = max.subtract(zero); - if (unit.getX() == 0) { + if (unit.x() == 0) { unit = unit.withX(1.0); } - if (unit.getY() == 0) { + if (unit.y() == 0) { unit = unit.withY(1.0); } - if (unit.getZ() == 0) { + if (unit.z() == 0) { unit = unit.withZ(1.0); } } @@ -636,7 +636,7 @@ public class GenerationCommands { MainUtil.checkImageHost(url.toURI()); if (dimensions != null) { checkCommandArgument( - (long) dimensions.getX() * dimensions.getZ() <= Settings.settings().WEB.MAX_IMAGE_SIZE, + (long) dimensions.x() * dimensions.z() <= Settings.settings().WEB.MAX_IMAGE_SIZE, Caption.of("fawe.error.image-dimensions", Settings.settings().WEB.MAX_IMAGE_SIZE) ); } @@ -644,7 +644,7 @@ public class GenerationCommands { Future future = executor.submit(() -> { BufferedImage image = MainUtil.readImage(url); if (dimensions != null) { - image = ImageUtil.getScaledInstance(image, dimensions.getBlockX(), dimensions.getBlockZ(), + image = ImageUtil.getScaledInstance(image, dimensions.x(), dimensions.z(), RenderingHints.VALUE_INTERPOLATION_BILINEAR, false ); } @@ -668,8 +668,8 @@ public class GenerationCommands { CuboidRegion region = new CuboidRegion(pos1, pos2); final BufferedImage finalImage = image; RegionVisitor visitor = new RegionVisitor(region, pos -> { - int x = pos.getBlockX() - pos1.getBlockX(); - int z = pos.getBlockZ() - pos1.getBlockZ(); + int x = pos.x() - pos1.x(); + int z = pos.z() - pos1.z(); int color = finalImage.getRGB(x, z); BlockType block = tu.getNearestBlock(color); if (block != null) { @@ -735,7 +735,7 @@ public class GenerationCommands { @Arg(desc = "double", def = "50") double amplitude ) throws WorldEditException { - double max = MathMan.max(radius.getX(), radius.getY(), radius.getZ()); + double max = MathMan.max(radius.x(), radius.y(), radius.z()); worldEdit.checkMaxRadius(max, actor); BlockVector3 pos = session.getPlacementPosition(actor); int affected = editSession.makeBlob( diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/HistorySubCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/HistorySubCommands.java index 08f48b265..8d28ad1eb 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/HistorySubCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/HistorySubCommands.java @@ -13,10 +13,7 @@ import com.fastasyncworldedit.core.util.MainUtil; import com.fastasyncworldedit.core.util.StringMan; import com.google.common.base.Function; import com.google.common.collect.Lists; -import com.sk89q.worldedit.EditSession; -import com.sk89q.worldedit.EditSessionBuilder; import com.sk89q.worldedit.LocalSession; -import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.command.argument.Arguments; import com.sk89q.worldedit.command.util.CommandPermissions; @@ -25,7 +22,6 @@ import com.sk89q.worldedit.command.util.annotation.Confirm; import com.sk89q.worldedit.command.util.annotation.Time; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Actor; -import com.sk89q.worldedit.function.operation.ChangeSetExecutor; import com.sk89q.worldedit.history.changeset.ChangeSet; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; @@ -245,11 +241,11 @@ public class HistorySubCommands { BlockVector3 pos1 = edit.getMinimumPoint(); BlockVector3 pos2 = edit.getMaximumPoint(); - double distanceX = Math.min(Math.abs(pos1.getX() - origin.getX()), Math.abs(pos2.getX() - origin.getX())); - double distanceZ = Math.min(Math.abs(pos1.getZ() - origin.getZ()), Math.abs(pos2.getZ() - origin.getZ())); + double distanceX = Math.min(Math.abs(pos1.x() - origin.x()), Math.abs(pos2.x() - origin.x())); + double distanceZ = Math.min(Math.abs(pos1.z() - origin.z()), Math.abs(pos2.z() - origin.z())); int distance = (int) Math.sqrt(distanceX * distanceX + distanceZ * distanceZ); - BlockVector2 dirVec = BlockVector2.at(edit.getOriginX() - origin.getX(), edit.getOriginZ() - origin.getZ()); + BlockVector2 dirVec = BlockVector2.at(edit.getOriginX() - origin.x(), edit.getOriginZ() - origin.z()); Direction direction = Direction.findClosest(dirVec.toVector3(), Direction.Flag.ALL); long seconds = (System.currentTimeMillis() - edit.getBDFile().lastModified()) / 1000; @@ -326,13 +322,13 @@ public class HistorySubCommands { BlockVector3 pos1 = rollback.getMinimumPoint(); BlockVector3 pos2 = rollback.getMaximumPoint(); - double distanceX = Math.min(Math.abs(pos1.getX() - origin.getX()), Math.abs(pos2.getX() - origin.getX())); - double distanceZ = Math.min(Math.abs(pos1.getZ() - origin.getZ()), Math.abs(pos2.getZ() - origin.getZ())); + double distanceX = Math.min(Math.abs(pos1.x() - origin.x()), Math.abs(pos2.x() - origin.x())); + double distanceZ = Math.min(Math.abs(pos1.z() - origin.z()), Math.abs(pos2.z() - origin.z())); int distance = (int) Math.sqrt(distanceX * distanceX + distanceZ * distanceZ); BlockVector2 dirVec = BlockVector2.at( - rollback.getOriginX() - origin.getX(), - rollback.getOriginZ() - origin.getZ() + rollback.getOriginX() - origin.x(), + rollback.getOriginZ() - origin.z() ); Direction direction = Direction.findClosest(dirVec.toVector3(), Direction.Flag.ALL); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java index 73cb34274..6a121aa02 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java @@ -351,8 +351,8 @@ public class RegionCommands { int affected = 0; while (iter.hasNext()) { BlockVector2 pos = iter.next(); - int x = pos.getBlockX(); - int z = pos.getBlockZ(); + int x = pos.x(); + int z = pos.z(); //FAWE start - world min/maxY y = editSession.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY); //FAWE end @@ -449,8 +449,8 @@ public class RegionCommands { //FAWE end BlockVector3 min = region.getMinimumPoint(); BlockVector3 max = region.getMaximumPoint(); - long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min - .getZ() + 1)); + long volume = (((long) max.x() - (long) min.x() + 1) * ((long) max.y() - (long) min.y() + 1) * ((long) max.z() - (long) min + .z() + 1)); FaweLimit limit = actor.getLimit(); if (volume >= limit.MAX_CHECKS) { throw FaweCache.MAX_CHECKS; @@ -772,13 +772,13 @@ public class RegionCommands { zero = max.add(min).divide(2); unit = max.subtract(zero); - if (unit.getX() == 0) { + if (unit.x() == 0) { unit = unit.withX(1.0); } - if (unit.getY() == 0) { + if (unit.y() == 0) { unit = unit.withY(1.0); } - if (unit.getZ() == 0) { + if (unit.z() == 0) { unit = unit.withZ(1.0); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java index a643742d2..d8e0943dc 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java @@ -262,12 +262,12 @@ public class SelectionCommands { actor.print(Caption.of( "worldedit.chunk.selected-multiple", - TextComponent.of(minChunk.getBlockX()), - TextComponent.of(minChunk.getBlockY()), - TextComponent.of(minChunk.getBlockZ()), - TextComponent.of(maxChunk.getBlockX()), - TextComponent.of(maxChunk.getBlockY()), - TextComponent.of(maxChunk.getBlockZ()) + TextComponent.of(minChunk.x()), + TextComponent.of(minChunk.y()), + TextComponent.of(minChunk.z()), + TextComponent.of(maxChunk.x()), + TextComponent.of(maxChunk.y()), + TextComponent.of(maxChunk.z()) )); } else { BlockVector3 minChunk; @@ -290,9 +290,9 @@ public class SelectionCommands { actor.print(Caption.of( "worldedit.chunk.selected", - TextComponent.of(minChunk.getBlockX()), - TextComponent.of(minChunk.getBlockY()), - TextComponent.of(minChunk.getBlockZ()) + TextComponent.of(minChunk.x()), + TextComponent.of(minChunk.y()), + TextComponent.of(minChunk.z()) )); } @@ -538,10 +538,10 @@ public class SelectionCommands { .subtract(region.getMinimumPoint()).add(1, 1, 1); BlockVector3 origin = clipboard.getOrigin(); - String sizeStr = size.getBlockX() + "*" + size.getBlockY() + "*" + size.getBlockZ(); - String originStr = origin.getBlockX() + "," + origin.getBlockY() + "," + origin.getBlockZ(); + String sizeStr = size.x() + "*" + size.y() + "*" + size.z(); + String originStr = origin.x() + "," + origin.y() + "," + origin.z(); - long numBlocks = ((long) size.getBlockX() * size.getBlockY() * size.getBlockZ()); + long numBlocks = ((long) size.x() * size.y() * size.z()); actor.print(Caption.of( "worldedit.size.offset", TextComponent.of(name), 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 a336f4b12..a289f7cff 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 @@ -50,19 +50,12 @@ import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats; import com.sk89q.worldedit.function.EntityFunction; -import com.sk89q.worldedit.function.block.BlockReplace; import com.sk89q.worldedit.function.mask.BlockTypeMask; -import com.sk89q.worldedit.function.mask.BoundedHeightMask; import com.sk89q.worldedit.function.mask.ExistingBlockMask; import com.sk89q.worldedit.function.mask.Mask; -import com.sk89q.worldedit.function.mask.MaskIntersection; -import com.sk89q.worldedit.function.mask.Masks; -import com.sk89q.worldedit.function.mask.RegionMask; import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.function.pattern.Pattern; -import com.sk89q.worldedit.function.visitor.DownwardVisitor; import com.sk89q.worldedit.function.visitor.EntityVisitor; -import com.sk89q.worldedit.function.visitor.RecursiveVisitor; import com.sk89q.worldedit.internal.annotation.Direction; import com.sk89q.worldedit.internal.annotation.VertHeight; import com.sk89q.worldedit.internal.expression.EvaluationException; @@ -70,10 +63,8 @@ import com.sk89q.worldedit.internal.expression.Expression; import com.sk89q.worldedit.internal.expression.ExpressionException; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector2; -import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CylinderRegion; -import com.sk89q.worldedit.regions.EllipsoidRegion; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.util.formatting.component.SubtleFormat; import com.sk89q.worldedit.util.formatting.text.Component; @@ -550,8 +541,8 @@ public class UtilityCommands { CylinderRegion region = new CylinderRegion( position, Vector2.at(size, size), - position.getBlockY() - height, - position.getBlockY() + height + position.y() - height, + position.y() + height ); int affected = editSession.simulateSnow(region, stack); actor.print(Caption.of( diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/OffsetConverter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/OffsetConverter.java index 88b74a05f..22c755cb5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/OffsetConverter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/OffsetConverter.java @@ -98,9 +98,9 @@ public class OffsetConverter implements ArgumentConverter { // Create an affine transform of the columns (col4 is empty due to no translation) AffineTransform transform = new AffineTransform( - m1.getX(), m2.getX(), m3.getX(), 0, - m1.getY(), m2.getY(), m3.getY(), 0, - m1.getZ(), m2.getZ(), m3.getZ(), 0 + m1.x(), m2.x(), m3.x(), 0, + m1.y(), m2.y(), m3.y(), 0, + m1.z(), m2.z(), m3.z(), 0 ); return transform diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java index c4d45d683..6021102a2 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java @@ -380,7 +380,7 @@ public class BrushTool pitch = 23 - (pitch / 4); d += (int) (Math.sin(Math.toRadians(pitch)) * 50); final Vector3 vector = loc.getDirection().withY(0).normalize().multiply(d) - .add(loc.getX(), loc.getY(), loc.getZ()); + .add(loc.x(), loc.y(), loc.z()); return offset(vector, loc).toBlockPoint(); } case TARGET_POINT_HEIGHT: { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/GravityBrush.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/GravityBrush.java index b82601288..bfa19b7e3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/GravityBrush.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/GravityBrush.java @@ -38,11 +38,11 @@ public class GravityBrush implements Brush { public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException { //FAWE start - Ours operates differently to upstream, but does the same - double endY = position.getY() + size; - double startPerformY = Math.max(editSession.getMinY(), position.getY() - size); + double endY = position.y() + size; + double startPerformY = Math.max(editSession.getMinY(), position.y() - size); double startCheckY = fullHeight ? editSession.getMinY() : startPerformY; - for (double x = position.getX() + size; x > position.getX() - size; --x) { - for (double z = position.getZ() + size; z > position.getZ() - size; --z) { + for (double x = position.x() + size; x > position.x() - size; --x) { + for (double z = position.z() + size; z > position.z() - size; --z) { double freeSpot = startCheckY; for (double y = startCheckY; y <= endY; y++) { BlockState block = editSession.getBlock((int) x, (int) y, (int) z); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/Confirm.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/Confirm.java index 37ea4abeb..b8980afc8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/Confirm.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/annotation/Confirm.java @@ -3,7 +3,6 @@ package com.sk89q.worldedit.command.util.annotation; import com.fastasyncworldedit.core.configuration.Caption; import com.fastasyncworldedit.core.util.task.InterruptableCondition; import com.sk89q.worldedit.IncompleteRegionException; -import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.command.argument.Arguments; import com.sk89q.worldedit.event.Event; import com.sk89q.worldedit.event.platform.CommandEvent; @@ -57,7 +56,7 @@ public @interface Confirm { .orElseThrow(IncompleteRegionException::new); BlockVector3 pos1 = region.getMinimumPoint(); BlockVector3 pos2 = region.getMaximumPoint(); - long area = (pos2.getX() - pos1.getX()) * (pos2.getZ() - pos1.getZ() + 1) + long area = (pos2.x() - pos1.x()) * (pos2.z() - pos1.z() + 1) * (long) value; long max = 2 << 18; if (max != -1 && area > max) { 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 ae4eb2144..5337fe720 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 @@ -162,8 +162,8 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { public void findFreePosition(Location searchPos) { Extent world = searchPos.getExtent(); - int worldMinY = world.getMinimumPoint().getY(); - int worldMaxY = world.getMaximumPoint().getY(); + int worldMinY = world.getMinimumPoint().y(); + int worldMaxY = world.getMaximumPoint().y(); int x = searchPos.getBlockX(); int y = Math.max(worldMinY, searchPos.getBlockY()); @@ -202,7 +202,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { public void setOnGround(Location searchPos) { Extent world = searchPos.getExtent(); - int worldMinY = world.getMinimumPoint().getY(); + int worldMinY = world.getMinimumPoint().y(); int x = searchPos.getBlockX(); int y = Math.max(worldMinY, searchPos.getBlockY()); @@ -436,7 +436,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { @Override public Location getBlockOn() { final Location location = getLocation(); - return location.setPosition(location.setY(location.getY() - 1).toVector().floor()); + return location.setPosition(location.setY(location.y() - 1).toVector().floor()); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java index 3d2a45642..6117c6850 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java @@ -504,8 +504,8 @@ public interface Extent extends InputExtent, OutputExtent { if (random.nextInt(100) > rarity) { continue; } - int x = (chunkPos.getBlockX() << 4) + random.nextInt(16); - int z = (chunkPos.getBlockZ() << 4) + random.nextInt(16); + int x = (chunkPos.x() << 4) + random.nextInt(16); + int z = (chunkPos.z() << 4) + random.nextInt(16); gen.spawn(random, x, z); } } @@ -534,9 +534,9 @@ public interface Extent extends InputExtent, OutputExtent { default boolean contains(int x, int y, int z) { BlockVector3 min = getMinimumPoint(); BlockVector3 max = getMaximumPoint(); - return min.getX() <= x && max.getX() >= x - && min.getY() <= y && max.getY() >= y - && min.getZ() <= z && max.getZ() >= z; + return min.x() <= x && max.x() >= x + && min.y() <= y && max.y() >= y + && min.z() <= z && max.z() >= z; } default void addOre( @@ -665,11 +665,11 @@ public interface Extent extends InputExtent, OutputExtent { } default int getMinY() { - return getMinimumPoint().getY(); + return getMinimumPoint().y(); } default int getMaxY() { - return getMaximumPoint().getY(); + return getMaximumPoint().y(); } /** @@ -832,9 +832,9 @@ public interface Extent extends InputExtent, OutputExtent { Vector3 center = region.getCenter(); Region centerRegion = new CuboidRegion( this instanceof World ? (World) this : null, // Causes clamping of Y range - BlockVector3.at(((int) center.getX()), ((int) center.getY()), ((int) center.getZ())), - BlockVector3.at(MathUtils.roundHalfUp(center.getX()), - center.getY(), MathUtils.roundHalfUp(center.getZ()) + BlockVector3.at(((int) center.x()), ((int) center.y()), ((int) center.z())), + BlockVector3.at(MathUtils.roundHalfUp(center.x()), + center.y(), MathUtils.roundHalfUp(center.z()) ) ); return setBlocks(centerRegion, pattern); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/InputExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/InputExtent.java index 58863920c..7393c7722 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/InputExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/InputExtent.java @@ -50,7 +50,7 @@ public interface InputExtent { * @return the block */ default BlockState getBlock(BlockVector3 position) { - return getBlock(position.getX(), position.getY(), position.getZ()); + return getBlock(position.x(), position.y(), position.z()); } //FAWE start @@ -65,7 +65,7 @@ public interface InputExtent { * @return the block */ default BaseBlock getFullBlock(BlockVector3 position) { - return getFullBlock(position.getX(), position.getY(), position.getZ()); + return getFullBlock(position.x(), position.y(), position.z()); } default BaseBlock getFullBlock(int x, int y, int z) { @@ -85,7 +85,7 @@ public interface InputExtent { */ @Deprecated default BiomeType getBiome(BlockVector2 position) { - return getBiomeType(position.getX(), 0, position.getZ()); + return getBiomeType(position.x(), 0, position.z()); } default BiomeType getBiomeType(int x, int y, int z) { @@ -126,7 +126,7 @@ public interface InputExtent { * @return the light level at the location */ default int getEmittedLight(BlockVector3 position) { - return getEmittedLight(position.getX(), position.getY(), position.getZ()); + return getEmittedLight(position.x(), position.y(), position.z()); } default int getEmittedLight(int x, int y, int z) { @@ -140,7 +140,7 @@ public interface InputExtent { * @return the sky light level at the location */ default int getSkyLight(MutableBlockVector3 position) { - return getSkyLight(position.getX(), position.getY(), position.getZ()); + return getSkyLight(position.x(), position.y(), position.z()); } default int getSkyLight(int x, int y, int z) { @@ -148,7 +148,7 @@ public interface InputExtent { } default int getBrightness(MutableBlockVector3 position) { - return getBrightness(position.getX(), position.getY(), position.getZ()); + return getBrightness(position.x(), position.y(), position.z()); } default int getBrightness(int x, int y, int z) { @@ -156,7 +156,7 @@ public interface InputExtent { } default int getOpacity(MutableBlockVector3 position) { - return getOpacity(position.getX(), position.getY(), position.getZ()); + return getOpacity(position.x(), position.y(), position.z()); } default int getOpacity(int x, int y, int z) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/OutputExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/OutputExtent.java index d90bce937..9346bf380 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/OutputExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/OutputExtent.java @@ -60,7 +60,7 @@ public interface OutputExtent { */ @Deprecated default > boolean setBlock(BlockVector3 position, T block) throws WorldEditException { - return setBlock(position.getX(), position.getY(), position.getZ(), block); + return setBlock(position.x(), position.y(), position.z(), block); } // The defaults need to remain for compatibility (the actual implementation still needs to override one of these) @@ -148,7 +148,7 @@ public interface OutputExtent { * @param value light level to set */ default void setBlockLight(BlockVector3 position, int value) { - setBlockLight(position.getX(), position.getY(), position.getZ(), value); + setBlockLight(position.x(), position.y(), position.z(), value); } default void setBlockLight(int x, int y, int z, int value) { @@ -161,7 +161,7 @@ public interface OutputExtent { * @param value light level to set */ default void setSkyLight(BlockVector3 position, int value) { - setSkyLight(position.getX(), position.getY(), position.getZ(), value); + setSkyLight(position.x(), position.y(), position.z(), value); } //FAWE end diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java index 7b6be41d2..b861dbd6b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java @@ -165,9 +165,9 @@ public class BlockArrayClipboard implements Clipboard { @Override public BlockState getBlock(BlockVector3 position) { if (region.contains(position)) { - int x = position.getBlockX() - offset.getX(); - int y = position.getBlockY() - offset.getY(); - int z = position.getBlockZ() - offset.getZ(); + int x = position.x() - offset.x(); + int y = position.y() - offset.y(); + int z = position.z() - offset.z(); return getParent().getBlock(x, y, z); } @@ -177,9 +177,9 @@ public class BlockArrayClipboard implements Clipboard { @Override public BaseBlock getFullBlock(BlockVector3 position) { if (region.contains(position)) { - int x = position.getBlockX() - offset.getX(); - int y = position.getBlockY() - offset.getY(); - int z = position.getBlockZ() - offset.getZ(); + int x = position.x() - offset.x(); + int y = position.y() - offset.y(); + int z = position.z() - offset.z(); return getParent().getFullBlock(x, y, z); } return BlockTypes.AIR.getDefaultState().toBaseBlock(); @@ -189,9 +189,9 @@ public class BlockArrayClipboard implements Clipboard { public > boolean setBlock(BlockVector3 position, B block) throws WorldEditException { if (region.contains(position)) { //FAWE - get points - final int x = position.getBlockX(); - final int y = position.getBlockY(); - final int z = position.getBlockZ(); + final int x = position.x(); + final int y = position.y(); + final int z = position.z(); return setBlock(x, y, z, block); //FAWE end } @@ -201,22 +201,22 @@ public class BlockArrayClipboard implements Clipboard { //FAWE start @Override public boolean setTile(int x, int y, int z, CompoundTag tag) { - x -= offset.getX(); - y -= offset.getY(); - z -= offset.getZ(); + x -= offset.x(); + y -= offset.y(); + z -= offset.z(); return getParent().setTile(x, y, z, tag); } public boolean setTile(BlockVector3 position, CompoundTag tag) { - return setTile(position.getX(), position.getY(), position.getZ(), tag); + return setTile(position.x(), position.y(), position.z(), tag); } @Override public > boolean setBlock(int x, int y, int z, B block) throws WorldEditException { - x -= offset.getX(); - y -= offset.getY(); - z -= offset.getZ(); + x -= offset.x(); + y -= offset.y(); + z -= offset.z(); return parent.setBlock(x, y, z, block); } @@ -230,25 +230,25 @@ public class BlockArrayClipboard implements Clipboard { if (!region.contains(position)) { return null; } - int x = position.getBlockX() - offset.getX(); - int y = position.getBlockY() - offset.getY(); - int z = position.getBlockZ() - offset.getZ(); + int x = position.x() - offset.x(); + int y = position.y() - offset.y(); + int z = position.z() - offset.z(); return getParent().getBiomeType(x, y, z); } @Override public boolean setBiome(BlockVector3 position, BiomeType biome) { - int x = position.getBlockX() - offset.getX(); - int y = position.getBlockY() - offset.getY(); - int z = position.getBlockZ() - offset.getZ(); + int x = position.x() - offset.x(); + int y = position.y() - offset.y(); + int z = position.z() - offset.z(); return getParent().setBiome(x, y, z, biome); } @Override public boolean setBiome(int x, int y, int z, BiomeType biome) { - x -= offset.getX(); - y -= offset.getY(); - z -= offset.getZ(); + x -= offset.x(); + y -= offset.y(); + z -= offset.z(); return getParent().setBiome(x, y, z, biome); } @@ -262,9 +262,9 @@ public class BlockArrayClipboard implements Clipboard { ClipboardEntity ce = (ClipboardEntity) e; Location oldloc = ce.getLocation(); Location loc = new Location(oldloc.getExtent(), - oldloc.getX() + offset.getBlockX(), - oldloc.getY() + offset.getBlockY(), - oldloc.getZ() + offset.getBlockZ(), + oldloc.x() + offset.x(), + oldloc.y() + offset.y(), + oldloc.z() + offset.z(), oldloc.getYaw(), oldloc.getPitch() ); return new ClipboardEntity(loc, ce.entity); @@ -281,9 +281,9 @@ public class BlockArrayClipboard implements Clipboard { ClipboardEntity ce = (ClipboardEntity) e; Location oldloc = ce.getLocation(); Location loc = new Location(oldloc.getExtent(), - oldloc.getX() + offset.getBlockX(), - oldloc.getY() + offset.getBlockY(), - oldloc.getZ() + offset.getBlockZ(), + oldloc.x() + offset.x(), + oldloc.y() + offset.y(), + oldloc.z() + offset.z(), oldloc.getYaw(), oldloc.getPitch() ); return new ClipboardEntity(loc, ce.entity); @@ -296,9 +296,9 @@ public class BlockArrayClipboard implements Clipboard { @Nullable public Entity createEntity(Location location, BaseEntity entity) { Location l = new Location(location.getExtent(), - location.getX() - offset.getBlockX(), - location.getY() - offset.getBlockY(), - location.getZ() - offset.getBlockZ(), + location.x() - offset.x(), + location.y() - offset.y(), + location.z() - offset.z(), location.getYaw(), location.getPitch() ); return getParent().createEntity(l, entity); @@ -308,9 +308,9 @@ public class BlockArrayClipboard implements Clipboard { @Nullable public Entity createEntity(Location location, BaseEntity entity, UUID uuid) { Location l = new Location(location.getExtent(), - location.getX() - offset.getBlockX(), - location.getY() - offset.getBlockY(), - location.getZ() - offset.getBlockZ(), + location.x() - offset.x(), + location.y() - offset.y(), + location.z() - offset.z(), location.getYaw(), location.getPitch() ); return getParent().createEntity(l, entity, uuid); @@ -318,33 +318,33 @@ public class BlockArrayClipboard implements Clipboard { @Override public void removeEntity(int x, int y, int z, UUID uuid) { - x -= offset.getX(); - y -= offset.getY(); - z -= offset.getZ(); + x -= offset.x(); + y -= offset.y(); + z -= offset.z(); getParent().removeEntity(x, y, z, uuid); } @Override public BlockState getBlock(int x, int y, int z) { - x -= offset.getX(); - y -= offset.getY(); - z -= offset.getZ(); + x -= offset.x(); + y -= offset.y(); + z -= offset.z(); return getParent().getBlock(x, y, z); } @Override public BaseBlock getFullBlock(int x, int y, int z) { - x -= offset.getX(); - y -= offset.getY(); - z -= offset.getZ(); + x -= offset.x(); + y -= offset.y(); + z -= offset.z(); return getParent().getFullBlock(x, y, z); } @Override public BiomeType getBiomeType(int x, int y, int z) { - x -= offset.getX(); - y -= offset.getY(); - z -= offset.getZ(); + x -= offset.x(); + y -= offset.y(); + z -= offset.z(); return getParent().getBiomeType(x, y, z); } @@ -359,7 +359,7 @@ public class BlockArrayClipboard implements Clipboard { public Iterator iterator2d() { MutableBlockVector2 mutable = new MutableBlockVector2(); return Iterators.transform(getParent().iterator2d(), input -> - mutable.setComponents(input.getX() + offset.getX(), input.getZ() + offset.getZ())); + mutable.setComponents(input.x() + offset.x(), input.z() + offset.z())); } @Override @@ -409,7 +409,7 @@ public class BlockArrayClipboard implements Clipboard { private final float pitch; public ClipboardEntity(Location loc, BaseEntity entity) { - this((Clipboard) loc.getExtent(), loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch(), entity); + this((Clipboard) loc.getExtent(), loc.x(), loc.y(), loc.z(), loc.getYaw(), loc.getPitch(), entity); } public ClipboardEntity(Clipboard clipboard, double x, double y, double z, float yaw, float pitch, BaseEntity entity) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/Clipboard.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/Clipboard.java index 76e866c33..d52fd1056 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/Clipboard.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/Clipboard.java @@ -163,15 +163,15 @@ public interface Clipboard extends Extent, Iterable, Closeable, Fl void removeEntity(Entity entity); default int getWidth() { - return getDimensions().getBlockX(); + return getDimensions().x(); } default int getHeight() { - return getDimensions().getBlockY(); + return getDimensions().y(); } default int getLength() { - return getDimensions().getBlockZ(); + return getDimensions().z(); } default int getArea() { @@ -380,17 +380,17 @@ public interface Clipboard extends Extent, Iterable, Closeable, Fl final BlockVector3 origin = this.getOrigin(); // To must be relative to the clipboard origin ( player location - clipboard origin ) (as the locations supplied are relative to the world origin) - final int relx = to.getBlockX() - origin.getBlockX(); - final int rely = to.getBlockY() - origin.getBlockY(); - final int relz = to.getBlockZ() - origin.getBlockZ(); + final int relx = to.x() - origin.x(); + final int rely = to.y() - origin.y(); + final int relz = to.z() - origin.z(); pasteBiomes &= Clipboard.this.hasBiomes(); for (BlockVector3 pos : this) { BaseBlock block = pos.getFullBlock(this); - int xx = pos.getX() + relx; - int yy = pos.getY() + rely; - int zz = pos.getZ() + relz; + int xx = pos.x() + relx; + int yy = pos.y() + rely; + int zz = pos.z() + relz; if (pasteBiomes) { extent.setBiome(xx, yy, zz, pos.getBiome(this)); } @@ -400,9 +400,9 @@ public interface Clipboard extends Extent, Iterable, Closeable, Fl extent.setBlock(xx, yy, zz, block); } // Entity offset is the paste location subtract the clipboard origin (entity's location is already relative to the world origin) - final int entityOffsetX = to.getBlockX() - origin.getBlockX(); - final int entityOffsetY = to.getBlockY() - origin.getBlockY(); - final int entityOffsetZ = to.getBlockZ() - origin.getBlockZ(); + final int entityOffsetX = to.x() - origin.x(); + final int entityOffsetY = to.y() - origin.y(); + final int entityOffsetZ = to.z() - origin.z(); // entities if (pasteEntities) { for (Entity entity : this.getEntities()) { @@ -412,8 +412,8 @@ public interface Clipboard extends Extent, Iterable, Closeable, Fl continue; } Location pos = entity.getLocation(); - Location newPos = new Location(pos.getExtent(), pos.getX() + entityOffsetX, - pos.getY() + entityOffsetY, pos.getZ() + entityOffsetZ, pos.getYaw(), + Location newPos = new Location(pos.getExtent(), pos.x() + entityOffsetX, + pos.y() + entityOffsetY, pos.z() + entityOffsetZ, pos.getYaw(), pos.getPitch() ); extent.createEntity(newPos, entity.getState()); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardWriter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardWriter.java index b7cf7a050..d3420f658 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardWriter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardWriter.java @@ -50,9 +50,9 @@ public interface ClipboardWriter extends Closeable { //FAWE start default Tag writeVector(Vector3 vector) { List list = new ArrayList<>(); - list.add(new DoubleTag(vector.getX())); - list.add(new DoubleTag(vector.getY())); - list.add(new DoubleTag(vector.getZ())); + list.add(new DoubleTag(vector.x())); + list.add(new DoubleTag(vector.y())); + list.add(new DoubleTag(vector.z())); return new ListTag(DoubleTag.class, list); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java index 83d8c3007..a140b666a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java @@ -263,9 +263,9 @@ public class SpongeSchematicReader extends NBTSchematicReader { int[] pos = requireTag(tileEntity, "Pos", IntArrayTag.class).getValue(); final BlockVector3 pt = BlockVector3.at(pos[0], pos[1], pos[2]); Map values = Maps.newHashMap(tileEntity); - values.put("x", new IntTag(pt.getBlockX())); - values.put("y", new IntTag(pt.getBlockY())); - values.put("z", new IntTag(pt.getBlockZ())); + values.put("x", new IntTag(pt.x())); + values.put("y", new IntTag(pt.y())); + values.put("z", new IntTag(pt.z())); //FAWE start - support old, corrupt schematics Tag id = values.get("Id"); if (id == null) { @@ -378,7 +378,7 @@ public class SpongeSchematicReader extends NBTSchematicReader { palette.put(((IntTag) idTag).getValue(), biome); } - int width = clipboard.getDimensions().getX(); + int width = clipboard.getDimensions().x(); byte[] biomes = dataTag.getValue(); int biomeIndex = 0; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicWriter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicWriter.java index 2a10e9f4b..24860dd3c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicWriter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicWriter.java @@ -117,9 +117,9 @@ public class SpongeSchematicWriter implements ClipboardWriter { WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING).getDataVersion())); Map metadata = new HashMap<>(); - metadata.put("WEOffsetX", new IntTag(offset.getBlockX())); - metadata.put("WEOffsetY", new IntTag(offset.getBlockY())); - metadata.put("WEOffsetZ", new IntTag(offset.getBlockZ())); + metadata.put("WEOffsetX", new IntTag(offset.x())); + metadata.put("WEOffsetY", new IntTag(offset.y())); + metadata.put("WEOffsetZ", new IntTag(offset.z())); metadata.put("FAWEVersion", new IntTag(Fawe.instance().getVersion().build)); schematic.put("Metadata", new CompoundTag(metadata)); @@ -130,9 +130,9 @@ public class SpongeSchematicWriter implements ClipboardWriter { // The Sponge format Offset refers to the 'min' points location in the world. That's our 'Origin' schematic.put("Offset", new IntArrayTag(new int[]{ - min.getBlockX(), - min.getBlockY(), - min.getBlockZ(), + min.x(), + min.y(), + min.z(), })); int paletteMax = 0; @@ -143,11 +143,11 @@ public class SpongeSchematicWriter implements ClipboardWriter { ByteArrayOutputStream buffer = new ByteArrayOutputStream(width * height * length); for (int y = 0; y < height; y++) { - int y0 = min.getBlockY() + y; + int y0 = min.y() + y; for (int z = 0; z < length; z++) { - int z0 = min.getBlockZ() + z; + int z0 = min.z() + z; for (int x = 0; x < width; x++) { - int x0 = min.getBlockX() + x; + int x0 = min.x() + x; BlockVector3 point = BlockVector3.at(x0, y0, z0); BaseBlock block = clipboard.getFullBlock(point); if (block.getNbtData() != null) { @@ -217,10 +217,10 @@ public class SpongeSchematicWriter implements ClipboardWriter { Map palette = new HashMap<>(); for (int z = 0; z < length; z++) { - int z0 = min.getBlockZ() + z; + int z0 = min.z() + z; for (int x = 0; x < width; x++) { - int x0 = min.getBlockX() + x; - BlockVector3 pt = BlockVector3.at(x0, min.getBlockY(), z0); + int x0 = min.x() + x; + BlockVector3 pt = BlockVector3.at(x0, min.y(), z0); BiomeType biome = clipboard.getBiome(pt); String biomeKey = biome.getId(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagExtent.java index ff516e4c9..18e69c7a0 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagExtent.java @@ -104,7 +104,7 @@ public class BlockBagExtent extends AbstractDelegateExtent { @Override public > boolean setBlock(BlockVector3 position, B block) throws WorldEditException { - return setBlock(position.getX(), position.getY(), position.getZ(), block); + return setBlock(position.x(), position.y(), position.z(), block); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java index f22d7036d..d9effa512 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java @@ -391,9 +391,9 @@ public class BlockTransformExtent extends ResettableExtent { if (direction != null) { Vector3 applyAbsolute = transform.apply(direction.toVector()); Vector3 applyOrigin = transform.apply(Vector3.ZERO); - applyAbsolute.mutX(applyAbsolute.getX() - applyOrigin.getX()); - applyAbsolute.mutY(applyAbsolute.getY() - applyOrigin.getY()); - applyAbsolute.mutZ(applyAbsolute.getZ() - applyOrigin.getZ()); + applyAbsolute.mutX(applyAbsolute.x() - applyOrigin.x()); + applyAbsolute.mutY(applyAbsolute.y() - applyOrigin.y()); + applyAbsolute.mutZ(applyAbsolute.z() - applyOrigin.z()); Direction newDirection = Direction.findClosest( applyAbsolute, diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/DataValidatorExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/DataValidatorExtent.java index bc498711b..1161779d9 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/DataValidatorExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/DataValidatorExtent.java @@ -63,7 +63,7 @@ public class DataValidatorExtent extends AbstractDelegateExtent { @Override public > boolean setBlock(BlockVector3 location, B block) throws WorldEditException { - final int y = location.getBlockY(); + final int y = location.y(); final BlockType type = block.getBlockType(); if (y < minY || y > maxY) { return false; @@ -79,7 +79,7 @@ public class DataValidatorExtent extends AbstractDelegateExtent { @Override public boolean setBiome(BlockVector3 location, BiomeType biome) { - final int y = location.getBlockY(); + final int y = location.y(); if (y < minY || y > maxY) { return false; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/SideEffectExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/SideEffectExtent.java index 5a90aebbb..413bd31bf 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/SideEffectExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/SideEffectExtent.java @@ -88,7 +88,7 @@ public class SideEffectExtent extends AbstractDelegateExtent { @Override public > boolean setBlock(BlockVector3 location, B block) throws WorldEditException { if (sideEffectSet.getState(SideEffect.LIGHTING) == SideEffect.State.DELAYED) { - dirtyChunks.add(BlockVector2.at(location.getBlockX() >> 4, location.getBlockZ() >> 4)); + dirtyChunks.add(BlockVector2.at(location.x() >> 4, location.z() >> 4)); } if (postEditSimulation) { positions.put(location, world.getBlock(location)); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/biome/BiomeReplace.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/biome/BiomeReplace.java index 6ae4ad2ec..90d7f31cf 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/biome/BiomeReplace.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/biome/BiomeReplace.java @@ -70,7 +70,7 @@ public class BiomeReplace implements FlatRegionFunction, RegionFunction { @Deprecated public boolean apply(BlockVector2 position) throws WorldEditException { boolean success = false; - for (int y = extent.getMinimumPoint().getY(); y <= extent.getMaximumPoint().getY(); y++) { + for (int y = extent.getMinimumPoint().y(); y <= extent.getMaximumPoint().y(); y++) { success |= apply(position.toBlockVector3(y)); } return success; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/biome/ExtentBiomeCopy.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/biome/ExtentBiomeCopy.java index 076c1f561..5643da36a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/biome/ExtentBiomeCopy.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/biome/ExtentBiomeCopy.java @@ -102,7 +102,7 @@ public class ExtentBiomeCopy implements FlatRegionFunction, RegionFunction { @Deprecated public boolean apply(BlockVector2 position) throws WorldEditException { boolean success = false; - for (int y = destination.getMinimumPoint().getY(); y <= destination.getMaximumPoint().getY(); y++) { + for (int y = destination.getMinimumPoint().y(); y <= destination.getMaximumPoint().y(); y++) { success |= apply(position.toBlockVector3(y)); } return success; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/SnowSimulator.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/SnowSimulator.java index c84fcc67a..4027220b2 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/SnowSimulator.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/SnowSimulator.java @@ -105,7 +105,7 @@ public class SnowSimulator implements LayerFunction { // Can't put snow this far up - if (position.getBlockY() == this.extent.getMaximumPoint().getBlockY()) { + if (position.y() == this.extent.getMaximumPoint().y()) { return false; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/entity/ExtentEntityCopy.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/entity/ExtentEntityCopy.java index fa3ef1dc4..149464bef 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/entity/ExtentEntityCopy.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/entity/ExtentEntityCopy.java @@ -206,9 +206,9 @@ public class ExtentEntityCopy implements EntityFunction { BlockVector3 newLeash = transform.apply(tilePosition.subtract(from)).add(to).toBlockPoint(); return new BaseEntity(state.getType(), tag.createBuilder() .put("Leash", leashCompound.createBuilder() - .putInt("X", newLeash.getBlockX()) - .putInt("Y", newLeash.getBlockY()) - .putInt("Z", newLeash.getBlockZ()) + .putInt("X", newLeash.x()) + .putInt("Y", newLeash.y()) + .putInt("Z", newLeash.z()) .build() ).build()); } @@ -226,9 +226,9 @@ public class ExtentEntityCopy implements EntityFunction { BlockVector3 newTilePosition = transform.apply(tilePosition.subtract(from)).add(to).toBlockPoint(); CompoundTagBuilder builder = tag.createBuilder() - .putInt("TileX", newTilePosition.getBlockX()) - .putInt("TileY", newTilePosition.getBlockY()) - .putInt("TileZ", newTilePosition.getBlockZ()); + .putInt("TileX", newTilePosition.x()) + .putInt("TileY", newTilePosition.y()) + .putInt("TileZ", newTilePosition.z()); if (hasFacing) { boolean isPainting = state.getType() == EntityTypes.PAINTING; // Paintings have different facing values diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/factory/ApplyLayer.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/factory/ApplyLayer.java index 88e3218c0..c7ecc1207 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/factory/ApplyLayer.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/factory/ApplyLayer.java @@ -53,8 +53,8 @@ public class ApplyLayer implements Contextual { return new LayerVisitor( localRegion, - localRegion.getMinimumPoint().getY(), - localRegion.getMaximumPoint().getY(), + localRegion.getMinimumPoint().y(), + localRegion.getMaximumPoint().y(), function.createFromContext(context), //FAWE start - provide extent for preloading context.getDestination() diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/factory/Deform.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/factory/Deform.java index 115c05044..b4ccd0a55 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/factory/Deform.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/factory/Deform.java @@ -141,13 +141,13 @@ public class Deform implements Contextual { zero = max.add(min).multiply(0.5); unit = max.subtract(zero); - if (unit.getX() == 0) { + if (unit.x() == 0) { unit = unit.withX(1.0); } - if (unit.getY() == 0) { + if (unit.y() == 0) { unit = unit.withY(1.0); } - if (unit.getZ() == 0) { + if (unit.z() == 0) { unit = unit.withZ(1.0); } break; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BoundedHeightMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BoundedHeightMask.java index dfe1841d4..808465416 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BoundedHeightMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BoundedHeightMask.java @@ -48,7 +48,7 @@ public class BoundedHeightMask extends AbstractMask { @Override public boolean test(BlockVector3 vector) { - return vector.getY() >= minY && vector.getY() <= maxY; + return vector.y() >= minY && vector.y() <= maxY; } @Nullable diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExpressionMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExpressionMask.java index 1b95057ba..e5647332e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExpressionMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExpressionMask.java @@ -73,10 +73,10 @@ public class ExpressionMask extends AbstractMask { ((WorldEditExpressionEnvironment) expression.getEnvironment()).setCurrentBlock(vector.toVector3()); } if (timeout == null) { - return expression.evaluate(vector.getX(), vector.getY(), vector.getZ()) > 0; + return expression.evaluate(vector.x(), vector.y(), vector.z()) > 0; } else { return expression.evaluate( - new double[]{vector.getX(), vector.getY(), vector.getZ()}, + new double[]{vector.x(), vector.y(), vector.z()}, timeout.getAsInt() ) > 0; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExpressionMask2D.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExpressionMask2D.java index 0d2854b7c..7d5e22e99 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExpressionMask2D.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExpressionMask2D.java @@ -63,9 +63,9 @@ public class ExpressionMask2D extends AbstractMask2D { public boolean test(BlockVector2 vector) { try { if (timeout == null) { - return expression.evaluate(vector.getX(), 0, vector.getZ()) > 0; + return expression.evaluate(vector.x(), 0, vector.z()) > 0; } else { - return expression.evaluate(timeout.getAsInt(), vector.getX(), 0, vector.getZ()) > 0; + return expression.evaluate(timeout.getAsInt(), vector.x(), 0, vector.z()) > 0; } } catch (EvaluationException e) { return false; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/NoiseFilter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/NoiseFilter.java index 684148505..d0a016639 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/NoiseFilter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/NoiseFilter.java @@ -97,7 +97,7 @@ public class NoiseFilter extends AbstractMask { @Override public boolean test(BlockVector3 vector) { //FAWE start - mutable - return noiseGenerator.noise(mutable.setComponents(vector.getX(), vector.getZ(), vector.getZ())) <= density; + return noiseGenerator.noise(mutable.setComponents(vector.x(), vector.z(), vector.z())) <= density; //FAWE end } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/OffsetMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/OffsetMask.java index 2c809ada4..39eda315b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/OffsetMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/OffsetMask.java @@ -116,7 +116,7 @@ public class OffsetMask extends AbstractMask { public boolean test(BlockVector3 vector) { //FAWE start - ignore resultant position outside world height range BlockVector3 testPos = vector.add(offset); - if (testPos.getBlockY() < minY || testPos.getBlockY() > maxY) { + if (testPos.y() < minY || testPos.y() > maxY) { return false; } return getMask().test(testPos); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/OffsetMask2D.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/OffsetMask2D.java index 3e70c9ddd..f08811513 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/OffsetMask2D.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/OffsetMask2D.java @@ -89,13 +89,13 @@ public class OffsetMask2D extends AbstractMask2D { //FAWE start @Override public boolean test(BlockVector2 vector) { - mutableBlockVector2.setComponents(vector.getX() + offset.getX(), vector.getZ() + offset.getZ()); + mutableBlockVector2.setComponents(vector.x() + offset.x(), vector.z() + offset.z()); return getMask().test(mutableBlockVector2); } @Override public Mask2D copy2D() { - return new OffsetMask2D(mask.copy2D(), BlockVector2.at(offset.getX(), offset.getZ())); + return new OffsetMask2D(mask.copy2D(), BlockVector2.at(offset.x(), offset.z())); } //FAWE end diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/BackwardsExtentBlockCopy.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/BackwardsExtentBlockCopy.java index f766cf8d7..75018d96d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/BackwardsExtentBlockCopy.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/BackwardsExtentBlockCopy.java @@ -52,9 +52,9 @@ public class BackwardsExtentBlockCopy extends RegionVisitor implements Operation BlockVector3 max = BlockVector3.at(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE); BlockVector3 pos1 = region.getMinimumPoint(); BlockVector3 pos2 = region.getMaximumPoint(); - for (int x : new int[]{pos1.getBlockX(), pos2.getBlockX()}) { - for (int y : new int[]{pos1.getBlockY(), pos2.getBlockY()}) { - for (int z : new int[]{pos1.getBlockZ(), pos2.getBlockZ()}) { + for (int x : new int[]{pos1.x(), pos2.x()}) { + for (int y : new int[]{pos1.y(), pos2.y()}) { + for (int z : new int[]{pos1.z(), pos2.z()}) { BlockVector3 pt = transform(transform, BlockVector3.at(x, y, z)); min = min.getMinimum(pt); max = max.getMaximum(pt); @@ -65,13 +65,13 @@ public class BackwardsExtentBlockCopy extends RegionVisitor implements Operation } private BlockVector3 transform(Transform transform, BlockVector3 pt) { - mutV3.mutX(((pt.getBlockX() - origin.getBlockX()))); - mutV3.mutY(((pt.getBlockY() - origin.getBlockY()))); - mutV3.mutZ(((pt.getBlockZ() - origin.getBlockZ()))); + mutV3.mutX(((pt.x() - origin.x()))); + mutV3.mutY(((pt.y() - origin.y()))); + mutV3.mutZ(((pt.z() - origin.z()))); Vector3 tmp = transform.apply(mutV3); - mutBV3.mutX((tmp.getBlockX() + origin.getBlockX())); - mutBV3.mutY((tmp.getBlockY() + origin.getBlockY())); - mutBV3.mutZ((tmp.getBlockZ() + origin.getBlockZ())); + mutBV3.mutX((tmp.getBlockX() + origin.x())); + mutBV3.mutY((tmp.getBlockY() + origin.y())); + mutBV3.mutZ((tmp.getBlockZ() + origin.z())); return mutBV3; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/ForwardExtentCopy.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/ForwardExtentCopy.java index 99ee125ed..f98d5f924 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/ForwardExtentCopy.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/ForwardExtentCopy.java @@ -306,9 +306,9 @@ public class ForwardExtentCopy implements Operation { if (!translation.equals(BlockVector3.ZERO)) { finalDest = new BlockTranslateExtent( finalDest, - translation.getBlockX(), - translation.getBlockY(), - translation.getBlockZ() + translation.x(), + translation.y(), + translation.z() ); } //FAWE end @@ -349,21 +349,21 @@ public class ForwardExtentCopy implements Operation { if (sourceFunction != null) { BlockVector3 disAbs = translation.abs(); BlockVector3 size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1); - boolean overlap = (disAbs.getBlockX() < size.getBlockX() && disAbs.getBlockY() < size.getBlockY() && disAbs.getBlockZ() < size - .getBlockZ()); + boolean overlap = (disAbs.x() < size.x() && disAbs.y() < size.y() && disAbs.z() < size + .z()); RegionFunction copySrcFunc = sourceFunction; if (overlap && translation.length() != 0) { - int x = translation.getBlockX(); - int y = translation.getBlockY(); - int z = translation.getBlockZ(); + int x = translation.x(); + int y = translation.y(); + int z = translation.z(); maskFunc = position -> { BlockVector3 bv = BlockVector3.at( - position.getBlockX() + x, - position.getBlockY() + y, - position.getBlockZ() + z + position.x() + x, + position.y() + y, + position.z() + z ); if (region.contains(bv)) { return sourceFunction.apply(bv); @@ -373,9 +373,9 @@ public class ForwardExtentCopy implements Operation { copySrcFunc = position -> { BlockVector3 bv = BlockVector3.at( - position.getBlockX() - x, - position.getBlockY() - y, - position.getBlockZ() - z + position.x() - x, + position.y() - y, + position.z() - z ); if (!region.contains(bv)) { return sourceFunction.apply(position); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RandomPattern.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RandomPattern.java index c45629e5f..bc13fe4de 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RandomPattern.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RandomPattern.java @@ -107,12 +107,12 @@ public class RandomPattern extends AbstractPattern { @Override public BaseBlock applyBlock(BlockVector3 position) { - return collection.next(position.getBlockX(), position.getBlockY(), position.getBlockZ()).applyBlock(position); + return collection.next(position.x(), position.y(), position.z()).applyBlock(position); } @Override public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException { - return collection.next(get.getBlockX(), get.getBlockY(), get.getBlockZ()).apply(extent, get, set); + return collection.next(get.x(), get.y(), get.z()).apply(extent, get, set); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RepeatingExtentPattern.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RepeatingExtentPattern.java index 490c47cf2..ed62f92d8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RepeatingExtentPattern.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RepeatingExtentPattern.java @@ -88,9 +88,9 @@ public class RepeatingExtentPattern extends AbstractExtentPattern { @Override public BaseBlock applyBlock(BlockVector3 position) { //FAWE start - calculate offset - int x = Math.floorMod(position.getBlockX() + offset.getBlockX(), size.getBlockX()) + origin.getBlockX(); - int y = Math.floorMod(position.getBlockY() + offset.getBlockY(), size.getBlockY()) + origin.getBlockY(); - int z = Math.floorMod(position.getBlockZ() + offset.getBlockZ(), size.getBlockZ()) + origin.getBlockZ(); + int x = Math.floorMod(position.x() + offset.x(), size.x()) + origin.x(); + int y = Math.floorMod(position.y() + offset.y(), size.y()) + origin.y(); + int z = Math.floorMod(position.z() + offset.z(), size.z()) + origin.z(); //FAWE end return getExtent().getFullBlock(x, y, z); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/BreadthFirstSearch.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/BreadthFirstSearch.java index 7f3e5da63..796f02700 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/BreadthFirstSearch.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/BreadthFirstSearch.java @@ -305,10 +305,10 @@ public abstract class BreadthFirstSearch implements Operation { if (loadCount > Settings.settings().QUEUE.PRELOAD_CHUNK_COUNT) { break outer; } - int x = from.getBlockX() + direction.getBlockX(); - int z = from.getBlockZ() + direction.getBlockX(); + int x = from.x() + direction.x(); + int z = from.z() + direction.x(); if (cx != (cx = x >> 4) || cz != (cz = z >> 4)) { - int y = from.getBlockY() + direction.getBlockY(); + int y = from.y() + direction.y(); if (y < singleQueue.getMinY() || y > singleQueue.getMaxY()) { continue; } @@ -320,7 +320,7 @@ public abstract class BreadthFirstSearch implements Operation { } } for (BlockVector3 chunk : chunkLoadSet) { - singleQueue.addChunkLoad(chunk.getBlockX(), chunk.getBlockZ()); + singleQueue.addChunkLoad(chunk.x(), chunk.z()); } } for (BlockVector3 from : queue) { @@ -329,12 +329,12 @@ public abstract class BreadthFirstSearch implements Operation { } for (int i = 0, j = 0; i < dirs.length && j < maxBranch; i++) { BlockVector3 direction = dirs[i]; - int y = from.getBlockY() + direction.getY(); + int y = from.y() + direction.y(); if (y < minY || y > maxY) { continue; } - int x = from.getBlockX() + direction.getX(); - int z = from.getBlockZ() + direction.getZ(); + int x = from.x() + direction.x(); + int z = from.z() + direction.z(); if (!visited.contains(x, y, z)) { if (isVisitable(from, mutable.setComponents(x, y, z))) { j++; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/DownwardVisitor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/DownwardVisitor.java index f8204b085..2e5f07736 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/DownwardVisitor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/DownwardVisitor.java @@ -102,8 +102,8 @@ public class DownwardVisitor extends RecursiveVisitor { @Override protected boolean isVisitable(BlockVector3 from, BlockVector3 to) { - int fromY = from.getBlockY(); - return (fromY == baseY || to.subtract(from).getBlockY() < 0) && super.isVisitable(from, to); + int fromY = from.y(); + return (fromY == baseY || to.subtract(from).y() < 0) && super.isVisitable(from, to); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/RegionVisitor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/RegionVisitor.java index ff6b67e03..5ed98c354 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/RegionVisitor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/RegionVisitor.java @@ -111,8 +111,8 @@ public class RegionVisitor implements Operation { while (trailIter.hasNext()) { BlockVector3 pt = trailIter.next(); apply(pt); - int cx = pt.getBlockX() >> 4; - int cz = pt.getBlockZ() >> 4; + int cx = pt.x() >> 4; + int cz = pt.z() >> 4; if (cx != lastTrailChunkX || cz != lastTrailChunkZ) { lastTrailChunkX = cx; lastTrailChunkZ = cz; @@ -128,8 +128,8 @@ public class RegionVisitor implements Operation { lead: for (int count = 0; count < amount; ) { BlockVector3 v = leadIter.next(); - int vcx = v.getBlockX() >> 4; - int vcz = v.getBlockZ() >> 4; + int vcx = v.x() >> 4; + int vcz = v.z() >> 4; if (vcx != lastLeadChunkX || vcz != lastLeadChunkZ) { lastLeadChunkX = vcx; lastLeadChunkZ = vcz; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/history/changeset/ArrayListHistory.java b/worldedit-core/src/main/java/com/sk89q/worldedit/history/changeset/ArrayListHistory.java index ff624e81e..1bad79fb9 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/history/changeset/ArrayListHistory.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/history/changeset/ArrayListHistory.java @@ -83,7 +83,7 @@ public class ArrayListHistory implements ChangeSet { if (change instanceof BlockChange) { BlockChange blockChange = (BlockChange) change; BlockVector3 pos = blockChange.getPosition(); - summary.add(pos.getX(), pos.getZ(), blockChange.getCurrent().getOrdinal()); + summary.add(pos.x(), pos.z(), blockChange.getCurrent().getOrdinal()); } } return summary; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/anvil/ChunkDeleter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/anvil/ChunkDeleter.java index e4dcd99ab..1c88a1f2d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/anvil/ChunkDeleter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/anvil/ChunkDeleter.java @@ -54,7 +54,7 @@ public final class ChunkDeleter { private static final Logger LOGGER = LogManagerCompat.getLogger(); private static final Comparator chunkSorter = Comparator.comparing( - pos -> (pos.getBlockX() & 31) + (pos.getBlockZ() & 31) * 32 + pos -> (pos.x() & 31) + (pos.z() & 31) * 32 ); private static final Gson chunkDeleterGson = new GsonBuilder() @@ -182,15 +182,15 @@ public final class ChunkDeleter { int startZ = regZ << 5; int endZ = (regZ << 5) + 31; - int minX = Math.max(Math.min(startX, endX), minChunk.getBlockX()); - int minZ = Math.max(Math.min(startZ, endZ), minChunk.getBlockZ()); - int maxX = Math.min(Math.max(startX, endX), maxChunk.getBlockX()); - int maxZ = Math.min(Math.max(startZ, endZ), maxChunk.getBlockZ()); + int minX = Math.max(Math.min(startX, endX), minChunk.x()); + int minZ = Math.max(Math.min(startZ, endZ), minChunk.z()); + int maxX = Math.min(Math.max(startX, endX), maxChunk.x()); + int maxZ = Math.min(Math.max(startZ, endZ), maxChunk.z()); Stream stream = Stream.iterate( BlockVector2.at(minX, minZ), bv2 -> { - int nextX = bv2.getBlockX(); - int nextZ = bv2.getBlockZ(); + int nextX = bv2.x(); + int nextZ = bv2.z(); if (++nextX > maxX) { nextX = minX; if (++nextZ > maxZ) { @@ -295,8 +295,8 @@ public final class ChunkDeleter { @Override public void write(JsonWriter out, BlockVector2 value) throws IOException { out.beginArray(); - out.value(value.getBlockX()); - out.value(value.getBlockZ()); + out.value(value.x()); + out.value(value.z()); out.endArray(); } @@ -317,8 +317,8 @@ public final class ChunkDeleter { private final int z; RegionFilePos(BlockVector2 chunk) { - this.x = chunk.getBlockX() >> 5; - this.z = chunk.getBlockZ() >> 5; + this.x = chunk.x() >> 5; + this.z = chunk.z() >> 5; } RegionFilePos(int regX, int regZ) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/anvil/ChunkDeletionInfo.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/anvil/ChunkDeletionInfo.java index 13b9d3847..ffcb5f885 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/anvil/ChunkDeletionInfo.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/anvil/ChunkDeletionInfo.java @@ -45,7 +45,7 @@ public class ChunkDeletionInfo { return chunks.size(); } final BlockVector2 dist = maxChunk.subtract(minChunk).add(1, 1); - return dist.getBlockX() * dist.getBlockZ(); + return dist.x() * dist.z(); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/anvil/RegionAccess.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/anvil/RegionAccess.java index 80eb6989e..7c545040e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/anvil/RegionAccess.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/anvil/RegionAccess.java @@ -57,8 +57,8 @@ class RegionAccess implements AutoCloseable { } private static int indexChunk(BlockVector2 pos) { - int x = pos.getBlockX() & 31; - int z = pos.getBlockZ() & 31; + int x = pos.x() & 31; + int z = pos.z() & 31; return x + z * 32; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/SelectionCylinderEvent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/SelectionCylinderEvent.java index b9cf79fe0..4150f9a5c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/SelectionCylinderEvent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/SelectionCylinderEvent.java @@ -42,11 +42,11 @@ public class SelectionCylinderEvent implements CUIEvent { @Override public String[] getParameters() { return new String[]{ - String.valueOf(pos.getBlockX()), - String.valueOf(pos.getBlockY()), - String.valueOf(pos.getBlockZ()), - String.valueOf(radius.getX()), - String.valueOf(radius.getZ()) + String.valueOf(pos.x()), + String.valueOf(pos.y()), + String.valueOf(pos.z()), + String.valueOf(radius.x()), + String.valueOf(radius.z()) }; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/SelectionEllipsoidPointEvent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/SelectionEllipsoidPointEvent.java index 3bf609b1b..4e0131329 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/SelectionEllipsoidPointEvent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/SelectionEllipsoidPointEvent.java @@ -40,9 +40,9 @@ public class SelectionEllipsoidPointEvent implements CUIEvent { public String[] getParameters() { return new String[]{ String.valueOf(id), - String.valueOf(pos.getBlockX()), - String.valueOf(pos.getBlockY()), - String.valueOf(pos.getBlockZ()) + String.valueOf(pos.x()), + String.valueOf(pos.y()), + String.valueOf(pos.z()) }; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/SelectionPoint2DEvent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/SelectionPoint2DEvent.java index f27eda25c..f01c240a2 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/SelectionPoint2DEvent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/SelectionPoint2DEvent.java @@ -32,30 +32,30 @@ public class SelectionPoint2DEvent implements CUIEvent { @Deprecated public SelectionPoint2DEvent(int id, BlockVector2 pos, int area) { this.id = id; - this.blockX = pos.getX(); - this.blockZ = pos.getZ(); + this.blockX = pos.x(); + this.blockZ = pos.z(); this.area = area; } @Deprecated public SelectionPoint2DEvent(int id, BlockVector3 pos, int area) { this.id = id; - this.blockX = pos.getX(); - this.blockZ = pos.getZ(); + this.blockX = pos.x(); + this.blockZ = pos.z(); this.area = area; } public SelectionPoint2DEvent(int id, BlockVector2 pos, long area) { this.id = id; - this.blockX = pos.getX(); - this.blockZ = pos.getZ(); + this.blockX = pos.x(); + this.blockZ = pos.z(); this.area = area; } public SelectionPoint2DEvent(int id, BlockVector3 pos, long area) { this.id = id; - this.blockX = pos.getX(); - this.blockZ = pos.getZ(); + this.blockX = pos.x(); + this.blockZ = pos.z(); this.area = area; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/SelectionPointEvent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/SelectionPointEvent.java index 1ee2e466d..42718c7ae 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/SelectionPointEvent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/SelectionPointEvent.java @@ -49,9 +49,9 @@ public class SelectionPointEvent implements CUIEvent { public String[] getParameters() { return new String[]{ String.valueOf(id), - String.valueOf(pos.getBlockX()), - String.valueOf(pos.getBlockY()), - String.valueOf(pos.getBlockZ()), + String.valueOf(pos.x()), + String.valueOf(pos.y()), + String.valueOf(pos.z()), String.valueOf(area) }; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/ServerCUIHandler.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/ServerCUIHandler.java index b9f3891f3..8cc91f969 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/ServerCUIHandler.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/cui/ServerCUIHandler.java @@ -79,9 +79,9 @@ public class ServerCUIHandler { try { CuboidRegion region = ((CuboidRegionSelector) regionSelector).getRegion(); - posX = region.getMinimumPoint().getBlockX(); - posY = region.getMinimumPoint().getBlockY(); - posZ = region.getMinimumPoint().getBlockZ(); + posX = region.getMinimumPoint().x(); + posY = region.getMinimumPoint().y(); + posZ = region.getMinimumPoint().z(); width = region.getWidth(); height = region.getHeight(); @@ -104,9 +104,9 @@ public class ServerCUIHandler { } // Just select the point. - posX = point.getBlockX(); - posY = point.getBlockY(); - posZ = point.getBlockZ(); + posX = point.x(); + posY = point.y(); + posZ = point.z(); width = 1; height = 1; length = 1; @@ -128,8 +128,8 @@ public class ServerCUIHandler { double rotX = location.getYaw(); double rotY = location.getPitch(); double xz = Math.cos(Math.toRadians(rotY)); - int x = (int) (location.getX() - (-xz * Math.sin(Math.toRadians(rotX))) * 12); - int z = (int) (location.getZ() - (xz * Math.cos(Math.toRadians(rotX))) * 12); + int x = (int) (location.x() - (-xz * Math.sin(Math.toRadians(rotX))) * 12); + int z = (int) (location.z() - (xz * Math.cos(Math.toRadians(rotX))) * 12); int y = Math.max( player.getWorld().getMinY(), Math.min(Math.min(player.getWorld().getMaxY(), posY + MAX_DISTANCE), posY + 3) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/util/RegionOptimizedVectorSorter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/util/RegionOptimizedVectorSorter.java index b30bd8f49..4fdcb2118 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/util/RegionOptimizedVectorSorter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/util/RegionOptimizedVectorSorter.java @@ -62,13 +62,13 @@ public class RegionOptimizedVectorSorter { private static final long FLIP_REGION_Z_SIGN = 0x1_00_00L << REGION_Z_SHIFT; private static long key(BlockVector3 elem) { - long x = elem.getX(); - long z = elem.getZ(); + long x = elem.x(); + long z = elem.z(); return (((x << (REGION_X_SHIFT - 9)) & REGION_X_MASK) ^ FLIP_REGION_X_SIGN) | (((z << (REGION_Z_SHIFT - 9)) & REGION_Z_MASK) ^ FLIP_REGION_Z_SIGN) | ((x << (CHUNK_X_SHIFT - 4)) & CHUNK_X_MASK) | ((z << (CHUNK_Z_SHIFT - 4)) & CHUNK_Z_MASK) - | (Y_MAX - elem.getY()); + | (Y_MAX - elem.y()); } private static final int NUMBER_OF_BITS = 64; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/wna/WorldNativeAccess.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/wna/WorldNativeAccess.java index 769773b96..aa90cb816 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/wna/WorldNativeAccess.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/wna/WorldNativeAccess.java @@ -50,9 +50,9 @@ public interface WorldNativeAccess { checkNotNull(block); setCurrentSideEffectSet(sideEffects); - int x = position.getBlockX(); - int y = position.getBlockY(); - int z = position.getBlockZ(); + int x = position.x(); + int y = position.y(); + int z = position.z(); // First set the block NC chunk = getChunk(x >> 4, z >> 4); @@ -75,9 +75,9 @@ public interface WorldNativeAccess { if (tag != null) { tag = tag.put(ImmutableMap.of( "id", StringBinaryTag.of(baseBlock.getNbtId()), - "x", IntBinaryTag.of(position.getX()), - "y", IntBinaryTag.of(position.getY()), - "z", IntBinaryTag.of(position.getZ()) + "x", IntBinaryTag.of(position.x()), + "y", IntBinaryTag.of(position.y()), + "z", IntBinaryTag.of(position.z()) )); // update if TE changed as well @@ -99,8 +99,8 @@ public interface WorldNativeAccess { default void applySideEffects(BlockVector3 position, BlockState previousType, SideEffectSet sideEffectSet) { setCurrentSideEffectSet(sideEffectSet); - NP pos = getPosition(position.getX(), position.getY(), position.getZ()); - NC chunk = getChunk(position.getX() >> 4, position.getZ() >> 4); + NP pos = getPosition(position.x(), position.y(), position.z()); + NC chunk = getChunk(position.x() >> 4, position.z() >> 4); NBS oldData = toNative(previousType); NBS newData = getBlockState(chunk, pos); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector2.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector2.java index cb5784cce..baed5ffde 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector2.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector2.java @@ -53,7 +53,7 @@ public class BlockVector2 { * */ public static final Comparator COMPARING_GRID_ARRANGEMENT = - Comparator.comparingInt(BlockVector2::getZ).thenComparingInt(BlockVector2::getX); + Comparator.comparingInt(BlockVector2::z).thenComparingInt(BlockVector2::x); public static BlockVector2 at(double x, double z) { return at((int) Math.floor(x), (int) Math.floor(z)); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3.java index e48355d63..3d239b352 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3.java @@ -254,7 +254,7 @@ public abstract class BlockVector3 { */ //FAWE start - getter public BlockVector3 withY(int y) { - return BlockVector3.at(getX(), y, getZ()); + return BlockVector3.at(x(), y, z()); } //FAWE end 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 68e62e937..0eeabee70 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 @@ -89,10 +89,10 @@ public class HeightMap { this.maxSessionY = session.getMaxY(); //FAWE end - int minX = region.getMinimumPoint().getBlockX(); - int minY = region.getMinimumPoint().getBlockY(); - int minZ = region.getMinimumPoint().getBlockZ(); - int maxY = region.getMaximumPoint().getBlockY(); + int minX = region.getMinimumPoint().x(); + int minY = region.getMinimumPoint().y(); + int minZ = region.getMinimumPoint().z(); + int maxY = region.getMaximumPoint().y(); // Store current heightmap data data = new int[width * height]; @@ -100,14 +100,14 @@ public class HeightMap { //FAWE start if (layers) { BlockVector3 min = region.getMinimumPoint(); - int bx = min.getBlockX(); - int bz = min.getBlockZ(); + int bx = min.x(); + int bz = min.z(); Iterator flat = Regions.asFlatRegion(region).asFlatRegion().iterator(); int layer = session.getMinY(); while (flat.hasNext()) { BlockVector2 pos = flat.next(); - int x = pos.getBlockX(); - int z = pos.getBlockZ(); + int x = pos.x(); + int z = pos.z(); layer = session.getNearestSurfaceLayer(x, z, (layer + 7) >> 3, session.getMinY(), maxY); data[(z - bz) * width + (x - bx)] = layer; } @@ -169,10 +169,10 @@ public class HeightMap { checkNotNull(data); BlockVector3 min = region.getMinimumPoint(); - int originX = min.getBlockX(); - int originZ = min.getBlockZ(); + int originX = min.x(); + int originZ = min.z(); - int maxY = region.getMaximumPoint().getBlockY(); + int maxY = region.getMaximumPoint().y(); BlockState fillerAir = BlockTypes.AIR.getDefaultState(); @@ -261,11 +261,11 @@ public class HeightMap { checkNotNull(data); BlockVector3 min = region.getMinimumPoint(); - int originX = min.getBlockX(); - int originY = min.getBlockY(); - int originZ = min.getBlockZ(); + int originX = min.x(); + int originY = min.y(); + int originZ = min.z(); - int maxY = region.getMaximumPoint().getBlockY(); + int maxY = region.getMaximumPoint().y(); BlockState fillerAir = BlockTypes.AIR.getDefaultState(); int blocksChanged = 0; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/SnowHeightMap.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/SnowHeightMap.java index 97f58f9e1..0c12c4652 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/SnowHeightMap.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/SnowHeightMap.java @@ -65,10 +65,10 @@ public class SnowHeightMap { this.width = region.getWidth(); this.height = region.getLength(); - int minX = region.getMinimumPoint().getBlockX(); - int minY = region.getMinimumPoint().getBlockY(); - int minZ = region.getMinimumPoint().getBlockZ(); - int maxY = region.getMaximumPoint().getBlockY(); + int minX = region.getMinimumPoint().x(); + int minY = region.getMinimumPoint().y(); + int minZ = region.getMinimumPoint().z(); + int maxY = region.getMaximumPoint().y(); // Store current heightmap data data = new float[width * height]; @@ -134,11 +134,11 @@ public class SnowHeightMap { checkNotNull(data); BlockVector3 minY = region.getMinimumPoint(); - int originX = minY.getBlockX(); - int originY = minY.getBlockY(); - int originZ = minY.getBlockZ(); + int originX = minY.x(); + int originY = minY.y(); + int originZ = minY.z(); - int maxY = region.getMaximumPoint().getBlockY(); + int maxY = region.getMaximumPoint().y(); BlockState fillerAir = BlockTypes.AIR.getDefaultState(); BlockState fillerSnow = BlockTypes.SNOW_BLOCK.getDefaultState(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/KochanekBartelsInterpolation.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/KochanekBartelsInterpolation.java index 561ba14bf..0ecced12e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/KochanekBartelsInterpolation.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/KochanekBartelsInterpolation.java @@ -164,10 +164,10 @@ public class KochanekBartelsInterpolation implements Interpolation { //FAWE start double r2 = remainder * remainder; double r3 = r2 * remainder; - mutable.mutX((a.getX() * r3 + b.getX() * r2 + c.getX() * remainder + d.getX())); - mutable.mutY((a.getY() * r3 + b.getY() * r2 + c.getY() * remainder + d.getY())); - mutable.mutZ((a.getZ() * r3 + b.getZ() * r2 + c.getZ() * remainder + d.getZ())); - return Vector3.at(mutable.getX(), mutable.getY(), mutable.getZ()); + mutable.mutX((a.x() * r3 + b.x() * r2 + c.x() * remainder + d.x())); + mutable.mutY((a.y() * r3 + b.y() * r2 + c.y() * remainder + d.y())); + mutable.mutZ((a.z() * r3 + b.z() * r2 + c.z() * remainder + d.z())); + return Vector3.at(mutable.x(), mutable.y(), mutable.z()); //FAWE end } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/JLibNoiseGenerator.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/JLibNoiseGenerator.java index a7f3fe449..c541d2d3d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/JLibNoiseGenerator.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/JLibNoiseGenerator.java @@ -47,12 +47,12 @@ abstract class JLibNoiseGenerator implements NoiseGenerator { @Override public float noise(Vector2 position) { - return forceRange(module.GetValue(position.getX(), 0, position.getZ())); + return forceRange(module.GetValue(position.x(), 0, position.z())); } @Override public float noise(Vector3 position) { - return forceRange(module.GetValue(position.getX(), position.getY(), position.getZ())); + return forceRange(module.GetValue(position.x(), position.y(), position.z())); } private float forceRange(double value) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java index 02ee75d44..92e81eea2 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java @@ -265,11 +265,11 @@ public class AffineTransform implements Transform, Serializable { } public AffineTransform translate(Vector3 vec) { - return translate(vec.getX(), vec.getY(), vec.getZ()); + return translate(vec.x(), vec.y(), vec.z()); } public AffineTransform translate(BlockVector3 vec) { - return translate(vec.getX(), vec.getY(), vec.getZ()); + return translate(vec.x(), vec.y(), vec.z()); } public AffineTransform translate(double x, double y, double z) { @@ -315,29 +315,29 @@ public class AffineTransform implements Transform, Serializable { } public AffineTransform scale(Vector3 vec) { - return scale(vec.getX(), vec.getY(), vec.getZ()); + return scale(vec.x(), vec.y(), vec.z()); } //FAWE start public boolean isScaled(Vector3 vector) { - boolean flip = vector.getX() != 0 && m00 < 0; - if (vector.getY() != 0 && m11 < 0) { + boolean flip = vector.x() != 0 && m00 < 0; + if (vector.y() != 0 && m11 < 0) { flip = !flip; } - if (vector.getZ() != 0 && m22 < 0) { + if (vector.z() != 0 && m22 < 0) { flip = !flip; } if (flip) { return true; } // Check for flip-and-rotate - if (vector.getX() != 0 && vector.getY() != 0 && ((m01 < 0 && m10 < 0) || (m01 > 0 && m10 > 0))) { + if (vector.x() != 0 && vector.y() != 0 && ((m01 < 0 && m10 < 0) || (m01 > 0 && m10 > 0))) { flip = true; } - if (vector.getX() != 0 && vector.getZ() != 0 && ((m02 < 0 && m20 < 0) || (m02 > 0 && m20 > 0))) { + if (vector.x() != 0 && vector.z() != 0 && ((m02 < 0 && m20 < 0) || (m02 > 0 && m20 > 0))) { flip = !flip; } - if (vector.getY() != 0 && vector.getZ() != 0 && ((m12 < 0 && m21 < 0) || (m12 > 0 && m21 > 0))) { + if (vector.y() != 0 && vector.z() != 0 && ((m12 < 0 && m21 < 0) || (m12 > 0 && m21 > 0))) { flip = !flip; } return flip; @@ -346,9 +346,9 @@ public class AffineTransform implements Transform, Serializable { @Override public Vector3 apply(Vector3 vector) { - double x = (vector.getX() * m00 + vector.getY() * m01 + vector.getZ() * m02 + m03); - double y = (vector.getX() * m10 + vector.getY() * m11 + vector.getZ() * m12 + m13); - double z = (vector.getX() * m20 + vector.getY() * m21 + vector.getZ() * m22 + m23); + double x = (vector.x() * m00 + vector.y() * m01 + vector.z() * m02 + m03); + double y = (vector.x() * m10 + vector.y() * m11 + vector.z() * m12 + m13); + double z = (vector.x() * m20 + vector.y() * m21 + vector.z() * m22 + m23); vector = vector.mutX(x); vector = vector.mutY(y); vector = vector.mutZ(z); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/AbstractFlatRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/AbstractFlatRegion.java index 8534f0f35..a868e0262 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/AbstractFlatRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/AbstractFlatRegion.java @@ -29,12 +29,12 @@ public abstract class AbstractFlatRegion extends AbstractRegion implements FlatR @Override public int getMinimumY() { - return getMinimumPoint().getBlockY(); + return getMinimumPoint().y(); } @Override public int getMaximumY() { - return getMaximumPoint().getBlockY(); + return getMaximumPoint().y(); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/AbstractRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/AbstractRegion.java index 85979b217..f87f9741b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/AbstractRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/AbstractRegion.java @@ -20,8 +20,6 @@ package com.sk89q.worldedit.regions; import com.fastasyncworldedit.core.math.BlockVectorSet; -import com.sk89q.worldedit.WorldEdit; -import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; @@ -109,10 +107,10 @@ public abstract class AbstractRegion extends AbstractSet implement final List points = new ArrayList<>(4); - points.add(BlockVector2.at(min.getX(), min.getZ())); - points.add(BlockVector2.at(min.getX(), max.getZ())); - points.add(BlockVector2.at(max.getX(), max.getZ())); - points.add(BlockVector2.at(max.getX(), min.getZ())); + points.add(BlockVector2.at(min.x(), min.z())); + points.add(BlockVector2.at(min.x(), max.z())); + points.add(BlockVector2.at(max.x(), max.z())); + points.add(BlockVector2.at(max.x(), min.z())); return points; } @@ -122,9 +120,9 @@ public abstract class AbstractRegion extends AbstractSet implement BlockVector3 min = getMinimumPoint(); BlockVector3 max = getMaximumPoint(); - return (max.getX() - min.getX() + 1L) - * (max.getY() - min.getY() + 1L) - * (max.getZ() - min.getZ() + 1L); + return (max.x() - min.x() + 1L) + * (max.y() - min.y() + 1L) + * (max.z() - min.z() + 1L); } /** @@ -137,7 +135,7 @@ public abstract class AbstractRegion extends AbstractSet implement BlockVector3 min = getMinimumPoint(); BlockVector3 max = getMaximumPoint(); - return max.getX() - min.getX() + 1; + return max.x() - min.x() + 1; } /** @@ -150,7 +148,7 @@ public abstract class AbstractRegion extends AbstractSet implement BlockVector3 min = getMinimumPoint(); BlockVector3 max = getMaximumPoint(); - return max.getY() - min.getY() + 1; + return max.y() - min.y() + 1; } /** @@ -163,7 +161,7 @@ public abstract class AbstractRegion extends AbstractSet implement BlockVector3 min = getMinimumPoint(); BlockVector3 max = getMaximumPoint(); - return max.getZ() - min.getZ() + 1; + return max.z() - min.z() + 1; } /** @@ -179,12 +177,12 @@ public abstract class AbstractRegion extends AbstractSet implement final BlockVector3 maxBlock = getMaximumPoint(); //FAWE start - final BlockVector2 min = BlockVector2.at(minBlock.getX() >> 4, minBlock.getZ() >> 4); - final BlockVector2 max = BlockVector2.at(maxBlock.getX() >> 4, maxBlock.getZ() >> 4); + final BlockVector2 min = BlockVector2.at(minBlock.x() >> 4, minBlock.z() >> 4); + final BlockVector2 max = BlockVector2.at(maxBlock.x() >> 4, maxBlock.z() >> 4); //FAWE end - for (int X = min.getBlockX(); X <= max.getBlockX(); ++X) { - for (int Z = min.getBlockZ(); Z <= max.getBlockZ(); ++Z) { + for (int X = min.x(); X <= max.x(); ++X) { + for (int Z = min.z(); Z <= max.z(); ++Z) { if (containsChunk(X, Z)) { chunks.add(BlockVector2.at(X, Z)); } @@ -201,9 +199,9 @@ public abstract class AbstractRegion extends AbstractSet implement final BlockVector3 min = getMinimumPoint(); final BlockVector3 max = getMaximumPoint(); - for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) { - for (int y = min.getBlockY(); y <= max.getBlockY(); ++y) { - for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) { + for (int x = min.x(); x <= max.x(); ++x) { + for (int y = min.y(); y <= max.y(); ++y) { + for (int z = min.z(); z <= max.z(); ++z) { if (!contains(BlockVector3.at(x, y, z))) { continue; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java index d04e5aa8c..8616cbb2b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java @@ -160,12 +160,12 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { } pos1 = pos1.clampY(getWorldMinY(), getWorldMaxY()); pos2 = pos2.clampY(getWorldMinY(), getWorldMaxY()); - minX = Math.min(pos1.getX(), pos2.getX()); - minY = Math.min(pos1.getY(), pos2.getY()); - minZ = Math.min(pos1.getZ(), pos2.getZ()); - maxX = Math.max(pos1.getX(), pos2.getX()); - maxY = Math.max(pos1.getY(), pos2.getY()); - maxZ = Math.max(pos1.getZ(), pos2.getZ()); + minX = Math.min(pos1.x(), pos2.x()); + minY = Math.min(pos1.y(), pos2.y()); + minZ = Math.min(pos1.z(), pos2.z()); + maxX = Math.max(pos1.x(), pos2.x()); + maxY = Math.max(pos1.y(), pos2.y()); + maxZ = Math.max(pos1.z(), pos2.z()); } //FAWE start - allow region to be created without clamping Y @@ -176,12 +176,12 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { if (pos1 == null || pos2 == null) { return; } - minX = Math.min(pos1.getX(), pos2.getX()); - minY = Math.min(pos1.getY(), pos2.getY()); - minZ = Math.min(pos1.getZ(), pos2.getZ()); - maxX = Math.max(pos1.getX(), pos2.getX()); - maxY = Math.max(pos1.getY(), pos2.getY()); - maxZ = Math.max(pos1.getZ(), pos2.getZ()); + minX = Math.min(pos1.x(), pos2.x()); + minY = Math.min(pos1.y(), pos2.y()); + minZ = Math.min(pos1.z(), pos2.z()); + maxX = Math.max(pos1.x(), pos2.x()); + maxY = Math.max(pos1.y(), pos2.y()); + maxZ = Math.max(pos1.z(), pos2.z()); } //FAWE end @@ -196,16 +196,16 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { return new RegionIntersection( // Project to Z-Y plane - new CuboidRegion(pos1.withX(min.getX()), pos2.withX(min.getX())), - new CuboidRegion(pos1.withX(max.getX()), pos2.withX(max.getX())), + new CuboidRegion(pos1.withX(min.x()), pos2.withX(min.x())), + new CuboidRegion(pos1.withX(max.x()), pos2.withX(max.x())), // Project to X-Y plane - new CuboidRegion(pos1.withZ(min.getZ()), pos2.withZ(min.getZ())), - new CuboidRegion(pos1.withZ(max.getZ()), pos2.withZ(max.getZ())), + new CuboidRegion(pos1.withZ(min.z()), pos2.withZ(min.z())), + new CuboidRegion(pos1.withZ(max.z()), pos2.withZ(max.z())), // Project to the X-Z plane - new CuboidRegion(pos1.withY(min.getY()), pos2.withY(min.getY())), - new CuboidRegion(pos1.withY(max.getY()), pos2.withY(max.getY())) + new CuboidRegion(pos1.withY(min.y()), pos2.withY(min.y())), + new CuboidRegion(pos1.withY(max.y()), pos2.withY(max.y())) ); } @@ -221,7 +221,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { BlockVector3 dimensions = getDimensions(); //FAWE start - if (dimensions.getX() <= 2 || dimensions.getZ() <= 2) { + if (dimensions.x() <= 2 || dimensions.z() <= 2) { // The wall are the region return new RegionIntersection(this); } @@ -229,18 +229,18 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { return new RegionIntersection( // Project to Z-Y plane - new CuboidRegion(pos1.withX(min.getX()), pos2.withX(min.getX())), - new CuboidRegion(pos1.withX(max.getX()), pos2.withX(max.getX())), + new CuboidRegion(pos1.withX(min.x()), pos2.withX(min.x())), + new CuboidRegion(pos1.withX(max.x()), pos2.withX(max.x())), // Project to X-Y plane //FAWE start = prevent overlap new CuboidRegion( - pos1.withZ(min.getZ()).add(BlockVector3.UNIT_X), - pos2.withZ(min.getZ()).subtract(BlockVector3.UNIT_X) + pos1.withZ(min.z()).add(BlockVector3.UNIT_X), + pos2.withZ(min.z()).subtract(BlockVector3.UNIT_X) ), new CuboidRegion( - pos1.withZ(max.getZ()).add(BlockVector3.UNIT_X), - pos2.withZ(max.getZ()).subtract(BlockVector3.UNIT_X) + pos1.withZ(max.z()).add(BlockVector3.UNIT_X), + pos2.withZ(max.z()).subtract(BlockVector3.UNIT_X) ) //FAWE end ); @@ -276,45 +276,45 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { checkNotNull(changes); for (BlockVector3 change : changes) { - if (change.getX() > 0) { - if (Math.max(pos1.getX(), pos2.getX()) == pos1.getX()) { - pos1 = pos1.add(change.getX(), 0, 0); + if (change.x() > 0) { + if (Math.max(pos1.x(), pos2.x()) == pos1.x()) { + pos1 = pos1.add(change.x(), 0, 0); } else { - pos2 = pos2.add(change.getX(), 0, 0); + pos2 = pos2.add(change.x(), 0, 0); } } else { - if (Math.min(pos1.getX(), pos2.getX()) == pos1.getX()) { - pos1 = pos1.add(change.getX(), 0, 0); + if (Math.min(pos1.x(), pos2.x()) == pos1.x()) { + pos1 = pos1.add(change.x(), 0, 0); } else { - pos2 = pos2.add(change.getX(), 0, 0); + pos2 = pos2.add(change.x(), 0, 0); } } - if (change.getY() > 0) { - if (Math.max(pos1.getY(), pos2.getY()) == pos1.getY()) { - pos1 = pos1.add(0, change.getY(), 0); + if (change.y() > 0) { + if (Math.max(pos1.y(), pos2.y()) == pos1.y()) { + pos1 = pos1.add(0, change.y(), 0); } else { - pos2 = pos2.add(0, change.getY(), 0); + pos2 = pos2.add(0, change.y(), 0); } } else { - if (Math.min(pos1.getY(), pos2.getY()) == pos1.getY()) { - pos1 = pos1.add(0, change.getY(), 0); + if (Math.min(pos1.y(), pos2.y()) == pos1.y()) { + pos1 = pos1.add(0, change.y(), 0); } else { - pos2 = pos2.add(0, change.getY(), 0); + pos2 = pos2.add(0, change.y(), 0); } } - if (change.getZ() > 0) { - if (Math.max(pos1.getZ(), pos2.getZ()) == pos1.getZ()) { - pos1 = pos1.add(0, 0, change.getZ()); + if (change.z() > 0) { + if (Math.max(pos1.z(), pos2.z()) == pos1.z()) { + pos1 = pos1.add(0, 0, change.z()); } else { - pos2 = pos2.add(0, 0, change.getZ()); + pos2 = pos2.add(0, 0, change.z()); } } else { - if (Math.min(pos1.getZ(), pos2.getZ()) == pos1.getZ()) { - pos1 = pos1.add(0, 0, change.getZ()); + if (Math.min(pos1.z(), pos2.z()) == pos1.z()) { + pos1 = pos1.add(0, 0, change.z()); } else { - pos2 = pos2.add(0, 0, change.getZ()); + pos2 = pos2.add(0, 0, change.z()); } } } @@ -327,45 +327,45 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { checkNotNull(changes); for (BlockVector3 change : changes) { - if (change.getX() < 0) { - if (Math.max(pos1.getX(), pos2.getX()) == pos1.getX()) { - pos1 = pos1.add(change.getX(), 0, 0); + if (change.x() < 0) { + if (Math.max(pos1.x(), pos2.x()) == pos1.x()) { + pos1 = pos1.add(change.x(), 0, 0); } else { - pos2 = pos2.add(change.getX(), 0, 0); + pos2 = pos2.add(change.x(), 0, 0); } } else { - if (Math.min(pos1.getX(), pos2.getX()) == pos1.getX()) { - pos1 = pos1.add(change.getX(), 0, 0); + if (Math.min(pos1.x(), pos2.x()) == pos1.x()) { + pos1 = pos1.add(change.x(), 0, 0); } else { - pos2 = pos2.add(change.getX(), 0, 0); + pos2 = pos2.add(change.x(), 0, 0); } } - if (change.getY() < 0) { - if (Math.max(pos1.getY(), pos2.getY()) == pos1.getY()) { - pos1 = pos1.add(0, change.getY(), 0); + if (change.y() < 0) { + if (Math.max(pos1.y(), pos2.y()) == pos1.y()) { + pos1 = pos1.add(0, change.y(), 0); } else { - pos2 = pos2.add(0, change.getY(), 0); + pos2 = pos2.add(0, change.y(), 0); } } else { - if (Math.min(pos1.getY(), pos2.getY()) == pos1.getY()) { - pos1 = pos1.add(0, change.getY(), 0); + if (Math.min(pos1.y(), pos2.y()) == pos1.y()) { + pos1 = pos1.add(0, change.y(), 0); } else { - pos2 = pos2.add(0, change.getY(), 0); + pos2 = pos2.add(0, change.y(), 0); } } - if (change.getZ() < 0) { - if (Math.max(pos1.getZ(), pos2.getZ()) == pos1.getZ()) { - pos1 = pos1.add(0, 0, change.getZ()); + if (change.z() < 0) { + if (Math.max(pos1.z(), pos2.z()) == pos1.z()) { + pos1 = pos1.add(0, 0, change.z()); } else { - pos2 = pos2.add(0, 0, change.getZ()); + pos2 = pos2.add(0, 0, change.z()); } } else { - if (Math.min(pos1.getZ(), pos2.getZ()) == pos1.getZ()) { - pos1 = pos1.add(0, 0, change.getZ()); + if (Math.min(pos1.z(), pos2.z()) == pos1.z()) { + pos1 = pos1.add(0, 0, change.z()); } else { - pos2 = pos2.add(0, 0, change.getZ()); + pos2 = pos2.add(0, 0, change.z()); } } } @@ -385,10 +385,10 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { public Set getChunks() { BlockVector3 min = getMinimumPoint(); BlockVector3 max = getMaximumPoint(); - final int maxX = max.getBlockX() >> ChunkStore.CHUNK_SHIFTS; - final int minX = min.getBlockX() >> ChunkStore.CHUNK_SHIFTS; - final int maxZ = max.getBlockZ() >> ChunkStore.CHUNK_SHIFTS; - final int minZ = min.getBlockZ() >> ChunkStore.CHUNK_SHIFTS; + final int maxX = max.x() >> ChunkStore.CHUNK_SHIFTS; + final int minX = min.x() >> ChunkStore.CHUNK_SHIFTS; + final int maxZ = max.z() >> ChunkStore.CHUNK_SHIFTS; + final int minZ = min.z() >> ChunkStore.CHUNK_SHIFTS; final int size = (maxX - minX + 1) * (maxZ - minZ + 1); //FAWE start @@ -471,7 +471,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { public boolean contains(Object o) { if (o instanceof BlockVector2) { BlockVector2 cv = (BlockVector2) o; - return cv.getX() >= minX && cv.getX() <= maxX && cv.getZ() >= minZ && cv.getZ() <= maxZ; + return cv.x() >= minX && cv.x() <= maxX && cv.z() >= minZ && cv.z() <= maxZ; } return false; } @@ -488,9 +488,9 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { BlockVector3 min = getMinimumPoint(); BlockVector3 max = getMaximumPoint(); - for (int x = min.getBlockX() >> ChunkStore.CHUNK_SHIFTS; x <= max.getBlockX() >> ChunkStore.CHUNK_SHIFTS; ++x) { - for (int z = min.getBlockZ() >> ChunkStore.CHUNK_SHIFTS; z <= max.getBlockZ() >> ChunkStore.CHUNK_SHIFTS; ++z) { - for (int y = min.getBlockY() >> ChunkStore.CHUNK_SHIFTS; y <= max.getBlockY() >> ChunkStore.CHUNK_SHIFTS; ++y) { + for (int x = min.x() >> ChunkStore.CHUNK_SHIFTS; x <= max.x() >> ChunkStore.CHUNK_SHIFTS; ++x) { + for (int z = min.z() >> ChunkStore.CHUNK_SHIFTS; z <= max.z() >> ChunkStore.CHUNK_SHIFTS; ++z) { + for (int y = min.y() >> ChunkStore.CHUNK_SHIFTS; y <= max.y() >> ChunkStore.CHUNK_SHIFTS; ++y) { chunks.add(BlockVector3.at(x, y, z)); } } @@ -503,7 +503,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { @Override public boolean contains(BlockVector3 position) { //FAWE start - return contains(position.getX(), position.getY(), position.getZ()); + return contains(position.x(), position.y(), position.z()); //FAWE end } @@ -532,17 +532,17 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { private final BlockVector3 min = getMinimumPoint(); private final BlockVector3 max = getMaximumPoint(); - final int bx = min.getBlockX(); - final int by = min.getBlockY(); - final int bz = min.getBlockZ(); + final int bx = min.x(); + final int by = min.y(); + final int bz = min.z(); - final int tx = max.getBlockX(); - final int ty = max.getBlockY(); - final int tz = max.getBlockZ(); + final int tx = max.x(); + final int ty = max.y(); + final int tz = max.z(); - private int x = min.getBlockX(); - private int y = min.getBlockY(); - private int z = min.getBlockZ(); + private int x = min.x(); + private int y = min.y(); + private int z = min.z(); int cx = x >> 4; int cz = z >> 4; @@ -611,9 +611,9 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { return new Iterator() { private final BlockVector3 min = getMinimumPoint(); private final BlockVector3 max = getMaximumPoint(); - private int nextX = min.getBlockX(); - private int nextY = min.getBlockY(); - private int nextZ = min.getBlockZ(); + private int nextX = min.x(); + private int nextY = min.y(); + private int nextZ = min.z(); private boolean hasNext = true; @Override @@ -626,17 +626,17 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { mutable.mutX(nextX); mutable.mutY(nextY); mutable.mutZ(nextZ); - if (++nextX > max.getBlockX()) { - nextX = min.getBlockX(); - if (++nextZ > max.getBlockZ()) { - nextZ = min.getBlockZ(); - if (++nextY > max.getBlockY()) { + if (++nextX > max.x()) { + nextX = min.x(); + if (++nextZ > max.z()) { + nextZ = min.z(); + if (++nextY > max.y()) { if (!hasNext()) { throw new NoSuchElementException(); } - nextX = max.getBlockX(); - nextZ = max.getBlockZ(); - nextY = max.getBlockY(); + nextX = max.x(); + nextZ = max.z(); + nextY = max.y(); hasNext = false; } } @@ -652,8 +652,8 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { return () -> new Iterator() { private final BlockVector3 min = getMinimumPoint(); private final BlockVector3 max = getMaximumPoint(); - private int nextX = min.getBlockX(); - private int nextZ = min.getBlockZ(); + private int nextX = min.x(); + private int nextZ = min.z(); @Override public boolean hasNext() { @@ -666,9 +666,9 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { throw new NoSuchElementException(); } BlockVector2 answer = BlockVector2.at(nextX, nextZ); - if (++nextX > max.getBlockX()) { - nextX = min.getBlockX(); - if (++nextZ > max.getBlockZ()) { + if (++nextX > max.x()) { + nextX = min.x(); + if (++nextZ > max.z()) { nextZ = Integer.MAX_VALUE; nextX = Integer.MAX_VALUE; } @@ -705,10 +705,10 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { public static boolean contains(CuboidRegion region) { BlockVector3 min = region.getMinimumPoint(); BlockVector3 max = region.getMaximumPoint(); - return region.contains(min.getBlockX(), min.getBlockY(), min.getBlockZ()) && region.contains( - max.getBlockX(), - max.getBlockY(), - max.getBlockZ() + return region.contains(min.x(), min.y(), min.z()) && region.contains( + max.x(), + max.y(), + max.z() ); } //FAWE end diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CylinderRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CylinderRegion.java index 6439d6079..85c62e771 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CylinderRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CylinderRegion.java @@ -197,8 +197,8 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion { @Override public long getVolume() { - return BigDecimal.valueOf(radius.getX()) - .multiply(BigDecimal.valueOf(radius.getZ())) + return BigDecimal.valueOf(radius.x()) + .multiply(BigDecimal.valueOf(radius.z())) .multiply(PI) .multiply(BigDecimal.valueOf(getHeight())) .setScale(0, RoundingMode.FLOOR) @@ -207,7 +207,7 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion { @Override public int getWidth() { - return (int) (2 * radius.getX()); + return (int) (2 * radius.x()); } @Override @@ -217,7 +217,7 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion { @Override public int getLength() { - return (int) (2 * radius.getZ()); + return (int) (2 * radius.z()); } private BlockVector2 calculateDiff2D(BlockVector3... changes) throws RegionOperationException { @@ -226,7 +226,7 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion { diff = diff.add(change.toBlockVector2()); } - if ((diff.getBlockX() & 1) + (diff.getBlockZ() & 1) != 0) { + if ((diff.x() & 1) + (diff.z() & 1) != 0) { throw new RegionOperationException(Caption.of("worldedit.selection.cylinder.error.even-horizontal")); } @@ -254,7 +254,7 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion { radius = radius.add(calculateChanges2D(changes).toVector2()); this.radiusInverse = Vector2.ONE.divide(radius); for (BlockVector3 change : changes) { - int changeY = change.getBlockY(); + int changeY = change.y(); if (changeY > 0) { maxY += changeY; } else { @@ -276,7 +276,7 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion { this.radiusInverse = Vector2.ONE.divide(radius); for (BlockVector3 change : changes) { int height = maxY - minY; - int changeY = change.getBlockY(); + int changeY = change.y(); if (changeY > 0) { minY += Math.min(height, changeY); } else { @@ -289,7 +289,7 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion { public void shift(BlockVector3 change) throws RegionOperationException { center = center.add(change.toBlockVector2()); - int changeY = change.getBlockY(); + int changeY = change.y(); maxY += changeY; minY += changeY; } @@ -322,15 +322,15 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion { @Override public boolean contains(int x, int z) { - double dx = Math.abs(x - center.getBlockX()) * radiusInverse.getX(); - double dz = Math.abs(z - center.getBlockZ()) * radiusInverse.getZ(); + double dx = Math.abs(x - center.x()) * radiusInverse.x(); + double dz = Math.abs(z - center.z()) * radiusInverse.z(); return dx * dx + dz * dz <= 1; } @Override public boolean contains(BlockVector3 position) { - return contains(position.getX(), position.getY(), position.getZ()); + return contains(position.x(), position.y(), position.z()); } //FAWE end @@ -402,8 +402,8 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion { checkNotNull(extent); checkNotNull(center); Vector2 radiusVec = Vector2.at(radius, radius); - int minY = extent.getMinimumPoint().getBlockY(); - int maxY = extent.getMaximumPoint().getBlockY(); + int minY = extent.getMinimumPoint().y(); + int maxY = extent.getMaximumPoint().y(); return new CylinderRegion(center, radiusVec, minY, maxY); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/EllipsoidRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/EllipsoidRegion.java index c3aed2a53..944e7a14c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/EllipsoidRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/EllipsoidRegion.java @@ -102,32 +102,32 @@ public class EllipsoidRegion extends AbstractRegion { @Override public long getVolume() { return ELLIPSOID_BASE_MULTIPLIER - .multiply(BigDecimal.valueOf(radius.getX())) - .multiply(BigDecimal.valueOf(radius.getY())) - .multiply(BigDecimal.valueOf(radius.getZ())) + .multiply(BigDecimal.valueOf(radius.x())) + .multiply(BigDecimal.valueOf(radius.y())) + .multiply(BigDecimal.valueOf(radius.z())) .setScale(0, RoundingMode.FLOOR) .longValue(); } @Override public int getWidth() { - return (int) (2 * radius.getX()); + return (int) (2 * radius.x()); } @Override public int getHeight() { - return (int) (2 * radius.getY()); + return (int) (2 * radius.y()); } @Override public int getLength() { - return (int) (2 * radius.getZ()); + return (int) (2 * radius.z()); } private BlockVector3 calculateDiff(BlockVector3... changes) throws RegionOperationException { BlockVector3 diff = BlockVector3.ZERO.add(changes); - if ((diff.getBlockX() & 1) + (diff.getBlockY() & 1) + (diff.getBlockZ() & 1) != 0) { + if ((diff.x() & 1) + (diff.y() & 1) + (diff.z() & 1) != 0) { throw new RegionOperationException(Caption.of("worldedit.selection.ellipsoid.error.even-horizontal")); } @@ -198,8 +198,8 @@ public class EllipsoidRegion extends AbstractRegion { this.radius = radius.add(0.5, 0.5, 0.5); //FAWE start radiusSqr = radius.multiply(radius); - radiusLengthSqr = (int) radiusSqr.getX(); - this.sphere = radius.getY() == radius.getX() && radius.getX() == radius.getZ(); + radiusLengthSqr = (int) radiusSqr.x(); + this.sphere = radius.y() == radius.x() && radius.x() == radius.z(); inverseRadiusSqr = Vector3.ONE.divide(radiusSqr); //FAWE end } @@ -210,10 +210,10 @@ public class EllipsoidRegion extends AbstractRegion { final BlockVector3 min = getMinimumPoint(); final BlockVector3 max = getMaximumPoint(); - final int centerY = center.getBlockY(); + final int centerY = center.y(); - for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) { - for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) { + for (int x = min.x(); x <= max.x(); ++x) { + for (int z = min.z(); z <= max.z(); ++z) { if (!contains(x, centerY, z)) { continue; } @@ -231,17 +231,17 @@ public class EllipsoidRegion extends AbstractRegion { //FAWE start @Override public boolean contains(int x, int y, int z) { - int cx = x - center.getBlockX(); + int cx = x - center.x(); int cx2 = cx * cx; if (cx2 > radiusSqr.getBlockX()) { return false; } - int cz = z - center.getBlockZ(); + int cz = z - center.z(); int cz2 = cz * cz; if (cz2 > radiusSqr.getBlockZ()) { return false; } - int cy = y - center.getBlockY(); + int cy = y - center.y(); int cy2 = cy * cy; if (radiusSqr.getBlockY() < getWorldMaxY() && cy2 > radiusSqr.getBlockY()) { return false; @@ -249,9 +249,9 @@ public class EllipsoidRegion extends AbstractRegion { if (sphere) { return cx2 + cy2 + cz2 <= radiusLengthSqr; } - double cxd = cx2 * inverseRadiusSqr.getX(); - double cyd = cy2 * inverseRadiusSqr.getY(); - double czd = cz2 * inverseRadiusSqr.getZ(); + double cxd = cx2 * inverseRadiusSqr.x(); + double cyd = cy2 * inverseRadiusSqr.y(); + double czd = cz2 * inverseRadiusSqr.z(); return cxd + cyd + czd <= 1; } @@ -265,23 +265,23 @@ public class EllipsoidRegion extends AbstractRegion { @Override public boolean contains(BlockVector3 position) { - return contains(position.getX(), position.getY(), position.getZ()); + return contains(position.x(), position.y(), position.z()); } @Override public boolean contains(int x, int z) { - int cx = x - center.getBlockX(); + int cx = x - center.x(); int cx2 = cx * cx; if (cx2 > radiusSqr.getBlockX()) { return false; } - int cz = z - center.getBlockZ(); + int cz = z - center.z(); int cz2 = cz * cz; if (cz2 > radiusSqr.getBlockZ()) { return false; } - double cxd = cx2 * inverseRadiusSqr.getX(); - double czd = cz2 * inverseRadiusSqr.getZ(); + double cxd = cx2 * inverseRadiusSqr.x(); + double czd = cz2 * inverseRadiusSqr.z(); return cxd + czd <= 1; } //FAWE end @@ -339,9 +339,9 @@ public class EllipsoidRegion extends AbstractRegion { int layer, int y1, int y2, int bx, int bz, Filter filter, ChunkFilterBlock block, IChunkGet get, IChunkSet set ) { - int cx = center.getBlockX(); - int cy = center.getBlockY(); - int cz = center.getBlockZ(); + int cx = center.x(); + int cy = center.y(); + int cz = center.z(); block.initLayer(get, set, layer); @@ -376,8 +376,8 @@ public class EllipsoidRegion extends AbstractRegion { ) { // Check bounds // This needs to be able to perform 50M blocks/sec otherwise it becomes a bottleneck - int cx = center.getBlockX(); - int cz = center.getBlockZ(); + int cx = center.x(); + int cz = center.z(); int bx = chunk.getX() << 4; int bz = chunk.getZ() << 4; int tx = bx + 15; @@ -415,7 +415,7 @@ public class EllipsoidRegion extends AbstractRegion { block = block.initChunk(chunk.getX(), chunk.getZ()); // Get the solid layers - int cy = center.getBlockY(); + int cy = center.y(); int diffYFull = MathMan.usqrt(diffY2); int yBotFull = Math.max(getWorldMinY(), cy - diffYFull); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Polygonal2DRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Polygonal2DRegion.java index 021e042be..b07503762 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Polygonal2DRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Polygonal2DRegion.java @@ -111,14 +111,14 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion { return; } - int minX = points.get(0).getBlockX(); - int minZ = points.get(0).getBlockZ(); - int maxX = points.get(0).getBlockX(); - int maxZ = points.get(0).getBlockZ(); + int minX = points.get(0).x(); + int minZ = points.get(0).z(); + int maxX = points.get(0).x(); + int maxZ = points.get(0).z(); for (BlockVector2 v : points) { - int x = v.getBlockX(); - int z = v.getBlockZ(); + int x = v.x(); + int z = v.z(); if (x < minX) { minX = x; } @@ -161,7 +161,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion { * @param position the position */ public void addPoint(BlockVector3 position) { - points.add(BlockVector2.at(position.getBlockX(), position.getBlockZ())); + points.add(BlockVector2.at(position.x(), position.z())); recalculate(); } @@ -214,8 +214,8 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion { int j = points.size() - 1; for (i = 0; i < points.size(); ++i) { - long x = points.get(j).getBlockX() + points.get(i).getBlockX(); - long z = points.get(j).getBlockZ() - points.get(i).getBlockZ(); + long x = points.get(j).x() + points.get(i).x(); + long z = points.get(j).z() - points.get(i).z(); area += x * z; j = i; } @@ -229,7 +229,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion { @Override public int getWidth() { - return max.getBlockX() - min.getBlockX() + 1; + return max.x() - min.x() + 1; } @Override @@ -239,16 +239,16 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion { @Override public int getLength() { - return max.getBlockZ() - min.getBlockZ() + 1; + return max.z() - min.z() + 1; } @Override public void expand(BlockVector3... changes) throws RegionOperationException { for (BlockVector3 change : changes) { - if (change.getBlockX() != 0 || change.getBlockZ() != 0) { + if (change.x() != 0 || change.z() != 0) { throw new RegionOperationException(Caption.of("worldedit.selection.polygon2d.error.expand-only-vertical")); } - int changeY = change.getBlockY(); + int changeY = change.y(); if (changeY > 0) { maxY += changeY; } else { @@ -261,10 +261,10 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion { @Override public void contract(BlockVector3... changes) throws RegionOperationException { for (BlockVector3 change : changes) { - if (change.getBlockX() != 0 || change.getBlockZ() != 0) { + if (change.x() != 0 || change.z() != 0) { throw new RegionOperationException(Caption.of("worldedit.selection.polygon2d.error.contract-only-vertical")); } - int changeY = change.getBlockY(); + int changeY = change.y(); if (changeY > 0) { minY += changeY; } else { @@ -276,13 +276,13 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion { @Override public void shift(BlockVector3 change) throws RegionOperationException { - final double changeX = change.getX(); - final double changeY = change.getY(); - final double changeZ = change.getZ(); + final double changeX = change.x(); + final double changeY = change.y(); + final double changeZ = change.z(); for (int i = 0; i < points.size(); ++i) { BlockVector2 point = points.get(i); - points.set(i, BlockVector2.at(point.getX() + changeX, point.getZ() + changeZ)); + points.set(i, BlockVector2.at(point.x() + changeX, point.z() + changeZ)); } minY += changeY; @@ -307,12 +307,12 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion { long crossproduct; int i; - xOld = points.get(npoints - 1).getBlockX(); - zOld = points.get(npoints - 1).getBlockZ(); + xOld = points.get(npoints - 1).x(); + zOld = points.get(npoints - 1).z(); for (i = 0; i < npoints; ++i) { - xNew = points.get(i).getBlockX(); - zNew = points.get(i).getBlockZ(); + xNew = points.get(i).x(); + zNew = points.get(i).z(); //Check for corner if (xNew == targetX && zNew == targetZ) { return true; @@ -365,9 +365,9 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion { if (points.size() < 3) { return false; } - int targetX = pt.getBlockX(); //wide - int targetY = pt.getBlockY(); //height - int targetZ = pt.getBlockZ(); //depth + int targetX = pt.x(); //wide + int targetY = pt.y(); //height + int targetZ = pt.z(); //depth if (targetY < minY || targetY > maxY) { return false; @@ -384,12 +384,12 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion { long crossproduct; int i; - int xOld = points.get(npoints - 1).getBlockX(); - int zOld = points.get(npoints - 1).getBlockZ(); + int xOld = points.get(npoints - 1).x(); + int zOld = points.get(npoints - 1).z(); for (i = 0; i < npoints; ++i) { - xNew = points.get(i).getBlockX(); - zNew = points.get(i).getBlockZ(); + xNew = points.get(i).x(); + zNew = points.get(i).z(); //Check for corner if (xNew == targetX && zNew == targetZ) { return true; @@ -478,7 +478,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion { Iterator it = pts.iterator(); while (it.hasNext()) { BlockVector2 current = it.next(); - sb.append("(").append(current.getBlockX()).append(", ").append(current.getBlockZ()).append(")"); + sb.append("(").append(current.x()).append(", ").append(current.z()).append(")"); if (it.hasNext()) { sb.append(" - "); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java index d2fa35310..e8c6da179 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java @@ -235,15 +235,15 @@ public interface Region extends Iterable, Cloneable, IBatchProcess default boolean isGlobal() { BlockVector3 pos1 = getMinimumPoint(); BlockVector3 pos2 = getMaximumPoint(); - return pos1.getBlockX() == Integer.MIN_VALUE && pos1.getBlockZ() == Integer.MIN_VALUE && pos2.getBlockX() == Integer.MAX_VALUE && pos2 - .getBlockZ() == Integer.MAX_VALUE - && pos1.getBlockY() <= WorldEdit + return pos1.x() == Integer.MIN_VALUE && pos1.z() == Integer.MIN_VALUE && pos2.x() == Integer.MAX_VALUE && pos2 + .z() == Integer.MAX_VALUE + && pos1.y() <= WorldEdit .getInstance() .getPlatformManager() .queryCapability( Capability.WORLD_EDITING) .versionMinY() - && pos2.getBlockY() >= WorldEdit + && pos2.y() >= WorldEdit .getInstance() .getPlatformManager() .queryCapability(Capability.WORLD_EDITING) @@ -251,11 +251,11 @@ public interface Region extends Iterable, Cloneable, IBatchProcess } default int getMinimumY() { - return getMinimumPoint().getY(); + return getMinimumPoint().y(); } default int getMaximumY() { - return getMaximumPoint().getY(); + return getMaximumPoint().y(); } default void filter( @@ -385,7 +385,7 @@ public interface Region extends Iterable, Cloneable, IBatchProcess int tz = bz + 15; BlockVector3 min = getMinimumPoint(); BlockVector3 max = getMaximumPoint(); - return tx >= min.getX() && bx <= max.getX() && tz >= min.getZ() && bz <= max.getZ(); + return tx >= min.x() && bx <= max.x() && tz >= min.z() && bz <= max.z(); } @Override @@ -397,7 +397,7 @@ public interface Region extends Iterable, Cloneable, IBatchProcess BlockVector3 min = getMinimumPoint(); BlockVector3 max = getMaximumPoint(); - if (tx >= min.getX() && bx <= max.getX() && tz >= min.getZ() && bz <= max.getZ()) { + if (tx >= min.x() && bx <= max.x() && tz >= min.z() && bz <= max.z()) { // contains some boolean processExtra = false; for (int layer = getMinimumY() >> 4; layer <= getMaximumY() >> 4; layer++) { @@ -451,7 +451,7 @@ public interface Region extends Iterable, Cloneable, IBatchProcess BlockVector3 min = getMinimumPoint(); BlockVector3 max = getMaximumPoint(); - if (tx >= min.getX() && bx <= max.getX() && tz >= min.getZ() && bz <= max.getZ()) { + if (tx >= min.x() && bx <= max.x() && tz >= min.z() && bz <= max.z()) { // contains some boolean processExtra = false; for (int layer = getMinimumY() >> 4; layer <= getMaximumY() >> 4; layer++) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionIntersection.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionIntersection.java index 7a3e91343..c1a81834c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionIntersection.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionIntersection.java @@ -168,7 +168,7 @@ public class RegionIntersection extends AbstractRegion { for (Region region : regions) { BlockVector3 regMin = region.getMinimumPoint(); BlockVector3 regMax = region.getMaximumPoint(); - if (tx >= regMin.getX() && bx <= regMax.getX() && tz >= regMin.getZ() && bz <= regMax.getZ()) { + if (tx >= regMin.x() && bx <= regMax.x() && tz >= regMin.z() && bz <= regMax.z()) { intersecting.add(region); } } @@ -204,7 +204,7 @@ public class RegionIntersection extends AbstractRegion { for (Region region : regions) { BlockVector3 regMin = region.getMinimumPoint(); BlockVector3 regMax = region.getMaximumPoint(); - if (tx >= regMin.getX() && bx <= regMax.getX() && tz >= regMin.getZ() && bz <= regMax.getZ()) { + if (tx >= regMin.x() && bx <= regMax.x() && tz >= regMin.z() && bz <= regMax.z()) { return region.processSet(chunk, get, set, true); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Regions.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Regions.java index 040ec2803..d562190cb 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Regions.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Regions.java @@ -35,7 +35,7 @@ public final class Regions { * @return the Y coordinate */ public static double minimumY(Region region) { - return region.getMinimumPoint().getY(); + return region.getMinimumPoint().y(); } /** @@ -46,7 +46,7 @@ public final class Regions { * @return the Y coordinate */ public static double maximumY(Region region) { - return region.getMaximumPoint().getY(); + return region.getMaximumPoint().y(); } /** @@ -57,7 +57,7 @@ public final class Regions { * @return the Y coordinate */ public static int minimumBlockY(Region region) { - return region.getMinimumPoint().getBlockY(); + return region.getMinimumPoint().y(); } /** @@ -68,7 +68,7 @@ public final class Regions { * @return the Y coordinate */ public static int maximumBlockY(Region region) { - return region.getMaximumPoint().getBlockY(); + return region.getMaximumPoint().y(); } /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/TransformRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/TransformRegion.java index b2471af32..782fcebae 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/TransformRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/TransformRegion.java @@ -119,17 +119,17 @@ public class TransformRegion extends AbstractRegion { @Override public int getWidth() { - return getMaximumPoint().subtract(getMinimumPoint()).getBlockX() + 1; + return getMaximumPoint().subtract(getMinimumPoint()).x() + 1; } @Override public int getHeight() { - return getMaximumPoint().subtract(getMinimumPoint()).getBlockY() + 1; + return getMaximumPoint().subtract(getMinimumPoint()).y() + 1; } @Override public int getLength() { - return getMaximumPoint().subtract(getMinimumPoint()).getBlockZ() + 1; + return getMaximumPoint().subtract(getMinimumPoint()).z() + 1; } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/factory/CylinderRegionFactory.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/factory/CylinderRegionFactory.java index 386700b1e..67112c68c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/factory/CylinderRegionFactory.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/factory/CylinderRegionFactory.java @@ -37,8 +37,8 @@ public class CylinderRegionFactory implements RegionFactory { return new CylinderRegion( position, Vector2.at(size, size), - position.getBlockY() - (int) (height / 2), - position.getBlockY() + (int) (height / 2) + position.y() - (int) (height / 2), + position.y() + (int) (height / 2) ); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegion3DIterator.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegion3DIterator.java index e7ae99340..12c5f90d9 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegion3DIterator.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegion3DIterator.java @@ -68,7 +68,7 @@ public class FlatRegion3DIterator implements Iterator { throw new NoSuchElementException(); } - BlockVector3 current = BlockVector3.at(next2D.getBlockX(), nextY, next2D.getBlockZ()); + BlockVector3 current = BlockVector3.at(next2D.x(), nextY, next2D.z()); if (nextY < maxY) { nextY++; } else if (flatIterator.hasNext()) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegionIterator.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegionIterator.java index e62c72ecd..3db019499 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegionIterator.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegionIterator.java @@ -46,15 +46,15 @@ public class FlatRegionIterator implements Iterator { BlockVector3 min = region.getMinimumPoint(); BlockVector3 max = region.getMaximumPoint(); - this.y = min.getBlockY(); + this.y = min.y(); - this.minX = min.getBlockX(); + this.minX = min.x(); this.nextX = minX; - this.nextZ = min.getBlockZ(); + this.nextZ = min.z(); - this.maxX = max.getBlockX(); - this.maxZ = max.getBlockZ(); + this.maxX = max.x(); + this.maxZ = max.z(); forward(); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/RegionIterator.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/RegionIterator.java index 9e2c9b8e8..54f67b4de 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/RegionIterator.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/RegionIterator.java @@ -43,14 +43,14 @@ public class RegionIterator implements Iterator { this.region = region; BlockVector3 max = region.getMaximumPoint(); - this.maxX = max.getBlockX(); - this.maxY = max.getBlockY(); - this.maxZ = max.getBlockZ(); + this.maxX = max.x(); + this.maxY = max.y(); + this.maxZ = max.z(); this.min = region.getMinimumPoint(); - this.nextX = min.getBlockX(); - this.nextY = min.getBlockY(); - this.nextZ = min.getBlockZ(); + this.nextX = min.x(); + this.nextY = min.y(); + this.nextZ = min.z(); forward(); } @@ -84,12 +84,12 @@ public class RegionIterator implements Iterator { if (++nextX <= maxX) { return; } - nextX = min.getBlockX(); + nextX = min.x(); if (++nextY <= maxY) { return; } - nextY = min.getBlockY(); + nextY = min.y(); if (++nextZ <= maxZ) { return; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/ConvexPolyhedralRegionSelector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/ConvexPolyhedralRegionSelector.java index 70471ceae..ac3141c02 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/ConvexPolyhedralRegionSelector.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/ConvexPolyhedralRegionSelector.java @@ -101,8 +101,8 @@ public class ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion return; } - final int minY = oldRegion.getMinimumPoint().getBlockY(); - final int maxY = oldRegion.getMaximumPoint().getBlockY(); + final int minY = oldRegion.getMinimumPoint().y(); + final int maxY = oldRegion.getMaximumPoint().y(); region = new ConvexPolyhedralRegion(oldRegion.getWorld()); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CylinderRegionSelector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CylinderRegionSelector.java index 0798b06e6..5a9d3748b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CylinderRegionSelector.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CylinderRegionSelector.java @@ -115,8 +115,8 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion { region.setCenter(center.toBlockVector2()); region.setRadius(pos2.toBlockVector2().subtract(center.toBlockVector2()).toVector2()); - region.setMaximumY(Math.max(pos1.getBlockY(), pos2.getBlockY())); - region.setMinimumY(Math.min(pos1.getBlockY(), pos2.getBlockY())); + region.setMaximumY(Math.max(pos1.y(), pos2.y())); + region.setMinimumY(Math.min(pos1.y(), pos2.y())); selectedCenter = true; selectedRadius = true; @@ -164,7 +164,7 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion { region = new CylinderRegion(region.getWorld()); region.setCenter(position.toBlockVector2()); - region.setY(position.getBlockY()); + region.setY(position.y()); selectedCenter = true; selectedRadius = false; @@ -182,7 +182,7 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion { final Vector2 minRadius = diff.getMaximum(diff.multiply(-1.0)); region.extendRadius(minRadius); - region.setY(position.getBlockY()); + region.setY(position.y()); selectedRadius = true; @@ -201,8 +201,8 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion { if (selectedCenter) { player.print(Caption.of( "worldedit.selection.cylinder.explain.secondary", - TextComponent.of(NUMBER_FORMAT.format(region.getRadius().getX())), - TextComponent.of(NUMBER_FORMAT.format(region.getRadius().getZ())), + TextComponent.of(NUMBER_FORMAT.format(region.getRadius().x())), + TextComponent.of(NUMBER_FORMAT.format(region.getRadius().z())), TextComponent.of(region.getVolume()) )); } else { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/ExtendingCuboidRegionSelector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/ExtendingCuboidRegionSelector.java index 5d74d7ae6..e75f8bbb5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/ExtendingCuboidRegionSelector.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/ExtendingCuboidRegionSelector.java @@ -107,13 +107,13 @@ public class ExtendingCuboidRegionSelector extends CuboidRegionSelector { return false; } - double x1 = Math.min(position.getX(), position1.getX()); - double y1 = Math.min(position.getY(), position1.getY()); - double z1 = Math.min(position.getZ(), position1.getZ()); + double x1 = Math.min(position.x(), position1.x()); + double y1 = Math.min(position.y(), position1.y()); + double z1 = Math.min(position.z(), position1.z()); - double x2 = Math.max(position.getX(), position2.getX()); - double y2 = Math.max(position.getY(), position2.getY()); - double z2 = Math.max(position.getZ(), position2.getZ()); + double x2 = Math.max(position.x(), position2.x()); + double y2 = Math.max(position.y(), position2.y()); + double z2 = Math.max(position.z(), position2.z()); final BlockVector3 o1 = position1; final BlockVector3 o2 = position2; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/Polygonal2DRegionSelector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/Polygonal2DRegionSelector.java index bf472615a..be9134f15 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/Polygonal2DRegionSelector.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/Polygonal2DRegionSelector.java @@ -96,8 +96,8 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion { return; } - final int minY = oldRegion.getMinimumPoint().getBlockY(); - final int maxY = oldRegion.getMaximumPoint().getBlockY(); + final int minY = oldRegion.getMinimumPoint().y(); + final int maxY = oldRegion.getMaximumPoint().y(); List points = oldRegion.polygonize(Integer.MAX_VALUE); @@ -118,7 +118,7 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion { checkNotNull(points); final BlockVector2 pos2D = points.get(0); - pos1 = BlockVector3.at(pos2D.getX(), minY, pos2D.getZ()); + pos1 = BlockVector3.at(pos2D.x(), minY, pos2D.z()); region = new Polygonal2DRegion(world, points, minY, maxY); } @@ -142,7 +142,7 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion { pos1 = position; region = new Polygonal2DRegion(region.getWorld()); region.addPoint(position); - region.expandY(position.getBlockY()); + region.expandY(position.y()); return true; } @@ -153,7 +153,7 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion { final List points = region.getPoints(); final BlockVector2 lastPoint = points.get(region.size() - 1); - if (lastPoint.getBlockX() == position.getBlockX() && lastPoint.getBlockZ() == position.getBlockZ()) { + if (lastPoint.x() == position.x() && lastPoint.z() == position.z()) { return false; } @@ -165,7 +165,7 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion { } region.addPoint(position); - region.expandY(position.getBlockY()); + region.expandY(position.y()); return true; } @@ -228,7 +228,7 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion { @Override public void learnChanges() { BlockVector2 pt = region.getPoints().get(0); - pos1 = BlockVector3.at(pt.getBlockX(), region.getMinimumPoint().getBlockY(), pt.getBlockZ()); + pos1 = BlockVector3.at(pt.x(), region.getMinimumPoint().y(), pt.z()); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/SphereRegionSelector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/SphereRegionSelector.java index a0eff3046..7394015ab 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/SphereRegionSelector.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/SphereRegionSelector.java @@ -61,7 +61,7 @@ public class SphereRegionSelector extends EllipsoidRegionSelector { super(oldSelector); if (selectedRadius) { final Vector3 radius = region.getRadius(); - final double radiusScalar = Math.max(Math.max(radius.getX(), radius.getY()), radius.getZ()); + final double radiusScalar = Math.max(Math.max(radius.x(), radius.y()), radius.z()); region.setRadius(Vector3.at(radiusScalar, radiusScalar, radiusScalar)); } } @@ -96,11 +96,11 @@ public class SphereRegionSelector extends EllipsoidRegionSelector { if (isDefined()) { player.print(Caption.of( "worldedit.selection.sphere.explain.secondary-defined", - TextComponent.of(region.getRadius().getX()), + TextComponent.of(region.getRadius().x()), TextComponent.of(region.getVolume()) )); } else { - player.print(Caption.of("worldedit.selection.sphere.explain.secondary", TextComponent.of(region.getRadius().getX()))); + player.print(Caption.of("worldedit.selection.sphere.explain.secondary", TextComponent.of(region.getRadius().x()))); } session.describeCUI(player); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryBiomeShape.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryBiomeShape.java index 9f2ef87b0..2fb9e6588 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryBiomeShape.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryBiomeShape.java @@ -59,13 +59,13 @@ public abstract class ArbitraryBiomeShape { BlockVector3 min = extent.getMinimumPoint(); BlockVector3 max = extent.getMaximumPoint(); - cacheOffsetX = min.getBlockX() - 1; - cacheOffsetY = min.getBlockY() - 1; - cacheOffsetZ = min.getBlockZ() - 1; + cacheOffsetX = min.x() - 1; + cacheOffsetY = min.y() - 1; + cacheOffsetZ = min.z() - 1; - cacheSizeX = max.getX() - cacheOffsetX + 2; - cacheSizeY = max.getY() - cacheOffsetY + 2; - cacheSizeZ = max.getZ() - cacheOffsetZ + 2; + cacheSizeX = max.x() - cacheOffsetX + 2; + cacheSizeY = max.y() - cacheOffsetY + 2; + cacheSizeZ = max.z() - cacheOffsetZ + 2; cache = new BiomeType[cacheSizeX * cacheSizeY * cacheSizeZ]; isCached = new BitSet(cache.length); @@ -128,9 +128,9 @@ public abstract class ArbitraryBiomeShape { int affected = 0; for (BlockVector3 position : getExtent()) { - int x = position.getBlockX(); - int y = position.getBlockY(); - int z = position.getBlockZ(); + int x = position.x(); + int y = position.y(); + int z = position.z(); if (!hollow) { final BiomeType material = getBiome(x, y, z, baseBiome); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryShape.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryShape.java index 4feff6b8f..dbb516b1b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryShape.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryShape.java @@ -59,13 +59,13 @@ public abstract class ArbitraryShape { BlockVector3 min = extent.getMinimumPoint(); BlockVector3 max = extent.getMaximumPoint(); - cacheOffsetX = min.getBlockX() - 1; - cacheOffsetY = min.getBlockY() - 1; - cacheOffsetZ = min.getBlockZ() - 1; + cacheOffsetX = min.x() - 1; + cacheOffsetY = min.y() - 1; + cacheOffsetZ = min.z() - 1; - cacheSizeX = max.getX() - cacheOffsetX + 2; - cacheSizeY = max.getY() - cacheOffsetY + 2; - cacheSizeZ = max.getZ() - cacheOffsetZ + 2; + cacheSizeX = max.x() - cacheOffsetX + 2; + cacheSizeY = max.y() - cacheOffsetY + 2; + cacheSizeZ = max.z() - cacheOffsetZ + 2; cache = new byte[cacheSizeX * cacheSizeY * cacheSizeZ]; } @@ -98,9 +98,9 @@ public abstract class ArbitraryShape { int affected = 0; for (BlockVector3 position : getExtent()) { - int x = position.getBlockX(); - int y = position.getBlockY(); - int z = position.getBlockZ(); + int x = position.x(); + int y = position.y(); + int z = position.z(); if (!hollow) { BaseBlock material = getMaterial(x, y, z, pattern.applyBlock(position)); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/Direction.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/Direction.java index d117ff328..c10312503 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/Direction.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/Direction.java @@ -84,7 +84,7 @@ public enum Direction { } Direction(Vector3 vector, int flags, int left, int right) { - this.blockPoint = BlockVector3.at(Math.signum(vector.getX()), Math.signum(vector.getY()), Math.signum(vector.getZ())); + this.blockPoint = BlockVector3.at(Math.signum(vector.x()), Math.signum(vector.y()), Math.signum(vector.z())); this.direction = vector.normalize(); this.flags = flags; this.left = left; @@ -104,27 +104,27 @@ public enum Direction { } public double getX() { - return direction.getX(); + return direction.x(); } public double getY() { - return direction.getY(); + return direction.y(); } public double getZ() { - return direction.getZ(); + return direction.z(); } public int getBlockX() { - return blockPoint.getX(); + return blockPoint.x(); } public int getBlockY() { - return blockPoint.getY(); + return blockPoint.y(); } public int getBlockZ() { - return blockPoint.getZ(); + return blockPoint.z(); } //FAWE end diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/TargetBlock.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/TargetBlock.java index 01444f269..557709931 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/TargetBlock.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/TargetBlock.java @@ -223,15 +223,15 @@ public class TargetBlock { curDistance += checkDistance; targetPosDouble = offset.add( - targetPosDouble.getX(), - targetPosDouble.getY(), - targetPosDouble.getZ() + targetPosDouble.x(), + targetPosDouble.y(), + targetPosDouble.z() ); targetPos = targetPosDouble.toBlockPoint(); } while (curDistance <= maxDistance - && targetPos.getBlockX() == prevPos.getBlockX() - && targetPos.getBlockY() == prevPos.getBlockY() - && targetPos.getBlockZ() == prevPos.getBlockZ()); + && targetPos.x() == prevPos.x() + && targetPos.y() == prevPos.y() + && targetPos.z() == prevPos.z()); if (curDistance > maxDistance) { return null; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/TreeGenerator.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/TreeGenerator.java index cf5c05278..f529b6c5e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/TreeGenerator.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/TreeGenerator.java @@ -135,9 +135,9 @@ public final class TreeGenerator { public boolean generate(EditSession editSession, BlockVector3 pos) throws MaxChangedBlocksException { //FAWE start - perform sanity check on generation location if (editSession - .getBlockType(pos.getX(), pos.getY(), pos.getZ()) + .getBlockType(pos.x(), pos.y(), pos.z()) .getMaterial() - .isAir() && canGenerateOn(editSession.getBlockType(pos.getX(), pos.getY() - 1, pos.getZ()))) { + .isAir() && canGenerateOn(editSession.getBlockType(pos.x(), pos.y() - 1, pos.z()))) { makePineTree(editSession, pos); return true; } @@ -151,7 +151,7 @@ public final class TreeGenerator { //FAWE start - ensure canGenerateOn is called. // chorus plants have to generate starting in the end stone itself, not the air above the ground BlockVector3 down = pos.subtract(0, 1, 0); - if (!canGenerateOn(editSession.getBlockType(down.getX(), down.getY(), down.getZ()))) { + if (!canGenerateOn(editSession.getBlockType(down.x(), down.y(), down.z()))) { return false; } return editSession.getWorld().generateTree(this, editSession, down); @@ -212,9 +212,9 @@ public final class TreeGenerator { public boolean generate(EditSession editSession, BlockVector3 pos) throws MaxChangedBlocksException { //FAWE start - check for ability for tree to generate on block if (editSession - .getBlockType(pos.getX(), pos.getY(), pos.getZ()) + .getBlockType(pos.x(), pos.y(), pos.z()) .getMaterial() - .isAir() && canGenerateOn(editSession.getBlockType(pos.getX(), pos.getY() - 1, pos.getZ()))) { + .isAir() && canGenerateOn(editSession.getBlockType(pos.x(), pos.y() - 1, pos.z()))) { return editSession.getWorld().generateTree(this, editSession, pos); } return false; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/collection/BlockMap.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/collection/BlockMap.java index 43c175dbc..a17f6a04f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/collection/BlockMap.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/collection/BlockMap.java @@ -85,15 +85,15 @@ public class BlockMap extends AbstractMap { private static final int BITS_6 = mask(6); private static long toGroupKey(BlockVector3 location) { - return ((location.getX() >>> 6) & BITS_20) - | (((location.getZ() >>> 6) & BITS_20) << 20) - | (((location.getY() >>> 8) & BITS_24) << (20 + 20)); + return ((location.x() >>> 6) & BITS_20) + | (((location.z() >>> 6) & BITS_20) << 20) + | (((location.y() >>> 8) & BITS_24) << (20 + 20)); } private static int toInnerKey(BlockVector3 location) { - return (location.getX() & BITS_6) - | ((location.getZ() & BITS_6) << 6) - | ((location.getY() & BITS_8) << (6 + 6)); + return (location.x() & BITS_6) + | ((location.z() & BITS_6) << 6) + | ((location.y() & BITS_8) << (6 + 6)); } private static final long GROUP_X = BITS_20; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/collection/VectorPositionList.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/collection/VectorPositionList.java index 3a2759e67..3e725712d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/collection/VectorPositionList.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/collection/VectorPositionList.java @@ -46,9 +46,9 @@ class VectorPositionList implements PositionList { @Override public void add(BlockVector3 vector) { - delegateX.add(vector.getX()); - delegateY.add(vector.getY()); - delegateZ.add(vector.getZ()); + delegateX.add(vector.x()); + delegateY.add(vector.y()); + delegateZ.add(vector.z()); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java index 908e0bac6..ccf8d8535 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java @@ -184,7 +184,7 @@ public class NullWorld extends AbstractWorld { @Override public BlockState getBlock(BlockVector3 position) { - return this.getBlock(position.getBlockX(), position.getBlockY(), position.getBlockZ()); + return this.getBlock(position.x(), position.y(), position.z()); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk.java index 5e4292cd4..5535f4305 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk.java @@ -130,9 +130,9 @@ public class AnvilChunk implements Chunk { } private int getBlockID(BlockVector3 position) throws DataException { - int x = position.getX() - rootX * 16; - int y = position.getY(); - int z = position.getZ() - rootZ * 16; + int x = position.x() - rootX * 16; + int y = position.y(); + int z = position.z() - rootZ * 16; int section = y >> 4; if (section < 0 || section >= blocks.length) { @@ -163,9 +163,9 @@ public class AnvilChunk implements Chunk { } private int getBlockData(BlockVector3 position) throws DataException { - int x = position.getX() - rootX * 16; - int y = position.getY(); - int z = position.getZ() - rootZ * 16; + int x = position.x() - rootX * 16; + int y = position.y(); + int z = position.z() - rootZ * 16; int section = y >> 4; int yIndex = y & 0x0F; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk13.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk13.java index 9b0d764f1..31bb7606c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk13.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk13.java @@ -231,9 +231,9 @@ public class AnvilChunk13 implements Chunk { @Override public BaseBlock getBlock(BlockVector3 position) throws DataException { //FAWE start - simplified - int x = position.getX() & 15; - int y = position.getY(); - int z = position.getZ() & 15; + int x = position.x() & 15; + int y = position.y(); + int z = position.z() & 15; //FAWE end int section = y >> 4; @@ -261,8 +261,8 @@ public class AnvilChunk13 implements Chunk { if (biomes == null) { populateBiomes(); } - int rx = position.getX() & 15; - int rz = position.getZ() & 15; + int rx = position.x() & 15; + int rz = position.z() & 15; return biomes[rz << 4 | rx]; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk15.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk15.java index 7565f66c1..60b9d9617 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk15.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk15.java @@ -60,9 +60,9 @@ public class AnvilChunk15 extends AnvilChunk13 { if (biomes == null) { populateBiomes(); } - int x = (position.getX() & 15) >> 2; - int y = position.getY() >> 2; - int z = (position.getZ() & 15) >> 2; + int x = (position.x() & 15) >> 2; + int y = position.y() >> 2; + int z = (position.z() & 15) >> 2; return biomes[y << 4 | z << 2 | x]; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk17.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk17.java index a6fa95b53..6d366c295 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk17.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk17.java @@ -234,9 +234,9 @@ public class AnvilChunk17 implements Chunk { @Override public BaseBlock getBlock(BlockVector3 position) throws DataException { - int x = position.getX() & 15; - int y = position.getY(); - int z = position.getZ() & 15; + int x = position.x() & 15; + int y = position.y(); + int z = position.z() & 15; int section = y >> 4; int yIndex = y & 0x0F; @@ -262,9 +262,9 @@ public class AnvilChunk17 implements Chunk { if (biomes == null) { populateBiomes(); } - int x = (position.getX() & 15) >> 2; - int y = (position.getY() - (minSectionPosition << 4)) >> 2; // normalize - int z = (position.getZ() & 15) >> 2; + int x = (position.x() & 15) >> 2; + int y = (position.y() - (minSectionPosition << 4)) >> 2; // normalize + int z = (position.z() & 15) >> 2; return biomes[y << 4 | z << 2 | x]; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk18.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk18.java index bb18e8ed5..4fa50629e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk18.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk18.java @@ -232,9 +232,9 @@ public class AnvilChunk18 implements Chunk { @Override public BaseBlock getBlock(BlockVector3 position) throws DataException { - int x = position.getX() & 15; - int y = position.getY(); - int z = position.getZ() & 15; + int x = position.x() & 15; + int y = position.y(); + int z = position.z() & 15; int section = y >> 4; int yIndex = y & 0x0F; @@ -259,10 +259,10 @@ public class AnvilChunk18 implements Chunk { if (biomes == null) { populateBiomes(); } - int x = (position.getX() & 15) >> 2; - int y = (position.getY() & 15) >> 2; - int z = (position.getZ() & 15) >> 2; - int section = position.getY() >> 4; + int x = (position.x() & 15) >> 2; + int y = (position.y() & 15) >> 2; + int z = (position.z() & 15) >> 2; + int section = position.y() >> 4; BiomeType[] sectionBiomes = biomes.get(section); if (sectionBiomes.length == 1) { return sectionBiomes[0]; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/OldChunk.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/OldChunk.java index aabf38ac9..7edb163e3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/OldChunk.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/OldChunk.java @@ -162,15 +162,15 @@ public class OldChunk implements Chunk { @Override public BaseBlock getBlock(BlockVector3 position) throws DataException { - if (position.getY() >= 128) { + if (position.y() >= 128) { return BlockTypes.VOID_AIR.getDefaultState().toBaseBlock(); } int id; int dataVal; - int x = position.getX() - rootX * 16; - int y = position.getY(); - int z = position.getZ() - rootZ * 16; + int x = position.x() - rootX * 16; + int y = position.y(); + int z = position.z() - rootZ * 16; int index = y + (z * 128 + (x * 128 * 16)); try { id = blocks[index]; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotRestore.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotRestore.java index 0d86679cf..3e3201fb6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotRestore.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotRestore.java @@ -114,9 +114,9 @@ public class SnapshotRestore { // First, we need to group points by chunk so that we only need // to keep one chunk in memory at any given moment - for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) { - for (int y = min.getBlockY(); y <= max.getBlockY(); ++y) { - for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) { + for (int x = min.x(); x <= max.x(); ++x) { + for (int y = min.y(); y <= max.y(); ++y) { + for (int z = min.z(); z <= max.z(); ++z) { BlockVector3 pos = BlockVector3.at(x, y, z); checkAndAddBlock(pos); } @@ -185,7 +185,7 @@ public class SnapshotRestore { try { editSession.setBlock(pos, chunk.getBlock(pos)); //FAWE start - biome and entity restore - if (restoreBiomes && (pos.getX() & 3) == 0 && (pos.getY() & 3) == 0 && (pos.getZ() & 3) == 0) { + if (restoreBiomes && (pos.x() & 3) == 0 && (pos.y() & 3) == 0 && (pos.z() & 3) == 0) { editSession.setBiome(pos, chunk.getBiome(pos)); } //FAWE end diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/experimental/SnapshotRestore.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/experimental/SnapshotRestore.java index 9493fc76f..5f9880fc0 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/experimental/SnapshotRestore.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/experimental/SnapshotRestore.java @@ -109,9 +109,9 @@ public class SnapshotRestore { // First, we need to group points by chunk so that we only need // to keep one chunk in memory at any given moment - for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) { - for (int y = min.getBlockY(); y <= max.getBlockY(); ++y) { - for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) { + for (int x = min.x(); x <= max.x(); ++x) { + for (int y = min.y(); y <= max.y(); ++y) { + for (int z = min.z(); z <= max.z(); ++z) { BlockVector3 pos = BlockVector3.at(x, y, z); checkAndAddBlock(pos); } @@ -181,7 +181,7 @@ public class SnapshotRestore { try { editSession.setBlock(pos, chunk.getBlock(pos)); //FAWE start - biome and entity restore - if (restoreBiomes && (pos.getX() & 3) == 0 && (pos.getY() & 3) == 0 && (pos.getZ() & 3) == 0) { + if (restoreBiomes && (pos.x() & 3) == 0 && (pos.y() & 3) == 0 && (pos.z() & 3) == 0) { editSession.setBiome(pos, chunk.getBiome(pos)); } //FAWE end diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/ChunkStore.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/ChunkStore.java index 6b8de78fc..6b42ba727 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/ChunkStore.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/ChunkStore.java @@ -73,7 +73,7 @@ public abstract class ChunkStore implements Closeable { * @return chunk coordinates */ public static BlockVector2 toChunk(BlockVector3 position) { - return BlockVector2.at(position.getX() >> CHUNK_SHIFTS, position.getZ() >> CHUNK_SHIFTS); + return BlockVector2.at(position.x() >> CHUNK_SHIFTS, position.z() >> CHUNK_SHIFTS); } /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/LegacyChunkStore.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/LegacyChunkStore.java index 5e534765a..0159c3880 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/LegacyChunkStore.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/LegacyChunkStore.java @@ -44,8 +44,8 @@ public abstract class LegacyChunkStore extends ChunkStore { * @return pathname */ public static String getFilename(BlockVector2 position, String separator) { - int x = position.getBlockX(); - int z = position.getBlockZ(); + int x = position.x(); + int z = position.z(); String folder1 = Integer.toString(divisorMod(x, 64), 36); String folder2 = Integer.toString(divisorMod(z, 64), 36); @@ -68,8 +68,8 @@ public abstract class LegacyChunkStore extends ChunkStore { @Override public CompoundTag getChunkTag(BlockVector2 position, World world) throws DataException, IOException { - int x = position.getBlockX(); - int z = position.getBlockZ(); + int x = position.x(); + int z = position.z(); String folder1 = Integer.toString(divisorMod(x, 64), 36); String folder2 = Integer.toString(divisorMod(z, 64), 36); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/McRegionChunkStore.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/McRegionChunkStore.java index 5b43de521..a4e06145e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/McRegionChunkStore.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/McRegionChunkStore.java @@ -40,8 +40,8 @@ public abstract class McRegionChunkStore extends ChunkStore { * @return the filename */ public static String getFilename(BlockVector2 position) { - int x = position.getBlockX(); - int z = position.getBlockZ(); + int x = position.x(); + int z = position.z(); return "r." + (x >> 5) + "." + (z >> 5) + ".mca"; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/McRegionReader.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/McRegionReader.java index 193f03b06..88e455200 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/McRegionReader.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/McRegionReader.java @@ -119,8 +119,8 @@ public class McRegionReader { * @throws DataException if there is an error getting the chunk data */ public synchronized InputStream getChunkInputStream(BlockVector2 position) throws IOException, DataException { - int x = position.getBlockX() & 31; - int z = position.getBlockZ() & 31; + int x = position.x() & 31; + int z = position.z() & 31; int offset = getOffset(x, z); diff --git a/worldedit-core/src/test/java/com/sk89q/worldedit/internal/expression/RealExpressionTest.java b/worldedit-core/src/test/java/com/sk89q/worldedit/internal/expression/RealExpressionTest.java index 444e1db9d..a4dd3062a 100644 --- a/worldedit-core/src/test/java/com/sk89q/worldedit/internal/expression/RealExpressionTest.java +++ b/worldedit-core/src/test/java/com/sk89q/worldedit/internal/expression/RealExpressionTest.java @@ -74,7 +74,7 @@ class RealExpressionTest extends BaseExpressionTest { Expression compiled = compile(expr, "x", "y", "z"); for (TestCase aCase : cases) { Vector3 loc = aCase.loc; - assertEquals(aCase.result, compiled.evaluate(loc.getX(), loc.getY(), loc.getZ()), 0, + assertEquals(aCase.result, compiled.evaluate(loc.x(), loc.y(), loc.z()), 0, "Test case " + aCase + " failed (result)" ); aCase.postChecks.accept(compiled); diff --git a/worldedit-core/src/test/java/com/sk89q/worldedit/internal/util/RegionOptimizedVectorSorterTest.java b/worldedit-core/src/test/java/com/sk89q/worldedit/internal/util/RegionOptimizedVectorSorterTest.java index a1582bf04..11057ca25 100644 --- a/worldedit-core/src/test/java/com/sk89q/worldedit/internal/util/RegionOptimizedVectorSorterTest.java +++ b/worldedit-core/src/test/java/com/sk89q/worldedit/internal/util/RegionOptimizedVectorSorterTest.java @@ -100,10 +100,10 @@ public class RegionOptimizedVectorSorterTest { for (int i = 0; i < toSort.size() - 1; i++) { BlockVector3 curr = toSort.get(i); BlockVector3 next = toSort.get(i + 1); - int currChunkX = curr.getX() >> 4; - int nextChunkX = next.getX() >> 4; - int currChunkZ = curr.getZ() >> 4; - int nextChunkZ = next.getZ() >> 4; + int currChunkX = curr.x() >> 4; + int nextChunkX = next.x() >> 4; + int currChunkZ = curr.z() >> 4; + int nextChunkZ = next.z() >> 4; int currRegionX = currChunkX >> 5; int nextRegionX = nextChunkX >> 5; int currRegionZ = currChunkZ >> 5; @@ -125,7 +125,7 @@ public class RegionOptimizedVectorSorterTest { fail(spaceship + " " + currChunkZ + " chunk z should be less than or equal to " + nextChunkZ); } else if (currChunkZ == nextChunkZ) { - if (curr.getY() < next.getY()) { + if (curr.y() < next.y()) { fail(spaceship + " " + curr + " y should be greater than or equal to " + next); } diff --git a/worldedit-core/src/test/java/com/sk89q/worldedit/util/LocationTest.java b/worldedit-core/src/test/java/com/sk89q/worldedit/util/LocationTest.java index 44962055b..2a16b4373 100644 --- a/worldedit-core/src/test/java/com/sk89q/worldedit/util/LocationTest.java +++ b/worldedit-core/src/test/java/com/sk89q/worldedit/util/LocationTest.java @@ -65,7 +65,7 @@ public class LocationTest { public void testGetX() throws Exception { World world = mock(World.class); Location location = new Location(world, Vector3.at(TEST_VALUE, 0, 0)); - assertEquals(TEST_VALUE, location.getX(), EPSILON); + assertEquals(TEST_VALUE, location.x(), EPSILON); } @Test @@ -80,17 +80,17 @@ public class LocationTest { World world = mock(World.class); Location location1 = new Location(world, Vector3.ZERO); Location location2 = location1.setX(TEST_VALUE); - assertEquals(0, location1.getX(), EPSILON); - assertEquals(TEST_VALUE, location2.getX(), EPSILON); - assertEquals(0, location2.getY(), EPSILON); - assertEquals(0, location2.getZ(), EPSILON); + assertEquals(0, location1.x(), EPSILON); + assertEquals(TEST_VALUE, location2.x(), EPSILON); + assertEquals(0, location2.y(), EPSILON); + assertEquals(0, location2.z(), EPSILON); } @Test public void testGetY() throws Exception { World world = mock(World.class); Location location = new Location(world, Vector3.at(0, TEST_VALUE, 0)); - assertEquals(TEST_VALUE, location.getY(), EPSILON); + assertEquals(TEST_VALUE, location.y(), EPSILON); } @Test @@ -105,17 +105,17 @@ public class LocationTest { World world = mock(World.class); Location location1 = new Location(world, Vector3.ZERO); Location location2 = location1.setY(TEST_VALUE); - assertEquals(0, location1.getY(), EPSILON); - assertEquals(0, location2.getX(), EPSILON); - assertEquals(TEST_VALUE, location2.getY(), EPSILON); - assertEquals(0, location2.getZ(), EPSILON); + assertEquals(0, location1.y(), EPSILON); + assertEquals(0, location2.x(), EPSILON); + assertEquals(TEST_VALUE, location2.y(), EPSILON); + assertEquals(0, location2.z(), EPSILON); } @Test public void testGetZ() throws Exception { World world = mock(World.class); Location location = new Location(world, Vector3.at(0, 0, TEST_VALUE)); - assertEquals(TEST_VALUE, location.getZ(), EPSILON); + assertEquals(TEST_VALUE, location.z(), EPSILON); } @Test @@ -130,10 +130,10 @@ public class LocationTest { World world = mock(World.class); Location location1 = new Location(world, Vector3.ZERO); Location location2 = location1.setZ(TEST_VALUE); - assertEquals(0, location1.getZ(), EPSILON); - assertEquals(0, location2.getX(), EPSILON); - assertEquals(0, location2.getY(), EPSILON); - assertEquals(TEST_VALUE, location2.getZ(), EPSILON); + assertEquals(0, location1.z(), EPSILON); + assertEquals(0, location2.x(), EPSILON); + assertEquals(0, location2.y(), EPSILON); + assertEquals(TEST_VALUE, location2.z(), EPSILON); } @RepeatedTest(value = 5) @@ -141,7 +141,7 @@ public class LocationTest { World world = mock(World.class); long start = System.currentTimeMillis(); BlockVector3 location1 = BlockVector3.ZERO; - BlockVector3.at(location1.getX() + 10, location1.getY() + 10, location1.getZ() + 10); + BlockVector3.at(location1.x() + 10, location1.y() + 10, location1.z() + 10); System.out.println(System.currentTimeMillis() - start + " ms"); } From 5da6c65df610ef276ee1d189d4c40b874d0112b1 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Mon, 27 May 2024 19:33:52 +0100 Subject: [PATCH 79/90] fix: use correct coordinates in BufferedPattern2D and NoiseFilter --- .../core/function/pattern/BufferedPattern2D.java | 2 +- .../java/com/sk89q/worldedit/function/mask/NoiseFilter.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/BufferedPattern2D.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/BufferedPattern2D.java index 483629af4..7748c8633 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/BufferedPattern2D.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/BufferedPattern2D.java @@ -33,7 +33,7 @@ public class BufferedPattern2D extends BufferedPattern { @Override public boolean set(BlockVector3 pos) { - return set.add(pos.x(), 0, pos.y()); + return set.add(pos.x(), 0, pos.z()); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/NoiseFilter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/NoiseFilter.java index d0a016639..8dd9c26d9 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/NoiseFilter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/NoiseFilter.java @@ -97,7 +97,7 @@ public class NoiseFilter extends AbstractMask { @Override public boolean test(BlockVector3 vector) { //FAWE start - mutable - return noiseGenerator.noise(mutable.setComponents(vector.x(), vector.z(), vector.z())) <= density; + return noiseGenerator.noise(mutable.setComponents(vector.x(), vector.y(), vector.z())) <= density; //FAWE end } From 7635eec2e47f8caf1454f3744c3949990c9cf41e Mon Sep 17 00:00:00 2001 From: Jordan Date: Sun, 2 Jun 2024 17:11:53 +0200 Subject: [PATCH 80/90] fix: improve how we determine if using FAWE from jenkins (#2754) - SNAPSHOT will usually only be removed if it's a release version - If others remove SNAPSHOT, then they're probably doing their own stuff, just use this as the "release" check - fixes #2744 --- .../com/fastasyncworldedit/core/util/UpdateNotification.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/UpdateNotification.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/UpdateNotification.java index 73ad01361..fdfe7c56c 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/UpdateNotification.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/UpdateNotification.java @@ -59,12 +59,12 @@ public class UpdateNotification { Document doc = db.parse(body); faweVersion = doc.getElementsByTagName("lastSuccessfulBuild").item(0).getFirstChild().getTextContent(); FaweVersion faweVersion = Fawe.instance().getVersion(); - if (faweVersion.build == 0 && !faweVersion.snapshot) { + if (faweVersion.build == 0 && faweVersion.snapshot) { LOGGER.warn("You are using a snapshot or a custom version of FAWE. This is not an official build distributed " + "via https://www.spigotmc.org/resources/13932/"); return; } - if (faweVersion.build < Integer.parseInt(UpdateNotification.faweVersion)) { + if (faweVersion.snapshot && faweVersion.build < Integer.parseInt(UpdateNotification.faweVersion)) { hasUpdate = true; int versionDifference = Integer.parseInt(UpdateNotification.faweVersion) - faweVersion.build; LOGGER.warn( From 261ebfa754c1a2e4ffd4e44aa6952e0a5e73b0b1 Mon Sep 17 00:00:00 2001 From: Pierre Maurice Schwang Date: Sun, 2 Jun 2024 18:21:56 +0200 Subject: [PATCH 81/90] feat: schematic share system, add missing Clipboard method for api compat (#2745) * Allow plugins to register new clipboard share destinations (#1707) * Allow plugins to register new clipboard share destinations * Rename file, as per request * Don't use the base enginehub name for EH_pastebin * Address review comments * Fixed wrong usage * Use a second metadata class for clipboard shares * Newline * Address comments * Improve docs * Apply suggestions from code review Co-authored-by: Octavia Togami * Use a consumer so that we handle serialization * Update worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/Clipboard.java Co-authored-by: Octavia Togami * Update worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/share/ClipboardShareDestination.java Co-authored-by: Octavia Togami * Update worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/share/ShareOutputConsumer.java Co-authored-by: Octavia Togami * Update worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/share/ShareOutputConsumer.java Co-authored-by: Octavia Togami * Fixed a lot of random comments * Return a consumer from share rather than a URL, allows the share destination to control output Co-authored-by: Octavia Togami (cherry picked from commit 6e2b0a1df8a6077c3cf8193e38dc9817038bcbe9) * chore: cleanup cherry-pick remainders * chore/feat: add ark as (default) schematic paster / sharing endpoint * chore: default to fast schematic writer in share * chore: re-format strings.json (seems to adjusted indentation when merging) * chore: hopefully fixing strings.json (again) --------- Co-authored-by: Maddy Miller --- .../core/configuration/Settings.java | 7 + .../arkitektonika/ArkitektonikaResponse.java | 4 + .../ArkitektonikaSchematicUploader.java | 58 +++++ .../worldedit/command/ClipboardCommands.java | 7 +- .../worldedit/command/SchematicCommands.java | 224 ++++++++---------- .../argument/ClipboardFormatConverter.java | 76 ++++++ .../ClipboardShareDestinationConverter.java | 72 ++++++ .../platform/PlatformCommandManager.java | 6 +- .../worldedit/extent/clipboard/Clipboard.java | 24 +- .../extent/clipboard/io/ClipboardFormats.java | 6 +- .../BuiltInClipboardShareDestinations.java | 149 ++++++++++++ .../io/share/ClipboardShareDestination.java | 72 ++++++ .../io/share/ClipboardShareDestinations.java | 80 +++++++ .../io/share/ClipboardShareMetadata.java | 49 ++++ .../io/share/ShareOutputProvider.java | 37 +++ .../util/ClipboardTransformBaker.java} | 37 +-- .../src/main/resources/lang/strings.json | 5 + 17 files changed, 764 insertions(+), 149 deletions(-) create mode 100644 worldedit-core/src/main/java/com/fastasyncworldedit/core/util/arkitektonika/ArkitektonikaResponse.java create mode 100644 worldedit-core/src/main/java/com/fastasyncworldedit/core/util/arkitektonika/ArkitektonikaSchematicUploader.java create mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/ClipboardFormatConverter.java create mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/ClipboardShareDestinationConverter.java create mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/share/BuiltInClipboardShareDestinations.java create mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/share/ClipboardShareDestination.java create mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/share/ClipboardShareDestinations.java create mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/share/ClipboardShareMetadata.java create mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/share/ShareOutputProvider.java rename worldedit-core/src/main/java/com/sk89q/worldedit/{command/FlattenedClipboardTransform.java => internal/util/ClipboardTransformBaker.java} (79%) diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Settings.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Settings.java index 33c8c94f0..cf0ba6f35 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Settings.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Settings.java @@ -668,6 +668,13 @@ public class Settings extends Config { @Comment({"The web interface for clipboards", " - All schematics are anonymous and private", " - Downloads can be deleted by the user", " - Supports clipboard uploads, downloads and saves",}) public String URL = "https://schem.intellectualsites.com/fawe/"; + @Comment({"The url of the backend server (Arkitektonika)"}) + public String ARKITEKTONIKA_BACKEND_URL = "https://api.schematic.cloud/"; + @Comment({"The url used to generate a download link from.", "{key} will be replaced with the generated key"}) + public String ARKITEKTONIKA_DOWNLOAD_URL = "https://schematic.cloud/download/{key}"; + @Comment({"The url used to generate a deletion link from.", "{key} will be replaced with the generated key"}) + public String ARKITEKTONIKA_DELETE_URL = "https://schematic.cloud/delete/{key}"; + @Comment("The maximum amount of time in seconds the plugin can attempt to load images for.") public int MAX_IMAGE_LOAD_TIME = 5; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/arkitektonika/ArkitektonikaResponse.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/arkitektonika/ArkitektonikaResponse.java new file mode 100644 index 000000000..821751c2a --- /dev/null +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/arkitektonika/ArkitektonikaResponse.java @@ -0,0 +1,4 @@ +package com.fastasyncworldedit.core.util.arkitektonika; + +public record ArkitektonikaResponse(String downloadKey, String deletionKey) { +} diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/arkitektonika/ArkitektonikaSchematicUploader.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/arkitektonika/ArkitektonikaSchematicUploader.java new file mode 100644 index 000000000..152bca058 --- /dev/null +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/arkitektonika/ArkitektonikaSchematicUploader.java @@ -0,0 +1,58 @@ +package com.fastasyncworldedit.core.util.arkitektonika; + +import com.fastasyncworldedit.core.internal.exception.FaweException; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.sk89q.worldedit.extent.clipboard.io.share.ClipboardShareMetadata; +import com.sk89q.worldedit.extent.clipboard.io.share.ShareOutputProvider; +import com.sk89q.worldedit.util.formatting.text.TextComponent; +import com.sk89q.worldedit.util.formatting.text.format.TextColor; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.util.UUID; + +public class ArkitektonikaSchematicUploader { + + private static final String BOUNDARY_IDENTIFIER = "--"; + private static final HttpClient HTTP_CLIENT = HttpClient.newHttpClient(); + private final String apiUrl; + + public ArkitektonikaSchematicUploader(String apiUrl) { + this.apiUrl = apiUrl.endsWith("/") ? apiUrl.substring(0, apiUrl.length() - 1) : apiUrl; + } + + public ArkitektonikaResponse uploadBlocking(ClipboardShareMetadata meta, ShareOutputProvider provider) throws IOException, + InterruptedException { + String boundary = UUID.randomUUID().toString(); + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + provider.writeTo(outputStream); + + final HttpRequest.BodyPublisher bodyPublisher = HttpRequest.BodyPublishers.concat( + HttpRequest.BodyPublishers.ofString(BOUNDARY_IDENTIFIER + boundary + "\r\n"), + HttpRequest.BodyPublishers.ofString("Content-Disposition: form-data; name=\"schematic\"; filename=\"" + meta.name() + "." + meta.format().getPrimaryFileExtension() + "\"\r\n\r\n"), + HttpRequest.BodyPublishers.ofByteArray(outputStream.toByteArray()), + HttpRequest.BodyPublishers.ofString("\r\n" + BOUNDARY_IDENTIFIER + boundary + BOUNDARY_IDENTIFIER) + ); + + final HttpResponse response = HTTP_CLIENT.send(HttpRequest.newBuilder() + .uri(URI.create(this.apiUrl + "/upload")) + .header("Content-Type", "multipart/form-data; boundary=\"" + boundary + "\"") + .POST(bodyPublisher).build(), HttpResponse.BodyHandlers.ofString()); + if (response.statusCode() != 200) { + throw new FaweException(TextComponent + .of("Arkitektonika returned status code " + response.statusCode()) + .color(TextColor.RED)); + } + JsonObject json = JsonParser.parseString(response.body()).getAsJsonObject(); + return new ArkitektonikaResponse( + json.get("download_key").getAsString(), + json.get("delete_key").getAsString() + ); + } + +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java index b4037ba15..8c0b69ec9 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java @@ -340,7 +340,7 @@ public class ClipboardCommands { aliases = {"/download"}, desc = "Downloads your clipboard through the configured web interface" ) - @Deprecated + @Deprecated(forRemoval = true, since = "TODO") @CommandPermissions({"worldedit.clipboard.download"}) public void download( final Actor actor, @@ -402,10 +402,7 @@ public class ClipboardCommands { final Clipboard target; // If we have a transform, bake it into the copy if (!transform.isIdentity()) { - final FlattenedClipboardTransform result = FlattenedClipboardTransform.transform(clipboard, transform); - target = new BlockArrayClipboard(result.getTransformedRegion(), actor.getUniqueId()); - target.setOrigin(clipboard.getOrigin()); - Operations.completeLegacy(result.copyTo(target)); + target = clipboard.transform(transform); } else { target = clipboard; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java index e711e61ee..920a24901 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java @@ -26,7 +26,6 @@ import com.fastasyncworldedit.core.extent.clipboard.MultiClipboardHolder; import com.fastasyncworldedit.core.extent.clipboard.URIClipboardHolder; import com.fastasyncworldedit.core.extent.clipboard.io.schematic.MinecraftStructure; import com.fastasyncworldedit.core.util.MainUtil; -import com.google.common.collect.ImmutableList; import com.google.common.collect.Multimap; import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; @@ -38,13 +37,13 @@ import com.sk89q.worldedit.command.util.CommandPermissions; import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Capability; -import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats; import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader; import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter; -import com.sk89q.worldedit.function.operation.Operations; +import com.sk89q.worldedit.extent.clipboard.io.share.ClipboardShareDestination; +import com.sk89q.worldedit.extent.clipboard.io.share.ClipboardShareMetadata; import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.transform.AffineTransform; import com.sk89q.worldedit.math.transform.Transform; @@ -61,19 +60,15 @@ import com.sk89q.worldedit.util.formatting.text.format.TextColor; import com.sk89q.worldedit.util.io.Closer; import com.sk89q.worldedit.util.io.file.FilenameException; import org.apache.logging.log4j.Logger; -import com.sk89q.worldedit.util.paste.EngineHubPaste; -import com.sk89q.worldedit.util.paste.PasteMetadata; import org.enginehub.piston.annotation.Command; import org.enginehub.piston.annotation.CommandContainer; import org.enginehub.piston.annotation.param.Arg; import org.enginehub.piston.annotation.param.ArgFlag; import org.enginehub.piston.annotation.param.Switch; -import org.enginehub.piston.exception.CommandException; import org.enginehub.piston.exception.StopExecutionException; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; -import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -85,11 +80,9 @@ import java.net.URL; import java.nio.channels.Channels; import java.nio.channels.ReadableByteChannel; import java.io.OutputStream; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; -import java.util.Base64; import java.util.Arrays; import java.util.Collection; import java.util.Collections; @@ -98,6 +91,7 @@ import java.util.Map; import java.util.Objects; import java.util.UUID; import java.util.concurrent.Callable; +import java.util.function.Consumer; import java.util.concurrent.ThreadLocalRandom; import java.util.function.Function; import java.util.regex.Pattern; @@ -321,7 +315,7 @@ public class SchematicCommands { Actor actor, LocalSession session, @Arg(desc = "File name.") String filename, - //FAWE start - random rotation + //FAWE start - use format-name, random rotation @Arg(desc = "Format name.", def = "") String formatName, @Switch(name = 'r', desc = "Apply random rotation to the clipboard") @@ -445,8 +439,8 @@ public class SchematicCommands { Actor actor, LocalSession session, @Arg(desc = "File name.") String filename, - @Arg(desc = "Format name.", def = "fast") - String formatName, + @Arg(desc = "Format name.", def = "fast") //FAWE: def: sponge -> fast + ClipboardFormat format, @Switch(name = 'f', desc = "Overwrite an existing file.") boolean allowOverwrite, //FAWE start @@ -474,12 +468,6 @@ public class SchematicCommands { dir = new File(dir, actor.getUniqueId().toString()); } - ClipboardFormat format = ClipboardFormats.findByAlias(formatName); - if (format == null) { - actor.print(Caption.of("worldedit.schematic.unknown-format", TextComponent.of(formatName))); - return; - } - boolean other = false; if (filename.contains("../")) { other = true; @@ -551,35 +539,98 @@ public class SchematicCommands { @CommandPermissions({ "worldedit.clipboard.share", "worldedit.schematic.share" }) public void share(Actor actor, LocalSession session, @Arg(desc = "Schematic name. Defaults to name-millis", def = "") - String schematicName, - @Arg(desc = "Format name.", def = "sponge") - String formatName) throws WorldEditException { - if (true) { - throw new UnsupportedOperationException("This feature is currently not implemented"); - } + String schematicName, + @Arg(desc = "Share location", def = "arkitektonika") //FAWE: def: ehpaste -> arkitektonika + ClipboardShareDestination destination, + @Arg(desc = "Format name", def = "fast") //FAWE: def: sponge -> fast + ClipboardFormat format) throws WorldEditException { if (worldEdit.getPlatformManager().queryCapability(Capability.GAME_HOOKS).getDataVersion() == -1) { actor.printError(TranslatableComponent.of("worldedit.schematic.unsupported-minecraft-version")); return; } - ClipboardFormat format = ClipboardFormats.findByAlias(formatName); if (format == null) { - actor.printError(TranslatableComponent.of("worldedit.schematic.unknown-format", TextComponent.of(formatName))); + format = destination.getDefaultFormat(); + } + + if (!destination.supportsFormat(format)) { + actor.printError(Caption.of( //FAWE: TranslatableComponent -> Caption + "worldedit.schematic.share.unsupported-format", + TextComponent.of(destination.getName()), + TextComponent.of(format.getName()) + )); return; } ClipboardHolder holder = session.getClipboard(); - SchematicShareTask task = new SchematicShareTask(actor, format, holder, schematicName); + SchematicShareTask task = new SchematicShareTask(actor, holder, destination, format, schematicName); AsyncCommandBuilder.wrap(task, actor) .registerWithSupervisor(worldEdit.getSupervisor(), "Sharing schematic") .setDelayMessage(TranslatableComponent.of("worldedit.schematic.save.saving")) .setWorkingMessage(TranslatableComponent.of("worldedit.schematic.save.still-saving")) - .onSuccess("Shared", (url -> actor.printInfo(TextComponent.of(url.toExternalForm() + ".schem").clickEvent(ClickEvent.openUrl(url.toExternalForm() + ".schem"))))) + .onSuccess("Shared", (consumer -> consumer.accept(actor))) .onFailure("Failed to share schematic", worldEdit.getPlatformManager().getPlatformCommandManager().getExceptionConverter()) .buildAndExec(worldEdit.getExecutorService()); } + @Command( + name = "delete", + aliases = {"d"}, + desc = "Delete a saved schematic" + ) + @CommandPermissions("worldedit.schematic.delete") + public void delete( + Actor actor, LocalSession session, + @Arg(desc = "File name.") + String filename + ) throws WorldEditException, IOException { + LocalConfiguration config = worldEdit.getConfiguration(); + //FAWE start + File working = worldEdit.getWorkingDirectoryPath(config.saveDir).toFile(); + File dir = Settings.settings().PATHS.PER_PLAYER_SCHEMATICS ? new File(working, actor.getUniqueId().toString()) : working; + List files = new ArrayList<>(); + + if (filename.equalsIgnoreCase("*")) { + files.addAll(getFiles(session.getClipboard())); + } else { + File f = MainUtil.resolveRelative(new File(dir, filename)); + files.add(f); + } + + if (files.isEmpty()) { + actor.print(Caption.of("worldedit.schematic.delete.does-not-exist", TextComponent.of(filename))); + return; + } + for (File f : files) { + if (!MainUtil.isInSubDirectory(working, f) || !f.exists()) { + actor.print(Caption.of("worldedit.schematic.delete.does-not-exist", TextComponent.of(filename))); + continue; + } + if (Settings.settings().PATHS.PER_PLAYER_SCHEMATICS && !MainUtil.isInSubDirectory(dir, f) && !actor.hasPermission( + "worldedit.schematic.delete.other")) { + actor.print(Caption.of("fawe.error.no-perm", "worldedit.schematic.delete.other")); + continue; + } + if (!deleteFile(f)) { + actor.print(Caption.of("worldedit.schematic.delete.failed", TextComponent.of(filename))); + continue; + } + actor.print(Caption.of("worldedit.schematic.delete.deleted", filename)); + } + //FAWE end + } + + //FAWE start + private boolean deleteFile(File file) { + if (file.delete()) { + new File(file.getParentFile(), "." + file.getName() + ".cached").delete(); + return true; + } + return false; + } + //FAWE end + @Command( name = "formats", aliases = {"listformats", "f"}, @@ -764,68 +815,11 @@ public class SchematicCommands { } - @Command( - name = "delete", - aliases = {"d"}, - desc = "Delete a saved schematic" - ) - @CommandPermissions("worldedit.schematic.delete") - public void delete( - Actor actor, LocalSession session, - @Arg(desc = "File name.") - String filename - ) throws WorldEditException, IOException { - LocalConfiguration config = worldEdit.getConfiguration(); - File working = worldEdit.getWorkingDirectoryPath(config.saveDir).toFile(); - //FAWE start - File dir = Settings.settings().PATHS.PER_PLAYER_SCHEMATICS ? new File(working, actor.getUniqueId().toString()) : working; - List files = new ArrayList<>(); - - if (filename.equalsIgnoreCase("*")) { - files.addAll(getFiles(session.getClipboard())); - } else { - File f = MainUtil.resolveRelative(new File(dir, filename)); - files.add(f); - } - - if (files.isEmpty()) { - actor.print(Caption.of("worldedit.schematic.delete.does-not-exist", TextComponent.of(filename))); - return; - } - for (File f : files) { - if (!MainUtil.isInSubDirectory(working, f) || !f.exists()) { - actor.print(Caption.of("worldedit.schematic.delete.does-not-exist", TextComponent.of(filename))); - continue; - } - if (Settings.settings().PATHS.PER_PLAYER_SCHEMATICS && !MainUtil.isInSubDirectory(dir, f) && !actor.hasPermission( - "worldedit.schematic.delete.other")) { - actor.print(Caption.of("fawe.error.no-perm", "worldedit.schematic.delete.other")); - continue; - } - if (!deleteFile(f)) { - actor.print(Caption.of("worldedit.schematic.delete.failed", TextComponent.of(filename))); - continue; - } - actor.print(Caption.of("worldedit.schematic.delete.deleted", filename)); - } - //FAWE end - } - - //FAWE start - private boolean deleteFile(File file) { - if (file.delete()) { - new File(file.getParentFile(), "." + file.getName() + ".cached").delete(); - return true; - } - return false; - } - //FAWE end - private static class SchematicLoadTask implements Callable { private final Actor actor; - private final ClipboardFormat format; private final File file; + private final ClipboardFormat format; SchematicLoadTask(Actor actor, File file, ClipboardFormat format) { this.actor = actor; @@ -863,19 +857,10 @@ public class SchematicCommands { this.holder = holder; } - protected void writeToOutputStream(OutputStream outputStream) throws Exception { + protected void writeToOutputStream(OutputStream outputStream) throws IOException, WorldEditException { Clipboard clipboard = holder.getClipboard(); Transform transform = holder.getTransform(); - Clipboard target; - // If we have a transform, bake it into the copy - if (transform.isIdentity()) { - target = clipboard; - } else { - FlattenedClipboardTransform result = FlattenedClipboardTransform.transform(clipboard, transform); - target = new BlockArrayClipboard(result.getTransformedRegion()); - target.setOrigin(clipboard.getOrigin()); - Operations.completeLegacy(result.copyTo(target)); - } + Clipboard target = clipboard.transform(transform); try (Closer closer = Closer.create()) { OutputStream stream = closer.register(outputStream); @@ -887,9 +872,10 @@ public class SchematicCommands { } private static class SchematicSaveTask extends SchematicOutputTask { - private File file; + private final Actor actor; + private File file; //FAWE: un-finalize private final boolean overwrite; - private final File rootDir; + private final File rootDir; //FAWE: add root-dir SchematicSaveTask( Actor actor, @@ -900,9 +886,10 @@ public class SchematicCommands { boolean overwrite ) { super(actor, format, holder); + this.actor = actor; this.file = file; - this.rootDir = rootDir; this.overwrite = overwrite; + this.rootDir = rootDir; //FAWE: add root-dir } @Override @@ -975,10 +962,7 @@ public class SchematicCommands { if (transform.isIdentity()) { target = clipboard; } else { - FlattenedClipboardTransform result = FlattenedClipboardTransform.transform(clipboard, transform); - target = new BlockArrayClipboard(result.getTransformedRegion()); - target.setOrigin(clipboard.getOrigin()); - Operations.completeLegacy(result.copyTo(target)); + target = clipboard.transform(transform); } try (Closer closer = Closer.create()) { @@ -1062,29 +1046,31 @@ public class SchematicCommands { } } - private static class SchematicShareTask extends SchematicOutputTask { + private static class SchematicShareTask extends SchematicOutputTask> { + private final Actor actor; private final String name; + private final ClipboardShareDestination destination; - SchematicShareTask(Actor actor, ClipboardFormat format, ClipboardHolder holder, String name) { + SchematicShareTask(Actor actor, + ClipboardHolder holder, + ClipboardShareDestination destination, + ClipboardFormat format, + String name) { super(actor, format, holder); + this.actor = actor; this.name = name; + this.destination = destination; } @Override - public URL call() throws Exception { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - try { - writeToOutputStream(baos); - } catch (Exception e) { - throw new CommandException(TextComponent.of(e.getMessage()), e, ImmutableList.of()); - } + public Consumer call() throws Exception { + ClipboardShareMetadata metadata = new ClipboardShareMetadata( + format, + this.actor.getName(), + name == null ? actor.getName() + "-" + System.currentTimeMillis() : name + ); - EngineHubPaste pasteService = new EngineHubPaste(); - PasteMetadata metadata = new PasteMetadata(); - metadata.author = this.actor.getName(); - metadata.extension = "schem"; - metadata.name = name == null ? actor.getName() + "-" + System.currentTimeMillis() : name; - return pasteService.paste(new String(Base64.getEncoder().encode(baos.toByteArray()), StandardCharsets.UTF_8), metadata).call(); + return destination.share(metadata, this::writeToOutputStream); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/ClipboardFormatConverter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/ClipboardFormatConverter.java new file mode 100644 index 000000000..cfa0a1ed4 --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/ClipboardFormatConverter.java @@ -0,0 +1,76 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.command.argument; + +import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; +import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats; +import com.sk89q.worldedit.extent.clipboard.io.share.ClipboardShareDestination; +import com.sk89q.worldedit.util.formatting.text.Component; +import com.sk89q.worldedit.util.formatting.text.TextComponent; +import org.enginehub.piston.CommandManager; +import org.enginehub.piston.converter.ArgumentConverter; +import org.enginehub.piston.converter.ConversionResult; +import org.enginehub.piston.converter.FailedConversion; +import org.enginehub.piston.converter.SuccessfulConversion; +import org.enginehub.piston.inject.InjectedValueAccess; +import org.enginehub.piston.inject.Key; + +import java.util.List; +import java.util.Set; + +import static org.enginehub.piston.converter.SuggestionHelper.limitByPrefix; + +public class ClipboardFormatConverter implements ArgumentConverter { + + public static void register(CommandManager commandManager) { + commandManager.registerConverter(Key.of(ClipboardFormat.class), + new ClipboardFormatConverter() + ); + } + + private final TextComponent choices; + + private ClipboardFormatConverter() { + this.choices = TextComponent.of("any clipboard format"); + } + + @Override + public Component describeAcceptableArguments() { + return this.choices; + } + + @Override + public List getSuggestions(String input, InjectedValueAccess context) { + ClipboardShareDestination destination = context.injectedValue(Key.of(ClipboardShareDestination.class)).orElse(null); + + return limitByPrefix(ClipboardFormats.getAll().stream() + .filter(format -> destination == null || destination.supportsFormat(format)) + .map(ClipboardFormat::getAliases) + .flatMap(Set::stream), input); + } + + @Override + public ConversionResult convert(String s, InjectedValueAccess injectedValueAccess) { + ClipboardFormat result = ClipboardFormats.findByAlias(s); + return result == null + ? FailedConversion.from(new IllegalArgumentException("Not a valid schematic format: " + s)) + : SuccessfulConversion.fromSingle(result); + } +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/ClipboardShareDestinationConverter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/ClipboardShareDestinationConverter.java new file mode 100644 index 000000000..5af81bb1d --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/argument/ClipboardShareDestinationConverter.java @@ -0,0 +1,72 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.command.argument; + +import com.sk89q.worldedit.extent.clipboard.io.share.ClipboardShareDestination; +import com.sk89q.worldedit.extent.clipboard.io.share.ClipboardShareDestinations; +import com.sk89q.worldedit.util.formatting.text.Component; +import com.sk89q.worldedit.util.formatting.text.TextComponent; +import org.enginehub.piston.CommandManager; +import org.enginehub.piston.converter.ArgumentConverter; +import org.enginehub.piston.converter.ConversionResult; +import org.enginehub.piston.converter.FailedConversion; +import org.enginehub.piston.converter.SuccessfulConversion; +import org.enginehub.piston.inject.InjectedValueAccess; +import org.enginehub.piston.inject.Key; + +import java.util.List; +import java.util.Set; + +import static org.enginehub.piston.converter.SuggestionHelper.limitByPrefix; + +public class ClipboardShareDestinationConverter implements ArgumentConverter { + + public static void register(CommandManager commandManager) { + commandManager.registerConverter(Key.of(ClipboardShareDestination.class), + new ClipboardShareDestinationConverter() + ); + } + + private final TextComponent choices; + + private ClipboardShareDestinationConverter() { + this.choices = TextComponent.of("any clipboard share destination"); + } + + @Override + public Component describeAcceptableArguments() { + return this.choices; + } + + @Override + public List getSuggestions(String input, InjectedValueAccess context) { + return limitByPrefix(ClipboardShareDestinations.getAll().stream() + .map(ClipboardShareDestination::getAliases) + .flatMap(Set::stream), input); + } + + @Override + public ConversionResult convert(String s, InjectedValueAccess injectedValueAccess) { + ClipboardShareDestination result = ClipboardShareDestinations.findByAlias(s); + return result == null + ? FailedConversion.from(new IllegalArgumentException("Not a valid clipboard share destination: " + s)) + : SuccessfulConversion.fromSingle(result); + } +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java index 7b493cf98..b03e4ce54 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java @@ -86,6 +86,8 @@ import com.sk89q.worldedit.command.WorldEditCommandsRegistration; import com.sk89q.worldedit.command.argument.Arguments; import com.sk89q.worldedit.command.argument.BooleanConverter; import com.sk89q.worldedit.command.argument.Chunk3dVectorConverter; +import com.sk89q.worldedit.command.argument.ClipboardFormatConverter; +import com.sk89q.worldedit.command.argument.ClipboardShareDestinationConverter; import com.sk89q.worldedit.command.argument.CommaSeparatedValuesConverter; import com.sk89q.worldedit.command.argument.DirectionConverter; import com.sk89q.worldedit.command.argument.DirectionVectorConverter; @@ -174,7 +176,6 @@ import java.util.stream.Stream; import static com.google.common.base.Preconditions.checkNotNull; - /** * Handles the registration and invocation of commands. * @@ -272,6 +273,8 @@ public final class PlatformCommandManager { SideEffectConverter.register(commandManager); HeightConverter.register(commandManager); OffsetConverter.register(worldEdit, commandManager); + ClipboardFormatConverter.register(commandManager); + ClipboardShareDestinationConverter.register(commandManager); //FAWE start commandManager.registerConverter( Key.of(com.sk89q.worldedit.function.pattern.Pattern.class, Annotations.patternList()), @@ -604,7 +607,6 @@ public final class PlatformCommandManager { void registerCommandsWith(Platform platform) { LOGGER.info("Registering commands with " + platform.getClass().getCanonicalName()); - LocalConfiguration config = platform.getConfiguration(); boolean logging = config.logCommands; String path = config.logFile; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/Clipboard.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/Clipboard.java index d52fd1056..4cd2ead97 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/Clipboard.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/Clipboard.java @@ -31,6 +31,7 @@ import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSessionBuilder; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.entity.Entity; +import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter; @@ -40,6 +41,7 @@ import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.operation.ForwardExtentCopy; import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.math.BlockVector2; +import com.sk89q.worldedit.internal.util.ClipboardTransformBaker; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.transform.Transform; import com.sk89q.worldedit.regions.Region; @@ -98,7 +100,7 @@ public interface Clipboard extends Extent, Iterable, Closeable, Fl * - {@link DiskOptimizedClipboard} * - {@link CPUOptimizedClipboard} * - {@link MemoryOptimizedClipboard} - * + * * @deprecated Internal use only. Use {@link BlockArrayClipboard#BlockArrayClipboard(Region, UUID)} */ @Deprecated @@ -144,10 +146,9 @@ public interface Clipboard extends Extent, Iterable, Closeable, Fl void setOrigin(BlockVector3 origin); /** - * Returns true if the clipboard has biome data. This can be checked since {@link Extent#getBiome(BlockVector2)} + * Returns true if the clipboard has biome data. This can be checked since {@link Extent#getBiome(BlockVector3)} * strongly suggests returning {@link com.sk89q.worldedit.world.biome.BiomeTypes#OCEAN} instead of {@code null} - * if biomes aren't present. However, it might not be desired to set areas to ocean if the clipboard is defaulting - * to ocean, instead of having biomes explicitly set. + * if biomes aren't present. * * @return true if the clipboard has biome data set */ @@ -155,6 +156,21 @@ public interface Clipboard extends Extent, Iterable, Closeable, Fl return false; } + /** + * Returns a clipboard with a given transform baked in. + * + *

+ * Note: This method may return the same clipboard object, if a copy is needed then you should check the returned value for identity equality and copy if needed. + *

+ * + * @param transform The transform + * @return The new clipboard + * @throws WorldEditException if the copy encounters an error + */ + default Clipboard transform(Transform transform) throws WorldEditException { + return ClipboardTransformBaker.bakeTransform(this, transform); + } + //FAWE start /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormats.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormats.java index 03cce5d80..b69a7a0cc 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormats.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormats.java @@ -73,7 +73,7 @@ public class ClipboardFormats { checkNotNull(format); for (String key : format.getAliases()) { - String lowKey = key.toLowerCase(Locale.ENGLISH); + String lowKey = key.toLowerCase(Locale.ROOT); ClipboardFormat old = aliasMap.put(lowKey, format); if (old != null) { aliasMap.put(lowKey, old); @@ -83,7 +83,7 @@ public class ClipboardFormats { } } for (String ext : format.getFileExtensions()) { - String lowExt = ext.toLowerCase(Locale.ENGLISH); + String lowExt = ext.toLowerCase(Locale.ROOT); fileExtensionMap.put(lowExt, format); } registeredFormats.add(format); @@ -104,7 +104,7 @@ public class ClipboardFormats { @Nullable public static ClipboardFormat findByAlias(String alias) { checkNotNull(alias); - return aliasMap.get(alias.toLowerCase(Locale.ENGLISH).trim()); + return aliasMap.get(alias.toLowerCase(Locale.ROOT).trim()); } /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/share/BuiltInClipboardShareDestinations.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/share/BuiltInClipboardShareDestinations.java new file mode 100644 index 000000000..981debe4b --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/share/BuiltInClipboardShareDestinations.java @@ -0,0 +1,149 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.extent.clipboard.io.share; + +import com.fastasyncworldedit.core.configuration.Caption; +import com.fastasyncworldedit.core.configuration.Settings; +import com.fastasyncworldedit.core.util.arkitektonika.ArkitektonikaResponse; +import com.fastasyncworldedit.core.util.arkitektonika.ArkitektonikaSchematicUploader; +import com.google.common.collect.ImmutableSet; +import com.sk89q.worldedit.extension.platform.Actor; +import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat; +import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; +import com.sk89q.worldedit.util.formatting.text.TextComponent; +import com.sk89q.worldedit.util.formatting.text.event.ClickEvent; +import com.sk89q.worldedit.util.formatting.text.format.TextColor; +import com.sk89q.worldedit.util.paste.EngineHubPaste; +import com.sk89q.worldedit.util.paste.PasteMetadata; + +import java.io.ByteArrayOutputStream; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.util.Base64; +import java.util.function.Consumer; + +/** + * A collection of natively supported clipboard share destinations. + */ +public enum BuiltInClipboardShareDestinations implements ClipboardShareDestination { + + /** + * The EngineHub pastebin service, at https://paste.enginehub.org/ + */ + ENGINEHUB_PASTEBIN("enginehub_paste", "ehpaste") { + @Override + public String getName() { + return "EngineHub Paste"; + } + + @Override + public Consumer share(ClipboardShareMetadata metadata, ShareOutputProvider serializer) throws Exception { + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + + serializer.writeTo(outputStream); + + PasteMetadata pasteMetadata = new PasteMetadata(); + pasteMetadata.author = metadata.author(); + pasteMetadata.extension = "schem"; + pasteMetadata.name = metadata.name(); + EngineHubPaste pasteService = new EngineHubPaste(); + + URL url = pasteService.paste(new String( + Base64.getEncoder().encode(outputStream.toByteArray()), + StandardCharsets.UTF_8 + ), pasteMetadata).call(); + String urlString = url.toExternalForm() + ".schem"; + return actor -> actor.printInfo(TextComponent.of(urlString).clickEvent(ClickEvent.openUrl(urlString))); + } + + @Override + public ClipboardFormat getDefaultFormat() { + return BuiltInClipboardFormat.SPONGE_SCHEMATIC; + } + + @Override + public boolean supportsFormat(ClipboardFormat format) { + return format == getDefaultFormat(); + } + }, + + //FAWE start - add arkitektonika + ARKITEKTONIKA("arkitektonika", "fawe") { + + private ArkitektonikaSchematicUploader uploader; + + @Override + public String getName() { + return "Arkitektonika"; + } + + @Override + public Consumer share(final ClipboardShareMetadata metadata, final ShareOutputProvider serializer) throws + Exception { + if (uploader == null) { + uploader = new ArkitektonikaSchematicUploader(Settings.settings().WEB.ARKITEKTONIKA_BACKEND_URL); + } + final ArkitektonikaResponse response = uploader.uploadBlocking(metadata, serializer); + final String downloadUrl = Settings.settings().WEB.ARKITEKTONIKA_DOWNLOAD_URL.replace("{key}", response.downloadKey()); + final String deletionUrl = Settings.settings().WEB.ARKITEKTONIKA_DELETE_URL.replace("{key}", response.deletionKey()); + return actor -> { + actor.print(Caption.of( + "worldedit.schematic.share.response.arkitektonika.download", + Caption.of("worldedit.schematic.share.response.arkitektonika.click-here") + .color(TextColor.GREEN).clickEvent(ClickEvent.openUrl(downloadUrl)) + )); + actor.print(Caption.of( + "worldedit.schematic.share.response.arkitektonika.delete", + Caption.of("worldedit.schematic.share.response.arkitektonika.click-here") + .color(TextColor.RED).clickEvent(ClickEvent.openUrl(deletionUrl)) + )); + }; + } + + @Override + public ClipboardFormat getDefaultFormat() { + return BuiltInClipboardFormat.FAST; + } + + @Override + public boolean supportsFormat(final ClipboardFormat format) { + return format == BuiltInClipboardFormat.SPONGE_SCHEMATIC || + format == BuiltInClipboardFormat.FAST || + format == BuiltInClipboardFormat.MCEDIT_SCHEMATIC; + } + }; + //FAWE end + + private final ImmutableSet aliases; + + BuiltInClipboardShareDestinations(String... aliases) { + this.aliases = ImmutableSet.copyOf(aliases); + } + + @Override + public ImmutableSet getAliases() { + return this.aliases; + } + + @Override + public String getName() { + return name(); + } +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/share/ClipboardShareDestination.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/share/ClipboardShareDestination.java new file mode 100644 index 000000000..1b0cb9e21 --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/share/ClipboardShareDestination.java @@ -0,0 +1,72 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.extent.clipboard.io.share; + +import com.sk89q.worldedit.extension.platform.Actor; +import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; + +import java.util.Set; +import java.util.function.Consumer; + +public interface ClipboardShareDestination { + + /** + * Gets the name of this share destination. + * + * @return The name + */ + String getName(); + + /** + * Get a set of aliases. + * + * @return a set of aliases + */ + Set getAliases(); + + /** + * Share a clipboard output stream and return a URL. + * + *

+ * The serialized schematic can be retrieved by providing an {@link java.io.OutputStream} to {@code serializer}. + *

+ * + * @param metadata The clipboard metadata + * @param serializer A function taking the {@link java.io.OutputStream} + * @return A consumer to provide the actor with the share results + * @throws Exception if it failed to share + */ + Consumer share(ClipboardShareMetadata metadata, ShareOutputProvider serializer) throws Exception; + + /** + * Gets the default clipboard format for this share destination. + * + * @return The default format + */ + ClipboardFormat getDefaultFormat(); + + /** + * Gets whether the share destination supports the given format. + * + * @param format The format + * @return If it's supported + */ + boolean supportsFormat(ClipboardFormat format); +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/share/ClipboardShareDestinations.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/share/ClipboardShareDestinations.java new file mode 100644 index 000000000..cf9b408f1 --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/share/ClipboardShareDestinations.java @@ -0,0 +1,80 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.extent.clipboard.io.share; + +import com.sk89q.worldedit.WorldEdit; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import javax.annotation.Nullable; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; + +public class ClipboardShareDestinations { + + private static final Map aliasMap = new HashMap<>(); + private static final List registeredDestinations = new ArrayList<>(); + + public static void registerClipboardShareDestination(ClipboardShareDestination destination) { + checkNotNull(destination); + checkState(destination.supportsFormat(destination.getDefaultFormat()), "Destination must accept its default format"); + + for (String key : destination.getAliases()) { + String lowKey = key.toLowerCase(Locale.ROOT); + ClipboardShareDestination old = aliasMap.put(lowKey, destination); + if (old != null) { + aliasMap.put(lowKey, old); + WorldEdit.logger.warn(destination.getClass().getName() + " cannot override existing alias '" + lowKey + "' used by " + old.getClass().getName()); + } + } + registeredDestinations.add(destination); + } + + static { + for (BuiltInClipboardShareDestinations destination : BuiltInClipboardShareDestinations.values()) { + registerClipboardShareDestination(destination); + } + } + + /** + * Find the clipboard format named by the given alias. + * + * @param alias the alias + * @return the format, otherwise null if none is matched + */ + @Nullable + public static ClipboardShareDestination findByAlias(String alias) { + checkNotNull(alias); + return aliasMap.get(alias.toLowerCase(Locale.ROOT).trim()); + } + + public static Collection getAll() { + return Collections.unmodifiableCollection(registeredDestinations); + } + + private ClipboardShareDestinations() { + } +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/share/ClipboardShareMetadata.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/share/ClipboardShareMetadata.java new file mode 100644 index 000000000..2e5f6c042 --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/share/ClipboardShareMetadata.java @@ -0,0 +1,49 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.extent.clipboard.io.share; + +import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; + +/** + * Items of metadata about shared clipboards. + */ +public class ClipboardShareMetadata { + private final ClipboardFormat format; + private final String name; + private final String author; + + public ClipboardShareMetadata(ClipboardFormat format, String name, String author) { + this.format = format; + this.name = name; + this.author = author; + } + + public ClipboardFormat format() { + return this.format; + } + + public String name() { + return this.name; + } + + public String author() { + return this.author; + } +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/share/ShareOutputProvider.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/share/ShareOutputProvider.java new file mode 100644 index 000000000..6d7587925 --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/share/ShareOutputProvider.java @@ -0,0 +1,37 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.extent.clipboard.io.share; + +import com.sk89q.worldedit.WorldEditException; + +import java.io.IOException; +import java.io.OutputStream; + +@FunctionalInterface +public interface ShareOutputProvider { + + /** + * Provides the share output to {@code stream}. + * + * @throws IOException if it failed + * @throws WorldEditException if WorldEdit failed to serialize to the stream + */ + void writeTo(OutputStream stream) throws IOException, WorldEditException; +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/FlattenedClipboardTransform.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/util/ClipboardTransformBaker.java similarity index 79% rename from worldedit-core/src/main/java/com/sk89q/worldedit/command/FlattenedClipboardTransform.java rename to worldedit-core/src/main/java/com/sk89q/worldedit/internal/util/ClipboardTransformBaker.java index d32504ad4..daa969080 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/FlattenedClipboardTransform.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/util/ClipboardTransformBaker.java @@ -17,13 +17,16 @@ * along with this program. If not, see . */ -package com.sk89q.worldedit.command; +package com.sk89q.worldedit.internal.util; +import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.transform.BlockTransformExtent; import com.sk89q.worldedit.function.operation.ForwardExtentCopy; import com.sk89q.worldedit.function.operation.Operation; +import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.transform.AffineTransform; import com.sk89q.worldedit.math.transform.CombinedTransform; @@ -36,12 +39,10 @@ import static com.google.common.base.Preconditions.checkNotNull; /** * Helper class to 'bake' a transform into a clipboard. * - *

This class needs a better name and may need to be made more generic.

- * * @see Clipboard * @see Transform */ -public class FlattenedClipboardTransform { +public class ClipboardTransformBaker { private final Clipboard original; private final Transform transform; @@ -52,7 +53,7 @@ public class FlattenedClipboardTransform { * @param original the original clipboard * @param transform the transform */ - private FlattenedClipboardTransform(Clipboard original, Transform transform) { + private ClipboardTransformBaker(Clipboard original, Transform transform) { checkNotNull(original); checkNotNull(transform); this.original = original; @@ -64,7 +65,7 @@ public class FlattenedClipboardTransform { * * @return the transformed region */ - public Region getTransformedRegion() { + private Region getTransformedRegion() { Region region = original.getRegion(); Vector3 minimum = region.getMinimumPoint().toVector3(); Vector3 maximum = region.getMaximumPoint().toVector3(); @@ -73,8 +74,7 @@ public class FlattenedClipboardTransform { new CombinedTransform( new AffineTransform().translate(original.getOrigin().multiply(-1)), transform, - new AffineTransform().translate(original.getOrigin()) - ); + new AffineTransform().translate(original.getOrigin())); Vector3[] corners = new Vector3[]{ minimum, @@ -113,7 +113,7 @@ public class FlattenedClipboardTransform { * @param target the target * @return the operation */ - public Operation copyTo(Extent target) { + private Operation copyTo(Extent target) { //FAWE start Extent extent = original; if (transform != null && !transform.isIdentity()) { @@ -121,11 +121,7 @@ public class FlattenedClipboardTransform { } //FAWE end ForwardExtentCopy copy = new ForwardExtentCopy( - extent, - original.getRegion(), - original.getOrigin(), - target, - original.getOrigin() + extent, original.getRegion(), original.getOrigin(), target, original.getOrigin() ); copy.setTransform(transform); if (original.hasBiomes()) { @@ -140,9 +136,18 @@ public class FlattenedClipboardTransform { * @param original the original clipboard * @param transform the transform * @return a builder + * @throws WorldEditException if an error occurred during copy */ - public static FlattenedClipboardTransform transform(Clipboard original, Transform transform) { - return new FlattenedClipboardTransform(original, transform); + public static Clipboard bakeTransform(Clipboard original, Transform transform) throws WorldEditException { + if (transform.isIdentity()) { + return original; + } + ClipboardTransformBaker baker = new ClipboardTransformBaker(original, transform); + Clipboard target = new BlockArrayClipboard(baker.getTransformedRegion()); + target.setOrigin(original.getOrigin()); + Operations.complete(baker.copyTo(target)); + + return target; } } diff --git a/worldedit-core/src/main/resources/lang/strings.json b/worldedit-core/src/main/resources/lang/strings.json index c343dd623..c67da38d7 100644 --- a/worldedit-core/src/main/resources/lang/strings.json +++ b/worldedit-core/src/main/resources/lang/strings.json @@ -360,6 +360,11 @@ "worldedit.schematic.save.already-exists": "That schematic already exists. Use the -f flag to overwrite it.", "worldedit.schematic.save.failed-directory": "Could not create folder for schematics!", "worldedit.schematic.save.saving": "(Please wait... saving schematic.)", + "worldedit.schematic.save.still-saving": "(Please wait... still saving schematic.)", + "worldedit.schematic.share.unsupported-format": "The schematic share destination \"{0}\" does not support the \"{1}\" format.", + "worldedit.schematic.share.response.arkitektonika.download" : "Download: {0}", + "worldedit.schematic.share.response.arkitektonika.delete" : "Delete: {0}", + "worldedit.schematic.share.response.arkitektonika.click-here" : "[Click here]", "worldedit.schematic.delete.empty": "Schematic {0} not found!", "worldedit.schematic.delete.does-not-exist": "Schematic {0} does not exist!", "worldedit.schematic.delete.failed": "Deletion of {0} failed! Is it read-only?", From c41e38202c959f6f89c56e945800f16866c0081e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 00:48:40 +0000 Subject: [PATCH 82/90] Update dependency com.palmergames.bukkit.towny:towny to v0.100.2.12 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 38f8f3f32..d6bf97dcb 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -14,7 +14,7 @@ mapmanager = "1.8.0-SNAPSHOT" griefprevention = "17.0.0" griefdefender = "2.1.0-SNAPSHOT" residence = "4.5._13.1" -towny = "0.100.2.11" +towny = "0.100.2.12" plotsquared = "7.3.8" # Third party From da81530f869e0f3269eeabad89b2a8ed93396c4d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 00:48:46 +0000 Subject: [PATCH 83/90] Update dependency net.kyori:adventure-platform-bukkit to v4.3.3 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index d6bf97dcb..12c34eeca 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -22,7 +22,7 @@ bstats = "3.0.2" sparsebitset = "1.3" parallelgzip = "1.0.5" adventure = "4.17.0" -adventure-bukkit = "4.3.2" +adventure-bukkit = "4.3.3" checkerqual = "3.43.0" truezip = "6.8.4" auto-value = "1.10.4" From e044b92d45bad2536b881418cf52b1eab8b2b9ae Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 03:30:53 +0000 Subject: [PATCH 84/90] Update dependency paperweight-userdev --- worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts | 2 +- worldedit-bukkit/adapters/adapter-1_20_5/build.gradle.kts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts b/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts index 821b6c52d..c82a5bd55 100644 --- a/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts +++ b/worldedit-bukkit/adapters/adapter-1_20_4/build.gradle.kts @@ -12,6 +12,6 @@ repositories { dependencies { // url=https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/1.20.4-R0.1-SNAPSHOT - the().paperDevBundle("1.20.4-R0.1-20240424.165410-174") + the().paperDevBundle("1.20.4-R0.1-20240528.102248-175") compileOnly(libs.paperlib) } diff --git a/worldedit-bukkit/adapters/adapter-1_20_5/build.gradle.kts b/worldedit-bukkit/adapters/adapter-1_20_5/build.gradle.kts index 8f97a8454..43bc53f15 100644 --- a/worldedit-bukkit/adapters/adapter-1_20_5/build.gradle.kts +++ b/worldedit-bukkit/adapters/adapter-1_20_5/build.gradle.kts @@ -12,6 +12,6 @@ repositories { dependencies { // url=https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/1.20.6-R0.1-SNAPSHOT/ - the().paperDevBundle("1.20.6-R0.1-20240526.222003-87") + the().paperDevBundle("1.20.6-R0.1-20240602.222958-106") compileOnly(libs.paperlib) } From 393ed005245bd51f1251a5e62664a237af87d37b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 03:30:58 +0000 Subject: [PATCH 85/90] Update eps1lon/actions-label-merge-conflict action to v3.0.2 --- .github/workflows/label-merge-conflicts.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/label-merge-conflicts.yaml b/.github/workflows/label-merge-conflicts.yaml index 551b39417..8a2c30125 100644 --- a/.github/workflows/label-merge-conflicts.yaml +++ b/.github/workflows/label-merge-conflicts.yaml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Label conflicting PRs - uses: eps1lon/actions-label-merge-conflict@v3.0.1 + uses: eps1lon/actions-label-merge-conflict@v3.0.2 with: dirtyLabel: "unresolved-merge-conflict" repoToken: "${{ secrets.GITHUB_TOKEN }}" From a82ba31185e9142c8ce0b12d83d2a9d0ad573df6 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Sun, 2 Jun 2024 09:23:31 +0100 Subject: [PATCH 86/90] feat: allow NBT on wand items - closes #2383 --- .../core/util/gson/BaseItemAdapter.java | 61 +++++++++++++ .../com/sk89q/worldedit/LocalSession.java | 87 ++++++++++++++----- .../com/sk89q/worldedit/blocks/BaseItem.java | 1 + .../worldedit/command/SelectionCommands.java | 32 ++++--- .../sk89q/worldedit/command/ToolCommands.java | 4 +- .../util/PropertiesConfiguration.java | 4 +- .../worldedit/util/YAMLConfiguration.java | 4 +- .../sk89q/worldedit/util/gson/GsonUtil.java | 3 + 8 files changed, 156 insertions(+), 40 deletions(-) create mode 100644 worldedit-core/src/main/java/com/fastasyncworldedit/core/util/gson/BaseItemAdapter.java diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/gson/BaseItemAdapter.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/gson/BaseItemAdapter.java new file mode 100644 index 000000000..859ed9194 --- /dev/null +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/gson/BaseItemAdapter.java @@ -0,0 +1,61 @@ +package com.fastasyncworldedit.core.util.gson; + +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.JsonPrimitive; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import com.sk89q.worldedit.blocks.BaseItem; +import com.sk89q.worldedit.util.concurrency.LazyReference; +import com.sk89q.worldedit.util.nbt.TagStringIO; +import com.sk89q.worldedit.world.item.ItemType; +import com.sk89q.worldedit.world.item.ItemTypes; + +import java.io.IOException; +import java.lang.reflect.Type; + +public final class BaseItemAdapter implements JsonDeserializer, JsonSerializer { + + @Override + public BaseItem deserialize(JsonElement json, Type type, JsonDeserializationContext cont) throws JsonParseException { + JsonObject jsonObject = json.getAsJsonObject(); + JsonElement id = jsonObject.get("id"); + if (id != null) { + ItemType itemType = ItemTypes.get(id.getAsString()); + if (itemType == null) { + throw new JsonParseException("Could not parse item type `" + id + "`"); + } + return new BaseItem(itemType); + } + ItemType itemType = cont.deserialize(jsonObject.get("itemType").getAsJsonObject(), ItemType.class); + JsonElement nbt = jsonObject.get("nbt"); + if (nbt == null) { + return new BaseItem(itemType); + } + try { + return new BaseItem(itemType, LazyReference.computed(TagStringIO.get().asCompound(nbt.getAsString()))); + } catch (IOException e) { + throw new JsonParseException("Could not deserialize BaseItem", e); + } + } + + @Override + public JsonElement serialize( + final BaseItem baseItem, + final Type type, + final JsonSerializationContext jsonSerializationContext + ) { + JsonObject obj = new JsonObject(); + obj.add("itemType", jsonSerializationContext.serialize(baseItem.getType())); + try { + obj.add("nbt", baseItem.getNbt() == null ? null : new JsonPrimitive(TagStringIO.get().asString(baseItem.getNbt()))); + return obj; + } catch (IOException e) { + throw new JsonParseException("Could not deserialize BaseItem", e); + } + } + +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java index 5a5fa654e..8bf84ab8b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java @@ -52,6 +52,7 @@ import com.sk89q.worldedit.command.tool.SelectionWand; import com.sk89q.worldedit.command.tool.SinglePickaxe; import com.sk89q.worldedit.command.tool.Tool; import com.sk89q.worldedit.entity.Player; +import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Locatable; import com.sk89q.worldedit.extent.NullExtent; @@ -80,7 +81,6 @@ import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.item.ItemType; -import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldedit.world.snapshot.experimental.Snapshot; import com.zaxxer.sparsebits.SparseBitSet; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; @@ -182,8 +182,10 @@ public class LocalSession implements TextureHolder { private String lastScript; private RegionSelectorType defaultSelector; private boolean useServerCUI = false; // Save this to not annoy players. - private ItemType wandItem; - private ItemType navWandItem; + //FAWE start - allow NBT + private BaseItem wandItem; + private BaseItem navWandItem; + //FAWE end /** * Construct the object. @@ -1199,7 +1201,7 @@ public class LocalSession implements TextureHolder { tool = tools.get(item.getInternalId()); } if (tool == SelectionWand.INSTANCE && !SelectionWand.INSTANCE.canUse(player)) { - tools.remove(wandItem.getInternalId()); + tools.remove(wandItem.getType().getInternalId()); loadDefaults(player, true); // Permissions have changed so redo the player's current tools. return null; } @@ -1253,18 +1255,20 @@ public class LocalSession implements TextureHolder { if (loadDefaults || force) { loadDefaults = false; LocalConfiguration config = WorldEdit.getInstance().getConfiguration(); + ParserContext context = new ParserContext(); + context.setActor(actor); if (wandItem == null) { - wandItem = ItemTypes.parse(config.wandItem); + wandItem = WorldEdit.getInstance().getItemFactory().parseFromInput(config.wandItem, context); } if (navWandItem == null) { - navWandItem = ItemTypes.parse(config.navigationWand); + navWandItem = WorldEdit.getInstance().getItemFactory().parseFromInput(config.navigationWand, context); } synchronized (this.tools) { - if (tools.get(navWandItem.getInternalId()) == null && NavigationWand.INSTANCE.canUse(actor)) { - tools.put(navWandItem.getInternalId(), NavigationWand.INSTANCE); + if (tools.get(navWandItem.getType().getInternalId()) == null && NavigationWand.INSTANCE.canUse(actor)) { + tools.put(navWandItem.getType().getInternalId(), NavigationWand.INSTANCE); } - if (tools.get(wandItem.getInternalId()) == null && SelectionWand.INSTANCE.canUse(actor)) { - tools.put(wandItem.getInternalId(), SelectionWand.INSTANCE); + if (tools.get(wandItem.getType().getInternalId()) == null && SelectionWand.INSTANCE.canUse(actor)) { + tools.put(wandItem.getType().getInternalId(), SelectionWand.INSTANCE); } } } @@ -1334,10 +1338,23 @@ public class LocalSession implements TextureHolder { * @param item the item type * @param tool the tool to set, which can be {@code null} * @throws InvalidToolBindException if the item can't be bound to that item + * @deprecated use {@link #setTool(BaseItem, Tool)} */ + @Deprecated public void setTool(ItemType item, @Nullable Tool tool) throws InvalidToolBindException { - if (item.hasBlockType()) { - throw new InvalidToolBindException(item, Caption.of("worldedit.error.blocks-cant-be-used")); + setTool(new BaseItem(item), tool); + } + + /** + * Set the tool. + * + * @param item the item type + * @param tool the tool to set, which can be {@code null} + * @throws InvalidToolBindException if the item can't be bound to that item + */ + public void setTool(BaseItem item, @Nullable Tool tool) throws InvalidToolBindException { + if (item.getType().hasBlockType()) { + throw new InvalidToolBindException(item.getType(), Caption.of("worldedit.error.blocks-cant-be-used")); } if (tool instanceof SelectionWand) { changeTool(this.wandItem, this.wandItem = item, tool); @@ -1348,7 +1365,7 @@ public class LocalSession implements TextureHolder { setDirty(); return; } - setTool(item.getDefaultState(), tool, null); + setTool(item, tool, null); } public void setTool(Player player, @Nullable Tool tool) throws InvalidToolBindException { @@ -1356,17 +1373,17 @@ public class LocalSession implements TextureHolder { setTool(item, tool, player); } - private void changeTool(ItemType oldType, ItemType newType, Tool newTool) { - if (oldType != null) { + private void changeTool(BaseItem oldItem, BaseItem newItem, Tool newTool) { + if (oldItem != null) { synchronized (this.tools) { - this.tools.remove(oldType.getInternalId()); + this.tools.remove(oldItem.getType().getInternalId()); } } synchronized (this.tools) { if (newTool == null) { - this.tools.remove(newType.getInternalId()); + this.tools.remove(newItem.getType().getInternalId()); } else { - this.tools.put(newType.getInternalId(), newTool); + this.tools.put(newItem.getType().getInternalId(), newTool); } } } @@ -1376,11 +1393,11 @@ public class LocalSession implements TextureHolder { if (type.hasBlockType() && type.getBlockType().getMaterial().isAir()) { throw new InvalidToolBindException(type, Caption.of("worldedit.error.blocks-cant-be-used")); } else if (tool instanceof SelectionWand) { - changeTool(this.wandItem, this.wandItem = item.getType(), tool); + changeTool(this.wandItem, this.wandItem = item, tool); setDirty(); return; } else if (tool instanceof NavigationWand) { - changeTool(this.navWandItem, this.navWandItem = item.getType(), tool); + changeTool(this.navWandItem, this.navWandItem = item, tool); setDirty(); return; } @@ -1877,9 +1894,32 @@ public class LocalSession implements TextureHolder { * Get the preferred wand item for this user, or {@code null} to use the default * * @return item id of wand item, or {@code null} + * @deprecated use {@link #getWandBaseItem()} */ + @Deprecated public String getWandItem() { - return wandItem.getId(); + return wandItem.getType().getId(); + } + + /** + * Get the preferred navigation wand item for this user, or {@code null} to use the default + * + * @return item id of nav wand item, or {@code null} + * @deprecated use {@link #getNavWandBaseItem()} + */ + @Deprecated + public String getNavWandItem() { + return navWandItem.getType().getId(); + } + + //FAWE start + /** + * Get the preferred wand item for this user, or {@code null} to use the default + * + * @return item id of wand item, or {@code null} + */ + public BaseItem getWandBaseItem() { + return wandItem == null ? null : new BaseItem(wandItem.getType(), wandItem.getNbtReference()); } /** @@ -1887,9 +1927,10 @@ public class LocalSession implements TextureHolder { * * @return item id of nav wand item, or {@code null} */ - public String getNavWandItem() { - return navWandItem.getId(); + public BaseItem getNavWandBaseItem() { + return navWandItem == null ? null : new BaseItem(navWandItem.getType(), navWandItem.getNbtReference()); } + //FAWE end /** * Get the last block distribution stored in this session. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BaseItem.java b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BaseItem.java index 1dab627c7..ac8236297 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BaseItem.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BaseItem.java @@ -71,6 +71,7 @@ public class BaseItem implements NbtValued { * @param itemType The type to set */ public void setType(ItemType itemType) { + checkNotNull(itemType); this.itemType = itemType; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java index d8e0943dc..ac13defc3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java @@ -30,6 +30,7 @@ import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; +import com.sk89q.worldedit.blocks.BaseItem; import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.command.argument.SelectorChoice; import com.sk89q.worldedit.command.tool.NavigationWand; @@ -38,6 +39,8 @@ import com.sk89q.worldedit.command.util.CommandPermissions; import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; import com.sk89q.worldedit.command.util.Logging; import com.sk89q.worldedit.entity.Player; +import com.sk89q.worldedit.extension.input.InputParseException; +import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Locatable; import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits; @@ -325,22 +328,29 @@ public class SelectionCommands { //FAWE start session.loadDefaults(player, true); //FAWE end - String wandId = navWand ? session.getNavWandItem() : session.getWandItem(); - if (wandId == null) { - wandId = navWand ? we.getConfiguration().navigationWand : we.getConfiguration().wandItem; + BaseItem wand = navWand ? session.getNavWandBaseItem() : session.getWandBaseItem(); + if (wand == null) { + String wandId = navWand ? we.getConfiguration().navigationWand : we.getConfiguration().wandItem; + //FAWE start - allow item NBT + ParserContext parserContext = new ParserContext(); + parserContext.setActor(player); + parserContext.setSession(session); + try { + wand = WorldEdit.getInstance().getItemFactory().parseFromInput(wandId, parserContext); + } catch (InputParseException e) { + player.print(Caption.of("worldedit.wand.invalid")); + return; + } } - ItemType itemType = ItemTypes.parse(wandId); - if (itemType == null) { - player.print(Caption.of("worldedit.wand.invalid")); - return; - } - player.giveItem(new BaseItemStack(itemType, 1)); + System.out.println("a "+ wand); + player.giveItem(new BaseItemStack(wand.getType(), wand.getNbtReference(), 1)); + //FAWE end //FAWE start - instance-iate session if (navWand) { - session.setTool(itemType, NavigationWand.INSTANCE); + session.setTool(wand, NavigationWand.INSTANCE); player.print(Caption.of("worldedit.wand.navwand.info")); } else { - session.setTool(itemType, SelectionWand.INSTANCE); + session.setTool(wand, SelectionWand.INSTANCE); player.print(Caption.of("worldedit.wand.selwand.info")); //FAWE end } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java index 95499372c..f3be41469 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java @@ -149,7 +149,7 @@ public class ToolCommands { throws InvalidToolBindException { //FAWE start isBrush = session.getTool(player) instanceof BrushTool; - session.setTool(player.getItemInHand(HandSide.MAIN_HAND).getType(), null); + session.setTool(player.getItemInHand(HandSide.MAIN_HAND), null); //FAWE end player.print(Caption.of(isBrush ? "worldedit.brush.none.equip" : "worldedit.tool.none.equip")); } @@ -163,7 +163,7 @@ public class ToolCommands { String translationKey ) throws InvalidToolBindException { BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND); - session.setTool(itemStack.getType(), tool); + session.setTool(itemStack, tool); player.print(Caption.of(translationKey, itemStack.getRichName())); sendUnbindInstruction(player, UNBIND_COMMAND_COMPONENT); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java index 3804be8d3..7bec7c2f5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java @@ -112,7 +112,7 @@ public class PropertiesConfiguration extends LocalConfiguration { logFile = getString("log-file", logFile); logFormat = getString("log-format", logFormat); registerHelp = getBool("register-help", registerHelp); - wandItem = getString("wand-item", wandItem).toLowerCase(Locale.ROOT); + wandItem = getString("wand-item", wandItem); try { wandItem = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(wandItem)).getId(); } catch (Throwable ignored) { @@ -122,7 +122,7 @@ public class PropertiesConfiguration extends LocalConfiguration { useInventory = getBool("use-inventory", useInventory); useInventoryOverride = getBool("use-inventory-override", useInventoryOverride); useInventoryCreativeOverride = getBool("use-inventory-creative-override", useInventoryCreativeOverride); - navigationWand = getString("nav-wand-item", navigationWand).toLowerCase(Locale.ROOT); + navigationWand = getString("nav-wand-item", navigationWand); try { navigationWand = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(navigationWand)).getId(); } catch (Throwable ignored) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java index 7b0cbf4b8..4a5e45713 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java @@ -58,7 +58,7 @@ public class YAMLConfiguration extends LocalConfiguration { profile = config.getBoolean("debug", profile); traceUnflushedSessions = config.getBoolean("debugging.trace-unflushed-sessions", traceUnflushedSessions); - wandItem = convertLegacyItem(config.getString("wand-item", wandItem)).toLowerCase(Locale.ROOT); + wandItem = convertLegacyItem(config.getString("wand-item", wandItem)); defaultChangeLimit = Math.max(-1, config.getInt( "limits.max-blocks-changed.default", defaultChangeLimit)); @@ -130,7 +130,7 @@ public class YAMLConfiguration extends LocalConfiguration { useInventoryCreativeOverride ); - navigationWand = convertLegacyItem(config.getString("navigation-wand.item", navigationWand)).toLowerCase(Locale.ROOT); + navigationWand = convertLegacyItem(config.getString("navigation-wand.item", navigationWand)); navigationWandMaxDistance = config.getInt("navigation-wand.max-distance", navigationWandMaxDistance); navigationUseGlass = config.getBoolean("navigation.use-glass", navigationUseGlass); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/gson/GsonUtil.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/gson/GsonUtil.java index e5d05ee6d..416fbeaae 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/gson/GsonUtil.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/gson/GsonUtil.java @@ -19,10 +19,12 @@ package com.sk89q.worldedit.util.gson; +import com.fastasyncworldedit.core.util.gson.BaseItemAdapter; import com.fastasyncworldedit.core.util.gson.ItemTypeAdapter; import com.fastasyncworldedit.core.util.gson.RegionSelectorAdapter; import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.sk89q.worldedit.blocks.BaseItem; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.regions.RegionSelector; @@ -48,6 +50,7 @@ public final class GsonUtil { //FAWE start gsonBuilder.registerTypeAdapter(RegionSelector.class, new RegionSelectorAdapter()); gsonBuilder.registerTypeAdapter(ItemType.class, new ItemTypeAdapter()); + gsonBuilder.registerTypeAdapter(BaseItem.class, new BaseItemAdapter()); //FAWE end return gsonBuilder; } From 47b0ece3777ae13564575cc6569ed2c34cac40d4 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Sun, 2 Jun 2024 09:27:56 +0100 Subject: [PATCH 87/90] Add since tags to new methods --- .../src/main/java/com/sk89q/worldedit/LocalSession.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java index 8bf84ab8b..5df95414b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java @@ -1351,6 +1351,7 @@ public class LocalSession implements TextureHolder { * @param item the item type * @param tool the tool to set, which can be {@code null} * @throws InvalidToolBindException if the item can't be bound to that item + * @since TODO */ public void setTool(BaseItem item, @Nullable Tool tool) throws InvalidToolBindException { if (item.getType().hasBlockType()) { @@ -1917,6 +1918,7 @@ public class LocalSession implements TextureHolder { * Get the preferred wand item for this user, or {@code null} to use the default * * @return item id of wand item, or {@code null} + * @since TODO */ public BaseItem getWandBaseItem() { return wandItem == null ? null : new BaseItem(wandItem.getType(), wandItem.getNbtReference()); @@ -1926,6 +1928,7 @@ public class LocalSession implements TextureHolder { * Get the preferred navigation wand item for this user, or {@code null} to use the default * * @return item id of nav wand item, or {@code null} + * @since TODO */ public BaseItem getNavWandBaseItem() { return navWandItem == null ? null : new BaseItem(navWandItem.getType(), navWandItem.getNbtReference()); From a7e4d19605484b7eb3f2619ea270114be8fa56cf Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Sun, 2 Jun 2024 17:25:32 +0100 Subject: [PATCH 88/90] Remove debug --- .../main/java/com/sk89q/worldedit/command/SelectionCommands.java | 1 - 1 file changed, 1 deletion(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java index ac13defc3..d000fcef7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java @@ -342,7 +342,6 @@ public class SelectionCommands { return; } } - System.out.println("a "+ wand); player.giveItem(new BaseItemStack(wand.getType(), wand.getNbtReference(), 1)); //FAWE end //FAWE start - instance-iate session From 5714a526756e1819b1598f31211e26b48cdd217d Mon Sep 17 00:00:00 2001 From: Jordan Date: Wed, 5 Jun 2024 21:23:12 +0200 Subject: [PATCH 89/90] fix: correctly trim the max chunk section (#2753) - fixes #2727 - fixes IntellectualSites/Plotsquared#4436 --- .../regions/plotsquared/PlotSquaredFeature.java | 14 ++++++-------- .../core/queue/IBatchProcessor.java | 12 ++++-------- .../com/sk89q/worldedit/regions/CuboidRegion.java | 4 ++-- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/PlotSquaredFeature.java b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/PlotSquaredFeature.java index 9f0916a4b..49955a4fa 100644 --- a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/PlotSquaredFeature.java +++ b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/PlotSquaredFeature.java @@ -1,6 +1,5 @@ package com.fastasyncworldedit.bukkit.regions.plotsquared; -import com.fastasyncworldedit.core.FaweAPI; import com.fastasyncworldedit.core.configuration.Caption; import com.fastasyncworldedit.core.regions.FaweMask; import com.fastasyncworldedit.core.regions.FaweMaskManager; @@ -174,22 +173,21 @@ public class PlotSquaredFeature extends FaweMaskManager { return null; } + final World world = player.getWorld(); + int min = area != null ? area.getMinBuildHeight() : world.getMinY(); + // PlotSquared uses exclusive max height, WorldEdit uses inclusive max height -> subtract 1 + int max = area != null ? Math.min(world.getMaxY(), area.getMaxBuildHeight() - 1) : world.getMaxY(); Region maskedRegion; if (regions.size() == 1) { - final World world = player.getWorld(); - int min = area != null ? area.getMinBuildHeight() : world.getMinY(); - // PlotSquared uses exclusive max height, WorldEdit uses inclusive max height -> subtract 1 - int max = area != null ? Math.min(world.getMaxY(), area.getMaxBuildHeight() - 1) : world.getMaxY(); final CuboidRegion region = regions.iterator().next(); final BlockVector3 pos1 = BlockVector3.at(region.getMinimumX(), min, region.getMinimumZ()); final BlockVector3 pos2 = BlockVector3.at(region.getMaximumX(), max, region.getMaximumZ()); maskedRegion = new CuboidRegion(pos1, pos2); } else { - World world = FaweAPI.getWorld(area.getWorldName()); List weRegions = regions.stream().map( - r -> new CuboidRegion(world, BlockVector3.at(r.getMinimumX(), r.getMinimumY(), r.getMinimumZ()), - BlockVector3.at(r.getMaximumX(), r.getMaximumY(), r.getMaximumZ()) + r -> new CuboidRegion(world, BlockVector3.at(r.getMinimumX(), min, r.getMinimumZ()), + BlockVector3.at(r.getMaximumX(), max, r.getMaximumZ()) )).collect(Collectors.toList()); maskedRegion = new RegionIntersection(world, weRegions); } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IBatchProcessor.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IBatchProcessor.java index 778f85ce4..4ba91a4f3 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IBatchProcessor.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IBatchProcessor.java @@ -58,7 +58,7 @@ public interface IBatchProcessor { /** * Utility method to trim a chunk based on min and max Y (inclusive). * - * @param keepInsideRange if all blocks inside the range (inclusive) should be kept (default) + * @param keepInsideRange if all blocks inside the range (inclusive) should be kept (default), or removed * @return false if chunk is empty of blocks */ default boolean trimY(IChunkSet set, int minY, int maxY, final boolean keepInsideRange) { @@ -74,16 +74,14 @@ public interface IBatchProcessor { for (int i = 0; i < index; i++) { arr[i] = BlockTypesCache.ReservedIDs.__RESERVED__; } - } else { - arr = new char[4096]; + set.setBlocks(layer, arr); } - set.setBlocks(layer, arr); } else { set.setBlocks(layer, null); } } } - for (int layer = maxLayer; layer < set.getMaxSectionPosition(); layer++) { + for (int layer = maxLayer; layer <= set.getMaxSectionPosition(); layer++) { if (set.hasSection(layer)) { if (layer == maxLayer) { char[] arr = set.loadIfPresent(layer); @@ -92,10 +90,8 @@ public interface IBatchProcessor { for (int i = index; i < arr.length; i++) { arr[i] = BlockTypesCache.ReservedIDs.__RESERVED__; } - } else { - arr = new char[4096]; + set.setBlocks(layer, arr); } - set.setBlocks(layer, arr); } else { set.setBlocks(layer, null); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java index 8616cbb2b..8e4da9214 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java @@ -828,7 +828,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { return set; } - for (int layer = get.getMinSectionPosition(); layer < get.getMaxSectionPosition(); layer++) { + for (int layer = get.getMinSectionPosition(); layer <= get.getMaxSectionPosition(); layer++) { if (!set.hasSection(layer)) { continue; } @@ -912,7 +912,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { boolean trimX = lowerX != 0 || upperX != 15; boolean trimZ = lowerZ != 0 || upperZ != 15; - for (int layer = get.getMinSectionPosition(); layer < get.getMaxSectionPosition(); layer++) { + for (int layer = get.getMinSectionPosition(); layer <= get.getMaxSectionPosition(); layer++) { if (!set.hasSection(layer)) { continue; } From c095c492e0264fc19a9d6f453183adf0f9f3f2e7 Mon Sep 17 00:00:00 2001 From: EpicPlayerA10 <62206933+EpicPlayerA10@users.noreply.github.com> Date: Fri, 7 Jun 2024 12:30:31 +0200 Subject: [PATCH 90/90] fix: normalize layer when setting ordinal to ThreadUnsafeCharBlocks (#2764) - fixes #2763 --- .../queue/implementation/blocks/ThreadUnsafeCharBlocks.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/ThreadUnsafeCharBlocks.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/ThreadUnsafeCharBlocks.java index 54331279f..90ae6b32e 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/ThreadUnsafeCharBlocks.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/ThreadUnsafeCharBlocks.java @@ -222,7 +222,7 @@ public class ThreadUnsafeCharBlocks implements IChunkSet, IBlocks { } public void set(int x, int y, int z, char value) { - final int layer = y >> 4; + final int layer = (y >> 4) - minSectionPosition; final int index = (y & 15) << 8 | z << 4 | x; try { blocks[layer][index] = value;