mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-11-20 02:45:00 +00:00
Line thickness support
This commit is contained in:
parent
91c6c69551
commit
f38b6c484c
@ -3002,11 +3002,12 @@ public class EditSession {
|
|||||||
* @param pattern The block pattern used to draw the line
|
* @param pattern The block pattern used to draw the line
|
||||||
* @param pos1 One of the points that define the line.
|
* @param pos1 One of the points that define the line.
|
||||||
* @param pos2 The other point that defines the line.
|
* @param pos2 The other point that defines the line.
|
||||||
|
* @param radius The radius of the line.
|
||||||
*
|
*
|
||||||
* @return number of blocks affected
|
* @return number of blocks affected
|
||||||
* @throws MaxChangedBlocksException
|
* @throws MaxChangedBlocksException
|
||||||
*/
|
*/
|
||||||
public int drawLine(Pattern pattern, Vector pos1, Vector pos2)
|
public int drawLine(Pattern pattern, Vector pos1, Vector pos2, int radius)
|
||||||
throws MaxChangedBlocksException {
|
throws MaxChangedBlocksException {
|
||||||
|
|
||||||
int affected = 0;
|
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);
|
int dx = Math.abs(x2 - x1), dy = Math.abs(y2 - y1), dz = Math.abs(z2 - z1);
|
||||||
|
|
||||||
if (dx + dy + dz == 0) {
|
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) {
|
if (Math.max(Math.max(dx, dy), dz) == dx && notdrawn) {
|
||||||
@ -3027,10 +3040,18 @@ public class EditSession {
|
|||||||
tipy = (int) Math.round(y1 + domstep * ((double) dy) / ((double) dx) * (y2 - y1 > 0 ? 1 : -1));
|
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));
|
tipz = (int) Math.round(z1 + domstep * ((double) dz) / ((double) dx) * (z2 - z1 > 0 ? 1 : -1));
|
||||||
|
|
||||||
if (setBlock(new Vector(tipx, tipy, tipz), pattern)) {
|
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++;
|
affected++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
notdrawn = false;
|
notdrawn = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3040,10 +3061,18 @@ public class EditSession {
|
|||||||
tipx = (int) Math.round(x1 + domstep * ((double) dx) / ((double) dy) * (x2 - x1 > 0 ? 1 : -1));
|
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));
|
tipz = (int) Math.round(z1 + domstep * ((double) dz) / ((double) dy) * (z2 - z1 > 0 ? 1 : -1));
|
||||||
|
|
||||||
if (setBlock(new Vector(tipx, tipy, tipz), pattern)) {
|
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++;
|
affected++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
notdrawn = false;
|
notdrawn = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3053,10 +3082,18 @@ public class EditSession {
|
|||||||
tipy = (int) Math.round(y1 + domstep * ((double) dy) / ((double) dz) * (y2-y1>0 ? 1 : -1));
|
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));
|
tipx = (int) Math.round(x1 + domstep * ((double) dx) / ((double) dz) * (x2-x1>0 ? 1 : -1));
|
||||||
|
|
||||||
if (setBlock(new Vector(tipx, tipy, tipz), pattern)) {
|
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++;
|
affected++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
notdrawn = false;
|
notdrawn = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,10 +88,10 @@ public class RegionCommands {
|
|||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "/line" },
|
aliases = { "/line" },
|
||||||
usage = "<block>",
|
usage = "<block> [thickness]",
|
||||||
desc = "Draw a line segment between selection corners.",
|
desc = "Draw a line segment between selection corners.",
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 1
|
max = 2
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.region.line")
|
@CommandPermissions("worldedit.region.line")
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
@ -103,11 +103,15 @@ public class RegionCommands {
|
|||||||
player.printError("Invalid region type");
|
player.printError("Invalid region type");
|
||||||
return;
|
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));
|
Pattern pattern = we.getBlockPattern(player, args.getString(0));
|
||||||
Vector pos1 = ((CuboidRegion) region).getPos1();
|
Vector pos1 = ((CuboidRegion) region).getPos1();
|
||||||
Vector pos2 = ((CuboidRegion) region).getPos2();
|
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.");
|
player.print(blocksChanged + " block(s) have been changed.");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user