From 211e8034ff67926a7be3a4628ecb4e0fe3a74381 Mon Sep 17 00:00:00 2001 From: eztaK-red Date: Mon, 6 Mar 2023 13:53:07 +0100 Subject: [PATCH] Fix off by one error for negative coordinates when using -r with //deform (#2092) The problem: Off by one error for negative coordinates. Source: Behaviour of rounding coordinates (doubles) after deform. The off by error came down to rounding using casts (int) and rounding using Math.floor() (int)( 1.8) = 1 (int)(-1.8) = -1 (int)Math.floor( 1.8) = 1 (int)Math.floor(-1.8) = -2 Looking at the original WorldEdit implementation a Math.floor call is present too. It was missing FAWE which resulted in the bug. Co-authored-by: Alexander Brandes --- .../src/main/java/com/sk89q/worldedit/EditSession.java | 6 +++--- 1 file changed, 3 insertions(+), 3 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 75a010a75..1b405fe75 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -3025,9 +3025,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { // transform expression.evaluate(new double[]{scaled.getX(), scaled.getY(), scaled.getZ()}, timeout); - int xv = (int) (x.getValue() * unit.getX() + zero2.getX()); - int yv = (int) (y.getValue() * unit.getY() + zero2.getY()); - int zv = (int) (z.getValue() * unit.getZ() + zero2.getZ()); + 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()); BlockState get; if (yv >= minY && yv <= maxY) {