Made /thru work better.

This commit is contained in:
sk89q 2010-10-19 20:33:50 -07:00
parent 9124cdd91f
commit ebf5b97451
2 changed files with 14 additions and 10 deletions

View File

@ -86,26 +86,30 @@ public class SMWorldEditPlayer extends WorldEditPlayer {
* @return whether the player was pass through
*/
public boolean passThroughForwardWall(int range) {
int free = 0;
int spots = 0;
boolean foundNext = false;
int searchDist = 0;
HitBlox hitBlox = new HitBlox(player, range, 0.2);
Block block;
free = hitBlox.getLastBlock().getType() == 0 ? 1 : 0;
while ((block = hitBlox.getNextBlock()) != null) {
searchDist++;
if (searchDist > 20) {
return false;
}
if (block.getType() == 0) {
free++;
if (spots >= 1) {
Vector v = new Vector(block.getX(), block.getY() + 1, block.getZ());
if (foundNext) {
Vector v = new Vector(block.getX(), block.getY() - 1, block.getZ());
if (server.getBlockType(v) == 0) {
setPosition(v.subtract(0, 1, 0));
setPosition(v.add(0.5, 0, 0.5));
return true;
}
}
} else {
free = 0;
spots++;
foundNext = true;
}
}

View File

@ -329,7 +329,7 @@ public class WorldEdit {
// Go through a wall
} else if (split[0].equalsIgnoreCase("/thru")) {
checkArgs(split, 0, 0, split[0]);
if (player.passThroughForwardWall(300)) {
if (player.passThroughForwardWall(6)) {
player.print("Whoosh!");
} else {
player.printError("No free spot ahead of you found.");