Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-12 22:20:08 +01:00
Removed -q flag from //[h]sphere and the code to back it.
The speed difference between the "flexible" and the "quick" variant is so minor that it doesn't justify the aditional code complexity.
Dieser Commit ist enthalten in:
Ursprung
d9b86025d3
Commit
318e81886c
@ -1976,74 +1976,6 @@ public class EditSession {
|
||||
return affected;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a sphere or ellipsoid.
|
||||
*
|
||||
* @param pos Center of the sphere or ellipsoid
|
||||
* @param block The block pattern to use
|
||||
* @param radiusX The sphere/ellipsoid's largest north/south extent
|
||||
* @param radiusY The sphere/ellipsoid's largest up/down extent
|
||||
* @param radiusZ The sphere/ellipsoid's largest east/west extent
|
||||
* @param filled If false, only a shell will be generated.
|
||||
* @return number of blocks changed
|
||||
* @throws MaxChangedBlocksException
|
||||
*/
|
||||
public int makeSphere(Vector pos, Pattern block, double radius, boolean filled) throws MaxChangedBlocksException {
|
||||
int affected = 0;
|
||||
|
||||
radius += 0.5;
|
||||
final double radiusSq = radius*radius;
|
||||
final double radius1Sq = (radius - 1)*(radius - 1);
|
||||
|
||||
final int ceilRadius = (int) Math.ceil(radius);
|
||||
for (int x = 0; x <= ceilRadius; ++x) {
|
||||
for (int y = 0; y <= ceilRadius; ++y) {
|
||||
for (int z = 0; z <= ceilRadius; ++z) {
|
||||
double dSq = lengthSq(x, y, z);
|
||||
|
||||
if (dSq > radiusSq) {
|
||||
continue;
|
||||
}
|
||||
if (!filled) {
|
||||
if (dSq < radius1Sq
|
||||
|| (lengthSq(x + 1, y, z) <= radiusSq
|
||||
&& lengthSq(x, y + 1, z) <= radiusSq
|
||||
&& lengthSq(x, y, z + 1) <= radiusSq)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (setBlock(pos.add(x, y, z), block)) {
|
||||
++affected;
|
||||
}
|
||||
if (setBlock(pos.add(-x, y, z), block)) {
|
||||
++affected;
|
||||
}
|
||||
if (setBlock(pos.add(x, -y, z), block)) {
|
||||
++affected;
|
||||
}
|
||||
if (setBlock(pos.add(x, y, -z), block)) {
|
||||
++affected;
|
||||
}
|
||||
if (setBlock(pos.add(-x, -y, z), block)) {
|
||||
++affected;
|
||||
}
|
||||
if (setBlock(pos.add(x, -y, -z), block)) {
|
||||
++affected;
|
||||
}
|
||||
if (setBlock(pos.add(-x, y, -z), block)) {
|
||||
++affected;
|
||||
}
|
||||
if (setBlock(pos.add(-x, -y, -z), block)) {
|
||||
++affected;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return affected;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a sphere or ellipsoid.
|
||||
*
|
||||
|
@ -85,7 +85,6 @@ public class GenerationCommands {
|
||||
aliases = { "/hsphere" },
|
||||
usage = "<block> <radius>[,<radius>,<radius>] [raised?]",
|
||||
desc = "Generate a hollow sphere.",
|
||||
flags = "q",
|
||||
min = 2,
|
||||
max = 3
|
||||
)
|
||||
@ -95,29 +94,6 @@ public class GenerationCommands {
|
||||
LocalSession session, LocalPlayer player, EditSession editSession)
|
||||
throws WorldEditException {
|
||||
|
||||
if (args.hasFlag('q')) {
|
||||
Pattern block = we.getBlockPattern(player, args.getString(0));
|
||||
String[] radiuses = args.getString(1).split(",");
|
||||
if (radiuses.length > 1) {
|
||||
throw new InsufficientArgumentsException("Cannot specify q flag and multiple radiuses.");
|
||||
}
|
||||
double radius = Double.parseDouble(radiuses[0]);
|
||||
boolean raised = args.argsLength() > 2
|
||||
? (args.getString(2).equalsIgnoreCase("true")
|
||||
|| args.getString(2).equalsIgnoreCase("yes"))
|
||||
: false;
|
||||
|
||||
Vector pos = session.getPlacementPosition(player);
|
||||
if (raised) {
|
||||
pos = pos.add(0, radius, 0);
|
||||
}
|
||||
|
||||
int affected = editSession.makeSphere(pos, block, radius, false);
|
||||
player.findFreePosition();
|
||||
player.print(affected + " block(s) have been created.");
|
||||
return;
|
||||
}
|
||||
|
||||
final Pattern block = we.getBlockPattern(player, args.getString(0));
|
||||
String[] radiuses = args.getString(1).split(",");
|
||||
final double radiusX, radiusY, radiusZ;
|
||||
@ -157,7 +133,6 @@ public class GenerationCommands {
|
||||
aliases = { "/sphere" },
|
||||
usage = "<block> <radius>[,<radius>,<radius>] [raised?]",
|
||||
desc = "Generate a filled sphere.",
|
||||
flags = "q",
|
||||
min = 2,
|
||||
max = 3
|
||||
)
|
||||
@ -167,29 +142,6 @@ public class GenerationCommands {
|
||||
LocalSession session, LocalPlayer player, EditSession editSession)
|
||||
throws WorldEditException {
|
||||
|
||||
if (args.hasFlag('q')) {
|
||||
Pattern block = we.getBlockPattern(player, args.getString(0));
|
||||
String[] radiuses = args.getString(1).split(",");
|
||||
if (radiuses.length > 1) {
|
||||
throw new InsufficientArgumentsException("Cannot specify q flag and multiple radiuses.");
|
||||
}
|
||||
double radius = Double.parseDouble(radiuses[0]);
|
||||
boolean raised = args.argsLength() > 2
|
||||
? (args.getString(2).equalsIgnoreCase("true")
|
||||
|| args.getString(2).equalsIgnoreCase("yes"))
|
||||
: false;
|
||||
|
||||
Vector pos = session.getPlacementPosition(player);
|
||||
if (raised) {
|
||||
pos = pos.add(0, radius, 0);
|
||||
}
|
||||
|
||||
int affected = editSession.makeSphere(pos, block, radius, true);
|
||||
player.findFreePosition();
|
||||
player.print(affected + " block(s) have been created.");
|
||||
return;
|
||||
}
|
||||
|
||||
Pattern block = we.getBlockPattern(player, args.getString(0));
|
||||
String[] radiuses = args.getString(1).split(",");
|
||||
final double radiusX, radiusY, radiusZ;
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren