Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-25 02:20:07 +01:00
Line thickness support
Dieser Commit ist enthalten in:
Ursprung
91c6c69551
Commit
f38b6c484c
@ -3002,11 +3002,12 @@ public class EditSession {
|
||||
* @param pattern The block pattern used to draw the line
|
||||
* @param pos1 One of the points that define the line.
|
||||
* @param pos2 The other point that defines the line.
|
||||
* @param radius The radius of the line.
|
||||
*
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException
|
||||
*/
|
||||
public int drawLine(Pattern pattern, Vector pos1, Vector pos2)
|
||||
public int drawLine(Pattern pattern, Vector pos1, Vector pos2, int radius)
|
||||
throws MaxChangedBlocksException {
|
||||
|
||||
int affected = 0;
|
||||
@ -3018,7 +3019,19 @@ public class EditSession {
|
||||
int dx = Math.abs(x2 - x1), dy = Math.abs(y2 - y1), dz = Math.abs(z2 - z1);
|
||||
|
||||
if (dx + dy + dz == 0) {
|
||||
return setBlock(new Vector(tipx, tipy, tipz), pattern) ? 1 : 0;
|
||||
for (int loopx = tipx - radius; loopx <= tipx + radius; loopx++) {
|
||||
for (int loopy = tipy - radius; loopy <= tipy + radius; loopy++) {
|
||||
for (int loopz = tipz - radius; loopz <= tipz + radius; loopz++) {
|
||||
if (Math.sqrt(Math.pow(loopx - tipx, 2) + Math.pow(loopy - tipy, 2) + Math.pow(loopz - tipz, 2)) <= radius) {
|
||||
if (setBlock(new Vector(loopx, loopy, loopz), pattern)) {
|
||||
affected++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return affected;
|
||||
}
|
||||
|
||||
if (Math.max(Math.max(dx, dy), dz) == dx && notdrawn) {
|
||||
@ -3027,8 +3040,16 @@ public class EditSession {
|
||||
tipy = (int) Math.round(y1 + domstep * ((double) dy) / ((double) dx) * (y2 - y1 > 0 ? 1 : -1));
|
||||
tipz = (int) Math.round(z1 + domstep * ((double) dz) / ((double) dx) * (z2 - z1 > 0 ? 1 : -1));
|
||||
|
||||
if (setBlock(new Vector(tipx, tipy, tipz), pattern)) {
|
||||
affected++;
|
||||
for (int loopx = tipx - radius; loopx <= tipx + radius; loopx++) {
|
||||
for (int loopy = tipy - radius; loopy <= tipy + radius; loopy++) {
|
||||
for (int loopz = tipz - radius; loopz <= tipz + radius; loopz++) {
|
||||
if (Math.sqrt(Math.pow(loopx - tipx, 2) + Math.pow(loopy - tipy, 2) + Math.pow(loopz - tipz, 2)) <= radius) {
|
||||
if (setBlock(new Vector(loopx, loopy, loopz), pattern)) {
|
||||
affected++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
notdrawn = false;
|
||||
@ -3040,8 +3061,16 @@ public class EditSession {
|
||||
tipx = (int) Math.round(x1 + domstep * ((double) dx) / ((double) dy) * (x2 - x1 > 0 ? 1 : -1));
|
||||
tipz = (int) Math.round(z1 + domstep * ((double) dz) / ((double) dy) * (z2 - z1 > 0 ? 1 : -1));
|
||||
|
||||
if (setBlock(new Vector(tipx, tipy, tipz), pattern)) {
|
||||
affected++;
|
||||
for (int loopx = tipx - radius; loopx <= tipx + radius; loopx++) {
|
||||
for (int loopy = tipy - radius; loopy <= tipy + radius; loopy++) {
|
||||
for (int loopz = tipz - radius; loopz <= tipz + radius; loopz++) {
|
||||
if (Math.sqrt(Math.pow(loopx - tipx, 2) + Math.pow(loopy - tipy, 2) + Math.pow(loopz - tipz, 2)) <= radius) {
|
||||
if (setBlock(new Vector(loopx, loopy, loopz), pattern)) {
|
||||
affected++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
notdrawn = false;
|
||||
@ -3053,8 +3082,16 @@ public class EditSession {
|
||||
tipy = (int) Math.round(y1 + domstep * ((double) dy) / ((double) dz) * (y2-y1>0 ? 1 : -1));
|
||||
tipx = (int) Math.round(x1 + domstep * ((double) dx) / ((double) dz) * (x2-x1>0 ? 1 : -1));
|
||||
|
||||
if (setBlock(new Vector(tipx, tipy, tipz), pattern)) {
|
||||
affected++;
|
||||
for (int loopx = tipx - radius; loopx <= tipx + radius; loopx++) {
|
||||
for (int loopy = tipy - radius; loopy <= tipy + radius; loopy++) {
|
||||
for (int loopz = tipz - radius; loopz <= tipz + radius; loopz++) {
|
||||
if (Math.sqrt(Math.pow(loopx - tipx, 2) + Math.pow(loopy - tipy, 2) + Math.pow(loopz - tipz, 2)) <= radius) {
|
||||
if (setBlock(new Vector(loopx, loopy, loopz), pattern)) {
|
||||
affected++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
notdrawn = false;
|
||||
|
@ -88,10 +88,10 @@ public class RegionCommands {
|
||||
|
||||
@Command(
|
||||
aliases = { "/line" },
|
||||
usage = "<block>",
|
||||
usage = "<block> [thickness]",
|
||||
desc = "Draw a line segment between selection corners.",
|
||||
min = 1,
|
||||
max = 1
|
||||
max = 2
|
||||
)
|
||||
@CommandPermissions("worldedit.region.line")
|
||||
@Logging(REGION)
|
||||
@ -103,11 +103,15 @@ public class RegionCommands {
|
||||
player.printError("Invalid region type");
|
||||
return;
|
||||
}
|
||||
if (args.argsLength() < 2 ? false : args.getInteger(1) < 0) {
|
||||
player.printError("Invalid thickness. Must be greater than -1");
|
||||
return;
|
||||
}
|
||||
|
||||
Pattern pattern = we.getBlockPattern(player, args.getString(0));
|
||||
Vector pos1 = ((CuboidRegion) region).getPos1();
|
||||
Vector pos2 = ((CuboidRegion) region).getPos2();
|
||||
int blocksChanged = editSession.drawLine(pattern, pos1, pos2);
|
||||
int blocksChanged = editSession.drawLine(pattern, pos1, pos2, args.argsLength() < 2 ? 0 : args.getInteger(1));
|
||||
|
||||
player.print(blocksChanged + " block(s) have been changed.");
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren