Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-25 02:20:07 +01:00
Fixed floating point inaccuracy error with getBlock#(), fixed //rotate.
Dieser Commit ist enthalten in:
Ursprung
383a475237
Commit
aa63f886ec
@ -118,20 +118,20 @@ public class CuboidClipboard {
|
|||||||
int width = getWidth();
|
int width = getWidth();
|
||||||
int length = getLength();
|
int length = getLength();
|
||||||
int height = getHeight();
|
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);
|
Vector sizeRotated = size.transform2D(angle, 0, 0, 0, 0);
|
||||||
int shiftX = sizeRotated.getX() < 0 ? newWidth - 1 : 0;
|
int shiftX = sizeRotated.getX() < 0 ? -sizeRotated.getBlockX() - 1 : 0;
|
||||||
int shiftZ = sizeRotated.getZ() < 0 ? newLength - 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 x = 0; x < width; x++) {
|
||||||
for (int z = 0; z < length; z++) {
|
for (int z = 0; z < length; z++) {
|
||||||
int newX = (new Vector(x, 0, z)).transform2D(angle, 0, 0, 0, 0)
|
Vector v = (new Vector(x, 0, z)).transform2D(angle, 0, 0, 0, 0);
|
||||||
.getBlockX();
|
int newX = v.getBlockX();
|
||||||
int newZ = (new Vector(x, 0, z)).transform2D(angle, 0, 0, 0, 0)
|
int newZ = v.getBlockZ();
|
||||||
.getBlockZ();
|
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; y++) {
|
||||||
newData[shiftX + newX][y][shiftZ + newZ] = data[x][y][z];
|
newData[shiftX + newX][y][shiftZ + newZ] = data[x][y][z];
|
||||||
}
|
}
|
||||||
@ -139,9 +139,11 @@ public class CuboidClipboard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
data = newData;
|
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)
|
offset = offset.transform2D(angle, 0, 0, 0, 0)
|
||||||
.subtract(shiftX, 0, shiftZ);
|
.subtract(shiftX, 0, shiftZ);;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -188,7 +190,7 @@ public class CuboidClipboard {
|
|||||||
for (int z = 0; z < size.getBlockZ(); z++) {
|
for (int z = 0; z < size.getBlockZ(); z++) {
|
||||||
if (noAir && data[x][y][z].isAir())
|
if (noAir && data[x][y][z].isAir())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
editSession.setBlock(new Vector(x, y, z).add(pos),
|
editSession.setBlock(new Vector(x, y, z).add(pos),
|
||||||
data[x][y][z]);
|
data[x][y][z]);
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ public class Vector {
|
|||||||
* @return the x
|
* @return the x
|
||||||
*/
|
*/
|
||||||
public int getBlockX() {
|
public int getBlockX() {
|
||||||
return (int)x;
|
return (int)Math.round(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -110,7 +110,7 @@ public class Vector {
|
|||||||
* @return the y
|
* @return the y
|
||||||
*/
|
*/
|
||||||
public int getBlockY() {
|
public int getBlockY() {
|
||||||
return (int)y;
|
return (int)Math.round(y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -124,7 +124,7 @@ public class Vector {
|
|||||||
* @return the z
|
* @return the z
|
||||||
*/
|
*/
|
||||||
public int getBlockZ() {
|
public int getBlockZ() {
|
||||||
return (int)z;
|
return (int)Math.round(z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren