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>
Dieser Commit ist enthalten in:
eztaK-red 2023-03-06 13:53:07 +01:00 committet von GitHub
Ursprung 94f57799d0
Commit 211e8034ff
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23

Datei anzeigen

@ -3025,9 +3025,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
// transform // transform
expression.evaluate(new double[]{scaled.getX(), scaled.getY(), scaled.getZ()}, timeout); expression.evaluate(new double[]{scaled.getX(), scaled.getY(), scaled.getZ()}, timeout);
int xv = (int) (x.getValue() * unit.getX() + zero2.getX()); int xv = (int) Math.floor(x.getValue() * unit.getX() + zero2.getX());
int yv = (int) (y.getValue() * unit.getY() + zero2.getY()); int yv = (int) Math.floor(y.getValue() * unit.getY() + zero2.getY());
int zv = (int) (z.getValue() * unit.getZ() + zero2.getZ()); int zv = (int) Math.floor(z.getValue() * unit.getZ() + zero2.getZ());
BlockState get; BlockState get;
if (yv >= minY && yv <= maxY) { if (yv >= minY && yv <= maxY) {