mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +00:00
Fixed floating point inaccuracy error with getBlock#(), fixed //rotate.
This commit is contained in:
parent
383a475237
commit
aa63f886ec
@ -118,20 +118,20 @@ public class CuboidClipboard {
|
||||
int width = getWidth();
|
||||
int length = getLength();
|
||||
int height = getHeight();
|
||||
int newWidth = angle % 180 == 0 ? width : length;
|
||||
int newLength = angle % 180 == 0 ? length : width;
|
||||
Vector sizeRotated = size.transform2D(angle, 0, 0, 0, 0);
|
||||
int shiftX = sizeRotated.getX() < 0 ? newWidth - 1 : 0;
|
||||
int shiftZ = sizeRotated.getZ() < 0 ? newLength - 1: 0;
|
||||
int shiftX = sizeRotated.getX() < 0 ? -sizeRotated.getBlockX() - 1 : 0;
|
||||
int shiftZ = sizeRotated.getZ() < 0 ? -sizeRotated.getBlockZ() - 1 : 0;
|
||||
|
||||
BaseBlock newData[][][] = new BaseBlock[newWidth][getHeight()][newLength];
|
||||
BaseBlock newData[][][] = new BaseBlock
|
||||
[Math.abs(sizeRotated.getBlockX())]
|
||||
[Math.abs(sizeRotated.getBlockY())]
|
||||
[Math.abs(sizeRotated.getBlockZ())];
|
||||
|
||||
for (int x = 0; x < width; x++) {
|
||||
for (int z = 0; z < length; z++) {
|
||||
int newX = (new Vector(x, 0, z)).transform2D(angle, 0, 0, 0, 0)
|
||||
.getBlockX();
|
||||
int newZ = (new Vector(x, 0, z)).transform2D(angle, 0, 0, 0, 0)
|
||||
.getBlockZ();
|
||||
Vector v = (new Vector(x, 0, z)).transform2D(angle, 0, 0, 0, 0);
|
||||
int newX = v.getBlockX();
|
||||
int newZ = v.getBlockZ();
|
||||
for (int y = 0; y < height; y++) {
|
||||
newData[shiftX + newX][y][shiftZ + newZ] = data[x][y][z];
|
||||
}
|
||||
@ -139,9 +139,11 @@ public class CuboidClipboard {
|
||||
}
|
||||
|
||||
data = newData;
|
||||
size = new Vector(newWidth, getHeight(), newLength);
|
||||
size = new Vector(Math.abs(sizeRotated.getBlockX()),
|
||||
Math.abs(sizeRotated.getBlockY()),
|
||||
Math.abs(sizeRotated.getBlockZ()));
|
||||
offset = offset.transform2D(angle, 0, 0, 0, 0)
|
||||
.subtract(shiftX, 0, shiftZ);
|
||||
.subtract(shiftX, 0, shiftZ);;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -96,7 +96,7 @@ public class Vector {
|
||||
* @return the x
|
||||
*/
|
||||
public int getBlockX() {
|
||||
return (int)x;
|
||||
return (int)Math.round(x);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -110,7 +110,7 @@ public class Vector {
|
||||
* @return the y
|
||||
*/
|
||||
public int getBlockY() {
|
||||
return (int)y;
|
||||
return (int)Math.round(y);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -124,7 +124,7 @@ public class Vector {
|
||||
* @return the z
|
||||
*/
|
||||
public int getBlockZ() {
|
||||
return (int)z;
|
||||
return (int)Math.round(z);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user