Fix for #1983, Use Math.floor instead of int cast (#1986)

This commit is contained in:
JOO200 2021-12-28 12:16:16 +01:00 committed by GitHub
parent 92dfe5e44e
commit 3fa364b448
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -144,7 +144,7 @@ public int apply(int[] data) throws MaxChangedBlocksException {
// Grow -- start from 1 below top replacing airblocks
for (int y = newHeight - 1 - originY; y >= 0; --y) {
int copyFrom = (int) (y * scale);
int copyFrom = (int) Math.floor(y * scale);
session.setBlock(BlockVector3.at(xr, originY + y, zr), session.getBlock(BlockVector3.at(xr, originY + copyFrom, zr)));
++blocksChanged;
}
@ -152,7 +152,7 @@ public int apply(int[] data) throws MaxChangedBlocksException {
} else if (curHeight > newHeight) {
// Shrink -- start from bottom
for (int y = 0; y < newHeight - originY; ++y) {
int copyFrom = (int) (y * scale);
int copyFrom = (int) Math.floor(y * scale);
session.setBlock(BlockVector3.at(xr, originY + y, zr), session.getBlock(BlockVector3.at(xr, originY + copyFrom, zr)));
++blocksChanged;
}

View File

@ -120,7 +120,7 @@ public int[] filter(int[] inData, int width, int height) {
z += f * inData[offsetY + offsetX];
}
}
outData[index++] = (int) (z + 0.5);
outData[index++] = (int) Math.floor(z + 0.5);
}
}
return outData;