mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-11-04 20:06:06 +00:00
Use Math.floor instead of int cast 757bef1f7d2b16317ab3d18427ad22183344e28d
This commit is contained in:
parent
c28a5ee66e
commit
5d4a2a4a0d
@ -105,7 +105,7 @@ public class HeightMapFilter {
|
||||
|
||||
for (int y = 0; y < height; ++y) {
|
||||
for (int x = 0; x < width; ++x) {
|
||||
outData[index++] = (int) calculateHeight(inDataFloat, width, height, offset, matrix, x, y);
|
||||
outData[index++] = (int) Math.floor(calculateHeight(inDataFloat, width, height, offset, matrix, x, y));
|
||||
}
|
||||
}
|
||||
return outData;
|
||||
|
@ -178,13 +178,13 @@ public class SnowHeightMap {
|
||||
++blocksChanged;
|
||||
|
||||
// Grow -- start from 1 below top replacing airblocks
|
||||
for (int y = (int) newHeight - 1 - originY; y >= 0; --y) {
|
||||
if (y >= newHeight - 1 - originY - layerBlocks) {
|
||||
for (int y = (int) Math.floor(newHeight - 1 - originY); y >= 0; --y) {
|
||||
if (y >= Math.floor(newHeight - 1 - originY - layerBlocks)) {
|
||||
//FAWE start - avoid BlockVector3 creation for no reason
|
||||
session.setBlock(xr, originY + y, zr, fillerSnow);
|
||||
//FAWE end
|
||||
} else {
|
||||
int copyFrom = (int) (y * scale);
|
||||
int copyFrom = (int) Math.floor(y * scale);
|
||||
//FAWE start - avoid BlockVector3 creation for no reason
|
||||
BlockState block = session.getBlock(xr, originY + copyFrom, zr);
|
||||
session.setBlock(xr, originY + y, zr, block);
|
||||
@ -195,13 +195,13 @@ public class SnowHeightMap {
|
||||
}
|
||||
} else {
|
||||
// Shrink -- start from bottom
|
||||
for (int y = 0; y < (int) newHeight - originY; ++y) {
|
||||
if (y >= (int) newHeight - originY - layerBlocks) {
|
||||
for (int y = 0; y < (int) Math.floor(newHeight - originY); ++y) {
|
||||
if (y >= (int) Math.floor(newHeight - originY - layerBlocks)) {
|
||||
//FAWE start - avoid BlockVector3 creation for no reason
|
||||
session.setBlock(xr, originY + y, zr, fillerSnow);
|
||||
//FAWE end
|
||||
} else {
|
||||
int copyFrom = (int) (y * scale);
|
||||
int copyFrom = (int) Math.floor(y * scale);
|
||||
//FAWE start - avoid BlockVector3 creation for no reason
|
||||
BlockState block = session.getBlock(xr, originY + copyFrom, zr);
|
||||
session.setBlock(xr, originY + y, zr, block);
|
||||
@ -214,7 +214,7 @@ public class SnowHeightMap {
|
||||
++blocksChanged;
|
||||
|
||||
// Fill rest with air
|
||||
for (int y = (int) newHeight + 1; y <= curHeight; ++y) {
|
||||
for (int y = (int) Math.floor(newHeight + 1); y <= Math.floor(curHeight); ++y) {
|
||||
//FAWE start - avoid BlockVector3 creation for no reason
|
||||
session.setBlock(xr, y, zr, fillerAir);
|
||||
//FAWE end
|
||||
@ -229,7 +229,8 @@ public class SnowHeightMap {
|
||||
}
|
||||
|
||||
private void setSnowLayer(int x, int z, float newHeight) throws MaxChangedBlocksException {
|
||||
int numOfLayers = (int) ((newHeight % 1) * 8) + 1;
|
||||
int y = (int) Math.floor(newHeight);
|
||||
int numOfLayers = (int) ((newHeight - y) * 8) + 1;
|
||||
//FAWE start - avoid BlockVector3 creation for no reason
|
||||
session.setBlock(x, (int) newHeight, z, BlockTypes.SNOW.getDefaultState().with(LAYERS, numOfLayers));
|
||||
//FAWE end
|
||||
|
Loading…
Reference in New Issue
Block a user