From 5ff9b1226afde47996bbe151b95e7e20e439243b Mon Sep 17 00:00:00 2001 From: MattBDev <4009945+MattBDev@users.noreply.github.com> Date: Wed, 5 Feb 2020 17:54:19 -0500 Subject: [PATCH] Minor EditSession changes --- .../java/com/sk89q/worldedit/EditSession.java | 42 ++++++++++++------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java index 77509df7b..801dd1974 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -19,12 +19,6 @@ package com.sk89q.worldedit; -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; -import static com.sk89q.worldedit.regions.Regions.asFlatRegion; -import static com.sk89q.worldedit.regions.Regions.maximumBlockY; -import static com.sk89q.worldedit.regions.Regions.minimumBlockY; - import com.boydti.fawe.FaweCache; import com.boydti.fawe.config.Caption; import com.boydti.fawe.config.Settings; @@ -130,7 +124,10 @@ 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.registry.LegacyMapper; -import java.io.IOException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -139,11 +136,15 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; +import java.io.IOException; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Range; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.sk89q.worldedit.regions.Regions.asFlatRegion; +import static com.sk89q.worldedit.regions.Regions.maximumBlockY; +import static com.sk89q.worldedit.regions.Regions.minimumBlockY; /** * An {@link Extent} that handles history, {@link BlockBag}s, change limits, @@ -1446,6 +1447,17 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { return this.changes = copy.getAffected(); } + /** + * Move the blocks in a region a certain direction. + * + * @param region the region to move + * @param dir the direction + * @param distance the distance to move + * @param copyAir true to copy air blocks + * @param replacement the replacement pattern to fill in after moving, or null to use air + * @return number of blocks moved + * @throws MaxChangedBlocksException thrown if too many blocks are changed + */ public int moveRegion(Region region, BlockVector3 dir, int distance, boolean copyAir, boolean moveEntities, boolean copyBiomes, Pattern replacement) throws MaxChangedBlocksException { Mask mask = null; @@ -1601,7 +1613,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { MaskIntersection blockMask = new MaskUnion(liquidMask, Masks.negate(new ExistingBlockMask(this))); // There are boundaries that the routine needs to stay in - Mask mask = new MaskIntersection( + MaskIntersection mask = new MaskIntersection( new BoundedHeightMask(0, Math.min(origin.getBlockY(), getWorld().getMaxY())), new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))), blockMask @@ -2290,15 +2302,15 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { * @throws MaxChangedBlocksException */ public int makeShape(final Region region, final Vector3 zero, final Vector3 unit, - final Pattern pattern, final String expressionString, final boolean hollow, final int timeout) + final Pattern pattern, final String expressionString, final boolean hollow, final int timeout) throws ExpressionException, MaxChangedBlocksException { final Expression expression = Expression.compile(expressionString, "x", "y", "z", "type", "data"); expression.optimize(); final Variable typeVariable = expression.getSlots().getVariable("type") - .orElseThrow(IllegalStateException::new); + .orElseThrow(IllegalStateException::new); final Variable dataVariable = expression.getSlots().getVariable("data") - .orElseThrow(IllegalStateException::new); + .orElseThrow(IllegalStateException::new); final WorldEditExpressionEnvironment environment = new WorldEditExpressionEnvironment(this, unit, zero); expression.setEnvironment(environment); @@ -2356,7 +2368,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { } public int deformRegion(final Region region, final Vector3 zero, final Vector3 unit, final String expressionString, - final int timeout) throws ExpressionException, MaxChangedBlocksException { + final int timeout) throws ExpressionException, MaxChangedBlocksException { final Expression expression = Expression.compile(expressionString, "x", "y", "z"); expression.optimize();