From 90b3439dc240a7078650aa5626ed2c53e2fc316c Mon Sep 17 00:00:00 2001 From: IronApollo Date: Sun, 13 Jan 2019 01:38:08 -0500 Subject: [PATCH] Even more changes made towards a proper Vector update, as well as minor FAVS changes to accomodate for recent vector changes. --- .../brush/BlockResetSurfaceBrush.java | 2 +- .../voxelsniper/brush/OverlayBrush.java | 2 +- .../brush/SplatterOverlayBrush.java | 2 +- .../voxelsniper/brush/UnderlayBrush.java | 2 +- .../brush/perform/PatternPerformer.java | 7 +- .../fawe/command/FawePrimitiveBinding.java | 70 ++++++++++++++++++- .../worldedit/world/block/BlockTypes.java | 2 +- 7 files changed, 75 insertions(+), 12 deletions(-) diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlockResetSurfaceBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlockResetSurfaceBrush.java index de93fa6eb..332699ce2 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlockResetSurfaceBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlockResetSurfaceBrush.java @@ -4,8 +4,8 @@ import java.util.ArrayList; import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.boydti.fawe.bukkit.wrapper.AsyncWorld; -import com.sk89q.worldedit.blocks.BlockMaterial; import com.sk89q.worldedit.bukkit.BukkitAdapter; +import com.sk89q.worldedit.world.registry.BlockMaterial; import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.SnipeData; diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/OverlayBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/OverlayBrush.java index fa599b04d..20d31a1d6 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/OverlayBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/OverlayBrush.java @@ -1,7 +1,7 @@ package com.thevoxelbox.voxelsniper.brush; -import com.sk89q.worldedit.blocks.BlockMaterial; import com.sk89q.worldedit.world.block.BlockTypes; +import com.sk89q.worldedit.world.registry.BlockMaterial; import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterOverlayBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterOverlayBrush.java index baea84b19..c74e4aaf7 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterOverlayBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterOverlayBrush.java @@ -1,7 +1,7 @@ package com.thevoxelbox.voxelsniper.brush; -import com.sk89q.worldedit.blocks.BlockMaterial; import com.sk89q.worldedit.world.block.BlockTypes; +import com.sk89q.worldedit.world.registry.BlockMaterial; import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/UnderlayBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/UnderlayBrush.java index 38e8ea2c3..28a68b65c 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/UnderlayBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/UnderlayBrush.java @@ -1,7 +1,7 @@ package com.thevoxelbox.voxelsniper.brush; -import com.sk89q.worldedit.blocks.BlockMaterial; import com.sk89q.worldedit.world.block.BlockTypes; +import com.sk89q.worldedit.world.registry.BlockMaterial; import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush; diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/PatternPerformer.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/PatternPerformer.java index aade828fa..dbbfd0782 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/PatternPerformer.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/perform/PatternPerformer.java @@ -2,10 +2,10 @@ package com.thevoxelbox.voxelsniper.brush.perform; import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.boydti.fawe.object.pattern.PatternTraverser; -import com.sk89q.worldedit.MutableBlockVector; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.pattern.Pattern; +import com.sk89q.worldedit.math.BlockVector3; import com.thevoxelbox.voxelsniper.Message; import com.thevoxelbox.voxelsniper.SnipeData; import org.bukkit.block.Block; @@ -14,7 +14,6 @@ public class PatternPerformer extends vPerformer { private String info; private Pattern pattern; private Extent extent; - private MutableBlockVector mutable = new MutableBlockVector(); @Override public void info(Message vm) { @@ -33,9 +32,9 @@ public class PatternPerformer extends vPerformer { @Override public void perform(AsyncBlock block) { - mutable.setComponents(block.getX(), block.getY(), block.getZ()); + BlockVector3 bv = BlockVector3.at(block.getX(), block.getY(), block.getZ()); try { - pattern.apply(extent, mutable, mutable); + pattern.apply(extent, bv, bv); } catch (WorldEditException e) { throw new RuntimeException(e); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/command/FawePrimitiveBinding.java b/worldedit-core/src/main/java/com/boydti/fawe/command/FawePrimitiveBinding.java index 3908e317c..eacaf53cf 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/command/FawePrimitiveBinding.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/command/FawePrimitiveBinding.java @@ -20,6 +20,8 @@ import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.internal.expression.Expression; import com.sk89q.worldedit.internal.expression.ExpressionException; import com.sk89q.worldedit.internal.expression.runtime.EvaluationException; +import com.sk89q.worldedit.math.BlockVector2; +import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector2; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.session.request.Request; @@ -261,7 +263,7 @@ public class FawePrimitiveBinding extends BindingHelper { behavior = BindingBehavior.CONSUMES, consumedCount = 1, provideModifiers = true) - public Vector3 getVector(ArgumentStack context, Annotation[] modifiers) throws ParameterException { + public Vector3 getVector3(ArgumentStack context, Annotation[] modifiers) throws ParameterException { String radiusString = context.next(); String[] radii = radiusString.split(","); final double radiusX, radiusY, radiusZ; @@ -294,7 +296,7 @@ public class FawePrimitiveBinding extends BindingHelper { behavior = BindingBehavior.CONSUMES, consumedCount = 1, provideModifiers = true) - public Vector2 getVector2D(ArgumentStack context, Annotation[] modifiers) throws ParameterException { + public Vector2 getVector2(ArgumentStack context, Annotation[] modifiers) throws ParameterException { String radiusString = context.next(); String[] radii = radiusString.split(","); final double radiusX, radiusZ; @@ -312,7 +314,69 @@ public class FawePrimitiveBinding extends BindingHelper { throw new ParameterException("You must either specify 1 or 2 radius values."); } return Vector2.at(radiusX, radiusZ); - } + } /** + * Gets a type from a {@link ArgumentStack}. + * + * @param context the context + * @return the requested type + * @throws ParameterException on error + */ + @BindingMatch(type = BlockVector3.class, + behavior = BindingBehavior.CONSUMES, + consumedCount = 1, + provideModifiers = true) + public BlockVector3 getBlockVector3(ArgumentStack context, Annotation[] modifiers) throws ParameterException { + String radiusString = context.next(); + String[] radii = radiusString.split(","); + final double radiusX, radiusY, radiusZ; + switch (radii.length) { + case 1: + radiusX = radiusY = radiusZ = Math.max(1, FawePrimitiveBinding.parseNumericInput(radii[0])); + break; + + case 3: + radiusX = Math.max(1, FawePrimitiveBinding.parseNumericInput(radii[0])); + radiusY = Math.max(1, FawePrimitiveBinding.parseNumericInput(radii[1])); + radiusZ = Math.max(1, FawePrimitiveBinding.parseNumericInput(radii[2])); + break; + + default: + throw new ParameterException("You must either specify 1 or 3 radius values."); + } + return BlockVector3.at(radiusX, radiusY, radiusZ); + } + + + /** + * Gets a type from a {@link ArgumentStack}. + * + * @param context the context + * @return the requested type + * @throws ParameterException on error + */ + @BindingMatch(type = BlockVector2.class, + behavior = BindingBehavior.CONSUMES, + consumedCount = 1, + provideModifiers = true) + public BlockVector2 getBlockVector2(ArgumentStack context, Annotation[] modifiers) throws ParameterException { + String radiusString = context.next(); + String[] radii = radiusString.split(","); + final double radiusX, radiusZ; + switch (radii.length) { + case 1: + radiusX = radiusZ = Math.max(1, FawePrimitiveBinding.parseNumericInput(radii[0])); + break; + + case 2: + radiusX = Math.max(1, FawePrimitiveBinding.parseNumericInput(radii[0])); + radiusZ = Math.max(1, FawePrimitiveBinding.parseNumericInput(radii[1])); + break; + + default: + throw new ParameterException("You must either specify 1 or 2 radius values."); + } + return BlockVector2.at(radiusX, radiusZ); + } /** * Try to parse numeric input as either a number or a mathematical expression. 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 51d580d78..3c550d7fe 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 @@ -772,7 +772,7 @@ public enum BlockTypes implements BlockType { String name = (name().indexOf(':') == -1 ? "minecraft:" : "") + name().toLowerCase(); ReflectionUtils.setFailsafeFieldValue(BlockTypes.class.getDeclaredField("id"), this, name); } - Settings settings = new Settings(this, id, internalId, states); + Settings settings = new Settings((this.getTypeEnum() == BlockTypes.__RESERVED__ ? BlockTypes.AIR : this), id, internalId, states); ReflectionUtils.setFailsafeFieldValue(BlockTypes.class.getDeclaredField("settings"), this, settings); } catch (Throwable e) { e.printStackTrace();