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 <mc.cache@web.de>
This commit is contained in:
eztaK-red 2023-03-06 13:53:07 +01:00 committed by GitHub
parent 94f57799d0
commit 211e8034ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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) {