From 04e281e72d588efcb078df3b75756cda9a235bd1 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Sat, 16 Apr 2016 18:16:08 +1000 Subject: [PATCH] Fix deform --- build.gradle | 2 +- bukkit/build/resources/main/plugin.yml | 2 +- bukkit/src/main/resources/plugin.yml | 2 +- .../java/com/sk89q/worldedit/EditSession.java | 25 ++---------- .../function/operation/Operations.java | 6 +-- .../sk89q/worldedit/regions/CuboidRegion.java | 39 +++++++++++++++++++ .../com/boydti/fawe/forge/SpongeMain.java | 2 +- pom.xml | 2 +- 8 files changed, 50 insertions(+), 30 deletions(-) diff --git a/build.gradle b/build.gradle index 6ccab276..3e11f4cf 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ buildscript { } group = 'com.boydti.fawe' -version = '3.3.12' +version = '3.3.13' description = """FastAsyncWorldEdit""" subprojects { diff --git a/bukkit/build/resources/main/plugin.yml b/bukkit/build/resources/main/plugin.yml index 292a1f4b..c14d5c9e 100644 --- a/bukkit/build/resources/main/plugin.yml +++ b/bukkit/build/resources/main/plugin.yml @@ -1,6 +1,6 @@ name: FastAsyncWorldEdit main: com.boydti.fawe.bukkit.FaweBukkit -version: 3.3.12 +version: 3.3.13 description: Fast Async WorldEdit plugin authors: [Empire92] loadbefore: [WorldEdit] diff --git a/bukkit/src/main/resources/plugin.yml b/bukkit/src/main/resources/plugin.yml index 292a1f4b..c14d5c9e 100644 --- a/bukkit/src/main/resources/plugin.yml +++ b/bukkit/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: FastAsyncWorldEdit main: com.boydti.fawe.bukkit.FaweBukkit -version: 3.3.12 +version: 3.3.13 description: Fast Async WorldEdit plugin authors: [Empire92] loadbefore: [WorldEdit] diff --git a/core/src/main/java/com/sk89q/worldedit/EditSession.java b/core/src/main/java/com/sk89q/worldedit/EditSession.java index 60733b90..9603ca4b 100644 --- a/core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -113,7 +113,6 @@ import com.sk89q.worldedit.regions.shape.RegionShape; import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment; import com.sk89q.worldedit.util.Countable; import com.sk89q.worldedit.util.TreeGenerator; -import com.sk89q.worldedit.util.collection.DoubleArrayList; import com.sk89q.worldedit.util.eventbus.EventBus; import com.sk89q.worldedit.world.AbstractWorld; import com.sk89q.worldedit.world.World; @@ -2255,43 +2254,25 @@ public class EditSession implements Extent { public int deformRegion(final Region region, final Vector zero, final Vector unit, final String expressionString) throws ExpressionException, MaxChangedBlocksException { final Expression expression = Expression.compile(expressionString, "x", "y", "z"); expression.optimize(); - final RValue x = expression.getVariable("x", false); final RValue y = expression.getVariable("y", false); final RValue z = expression.getVariable("z", false); - final WorldEditExpressionEnvironment environment = new WorldEditExpressionEnvironment(this, unit, zero); expression.setEnvironment(environment); - - final DoubleArrayList queue = new DoubleArrayList(false); - - for (final BlockVector position : region) { + int affected = 0; + for (BlockVector position : region) { // offset, scale final Vector scaled = position.subtract(zero).divide(unit); - // transform expression.evaluate(scaled.getX(), scaled.getY(), scaled.getZ()); - final BlockVector sourcePosition = environment.toWorld(x.getValue(), y.getValue(), z.getValue()); - // read block from world - final BaseBlock material = new BaseBlock(this.world.getBlockType(sourcePosition), this.world.getBlockData(sourcePosition)); - + BaseBlock material = FaweCache.CACHE_BLOCK[this.queue.getCombinedId4Data(sourcePosition.getBlockX(), sourcePosition.getBlockY(), sourcePosition.getBlockZ())]; // queue operation - queue.put(position, material); - } - - int affected = 0; - for (final Map.Entry entry : queue) { - final BlockVector position = entry.getKey(); - final BaseBlock material = entry.getValue(); - - // set at new position if (this.setBlock(position, material)) { ++affected; } } - return affected; } diff --git a/core/src/main/java/com/sk89q/worldedit/function/operation/Operations.java b/core/src/main/java/com/sk89q/worldedit/function/operation/Operations.java index 15809f06..1d91303b 100644 --- a/core/src/main/java/com/sk89q/worldedit/function/operation/Operations.java +++ b/core/src/main/java/com/sk89q/worldedit/function/operation/Operations.java @@ -34,7 +34,7 @@ public final class Operations { /** * Complete a given operation synchronously until it completes. * - * @param op operation to execute + * @param operation operation to execute * @throws WorldEditException WorldEdit exception */ public static void complete(Operation operation) throws WorldEditException { @@ -47,7 +47,7 @@ public final class Operations { * Complete a given operation synchronously until it completes. Catch all * errors that is not {@link MaxChangedBlocksException} for legacy reasons. * - * @param op operation to execute + * @param operation operation to execute * @throws MaxChangedBlocksException thrown when too many blocks have been changed */ public static void completeLegacy(Operation operation) throws MaxChangedBlocksException { @@ -65,7 +65,7 @@ public final class Operations { * {@link com.sk89q.worldedit.WorldEditException} exceptions as * {@link java.lang.RuntimeException}s. * - * @param op operation to execute + * @param operation operation to execute */ public static void completeBlindly(Operation operation) { try { diff --git a/core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java b/core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java index 16511b0e..4dd4d125 100644 --- a/core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java +++ b/core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java @@ -416,6 +416,45 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { }; } + public Iterator iterator_old() { + final BlockVector v = new BlockVector(0,0,0); + return new Iterator() { + private Vector min = getMinimumPoint(); + private Vector max = getMaximumPoint(); + private int nextX = min.getBlockX(); + private int nextY = min.getBlockY(); + private int nextZ = min.getBlockZ(); + + @Override + public boolean hasNext() { + return (nextX != Integer.MIN_VALUE); + } + + @Override + public BlockVector next() { + v.x = nextX; + v.y = nextY; + v.z = nextZ; + if (++nextX > max.getBlockX()) { + nextX = min.getBlockX(); + if (++nextY > max.getBlockY()) { + nextY = min.getBlockY(); + if (++nextZ > max.getBlockZ()) { + nextX = Integer.MIN_VALUE; + } + } + } + return v; + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + }; + } + + @Override public Iterable asFlatRegion() { return new Iterable() { diff --git a/forge/src/main/java/com/boydti/fawe/forge/SpongeMain.java b/forge/src/main/java/com/boydti/fawe/forge/SpongeMain.java index e6a79210..7124b77e 100644 --- a/forge/src/main/java/com/boydti/fawe/forge/SpongeMain.java +++ b/forge/src/main/java/com/boydti/fawe/forge/SpongeMain.java @@ -13,7 +13,7 @@ import org.spongepowered.api.plugin.Plugin; import org.spongepowered.api.plugin.PluginContainer; import org.spongepowered.api.profile.GameProfileManager; -@Plugin(id = "com.boydti.fawe", name = "FastAsyncWorldEdit", description = "Lagless WorldEdit, Area restrictions, Memory mangement, Block logging", url = "https://github.com/boy0001/FastAsyncWorldedit", version = "3.3.12") +@Plugin(id = "com.boydti.fawe", name = "FastAsyncWorldEdit", description = "Lagless WorldEdit, Area restrictions, Memory mangement, Block logging", url = "https://github.com/boy0001/FastAsyncWorldedit", version = "3.3.13") public class SpongeMain { public PluginContainer plugin; diff --git a/pom.xml b/pom.xml index 56732234..4dea2a42 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ UTF-8 FastAsyncWorldEdit - 3.3.12 + 3.3.13 FastAsyncWorldEdit jar