Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-24 01:50:06 +01:00
Fixed //center not working in some cases.
Due to odd rounding and math issues, using //center on a region with an edge of even length in quadrants with negative coordinates would only fill one of the two center blocks. Thanks to Griffrez and up201406036 for the original PR. Fixes WORDLEDIT-2986.
Dieser Commit ist enthalten in:
Ursprung
a4f1f57c9d
Commit
b2fb73582f
@ -59,6 +59,7 @@ import com.sk89q.worldedit.history.changeset.ChangeSet;
|
||||
import com.sk89q.worldedit.internal.expression.Expression;
|
||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||
import com.sk89q.worldedit.internal.expression.runtime.RValue;
|
||||
import com.sk89q.worldedit.math.MathUtils;
|
||||
import com.sk89q.worldedit.math.interpolation.Interpolation;
|
||||
import com.sk89q.worldedit.math.interpolation.KochanekBartelsInterpolation;
|
||||
import com.sk89q.worldedit.math.interpolation.Node;
|
||||
@ -963,8 +964,9 @@ public class EditSession implements Extent {
|
||||
Vector center = region.getCenter();
|
||||
Region centerRegion = new CuboidRegion(
|
||||
getWorld(), // Causes clamping of Y range
|
||||
new Vector((int) center.getX(), (int) center.getY(), (int) center.getZ()),
|
||||
center.toBlockVector());
|
||||
new Vector(((int) center.getX()), ((int) center.getY()), ((int) center.getZ())),
|
||||
new Vector(MathUtils.roundHalfUp(center.getX()),
|
||||
center.getY(), MathUtils.roundHalfUp(center.getZ())));
|
||||
return setBlocks(centerRegion, pattern);
|
||||
}
|
||||
|
||||
|
@ -105,4 +105,16 @@ public final class MathUtils {
|
||||
return Math.sin(Math.toRadians(degrees));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the rounded double of the given value, rounding to the
|
||||
* nearest integer value away from zero on ties.
|
||||
*
|
||||
* This behavior is the same as {@link java.math.RoundingMode#HALF_UP}.
|
||||
*
|
||||
* @param value the value
|
||||
* @return the rounded value
|
||||
*/
|
||||
public static double roundHalfUp(double value) {
|
||||
return Math.signum(value) * Math.round(Math.abs(value));
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren