summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2011-12-04 22:01:50 +0100
committersnowleo <schneeleo@gmail.com>2011-12-04 22:01:50 +0100
commit308f0506dc11c8cec10a02df051d0ea74d6c7f97 (patch)
tree22a0d62989240d962cbff75946a9f50d065cc01a
parente37c9d47abfdb38ef87bcc49bb5e0288a71039b6 (diff)
downloadEssentials-308f0506dc11c8cec10a02df051d0ea74d6c7f97.tar
Essentials-308f0506dc11c8cec10a02df051d0ea74d6c7f97.tar.gz
Essentials-308f0506dc11c8cec10a02df051d0ea74d6c7f97.tar.lz
Essentials-308f0506dc11c8cec10a02df051d0ea74d6c7f97.tar.xz
Essentials-308f0506dc11c8cec10a02df051d0ea74d6c7f97.zip
Less use of sqrt
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandbutcher.java5
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandremove.java7
2 files changed, 9 insertions, 3 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbutcher.java b/Essentials/src/com/earth2me/essentials/commands/Commandbutcher.java
index e127e197b..b5f43e2d9 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandbutcher.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandbutcher.java
@@ -78,6 +78,9 @@ public class Commandbutcher extends EssentialsCommand
world = ess.getWorld(args[1]);
}
}
+ if (radius >=0) {
+ radius *= radius;
+ }
String killType = type.toLowerCase();
int numKills = 0;
for (Chunk chunk : world.getLoadedChunks())
@@ -86,7 +89,7 @@ public class Commandbutcher extends EssentialsCommand
{
if (sender instanceof Player)
{
- if (((Player)sender).getLocation().distance(entity.getLocation()) > radius && radius >= 0)
+ if (((Player)sender).getLocation().distanceSquared(entity.getLocation()) > radius && radius >= 0)
{
continue;
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandremove.java b/Essentials/src/com/earth2me/essentials/commands/Commandremove.java
index 33b37ac39..d245d1239 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandremove.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandremove.java
@@ -89,16 +89,19 @@ public class Commandremove extends EssentialsCommand
removeEntities(sender, world, toRemove, 0);
}
- protected void removeEntities(final CommandSender sender, final World world, final ToRemove toRemove, final int radius) throws Exception
+ protected void removeEntities(final CommandSender sender, final World world, final ToRemove toRemove, int radius) throws Exception
{
int removed = 0;
+ if (radius > 0) {
+ radius*=radius;
+ }
for (Chunk chunk : world.getLoadedChunks())
{
for (Entity e : chunk.getEntities())
{
if (radius > 0)
{
- if (((Player)sender).getLocation().distance(e.getLocation()) > radius)
+ if (((Player)sender).getLocation().distanceSquared(e.getLocation()) > radius)
{
continue;
}