Added diagonal stacking

Dieser Commit ist enthalten in:
Valentin Stahlmann 2011-03-21 22:01:15 +08:00 committet von
Ursprung 7109046a82
Commit 789abaada9
2 geänderte Dateien mit 61 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -625,6 +625,66 @@ public class WorldEdit {
return new Vector(xm, ym, zm); return new Vector(xm, ym, zm);
} }
/**
* Get diagonal direction vector for a player's direction. May return
* null if a direction could not be found.
*
* @param player
* @param dirStr
* @return
* @throws UnknownDirectionException
*/
public Vector getDiagonalDirection( LocalPlayer player, String dirStr )
throws UnknownDirectionException {
int xm = 0;
int ym = 0;
int zm = 0;
PlayerDirection dir = null;
dirStr = dirStr.toLowerCase();
boolean wasDetected = false;
if ( dirStr.equals( "me" ) ) {
dir = player.getCardinalDirection();
wasDetected = true;
}
if ((dirStr.charAt(0) == 's' && dirStr.indexOf( 'w' ) > 0) || dir == PlayerDirection.SOUTH_WEST) {
zm += 1;
xm += 1;
} else if ((dirStr.charAt(0) == 'n' && dirStr.indexOf( 'w' ) > 0) || dir == PlayerDirection.NORTH_WEST) {
zm += 1;
xm -= 1;
} else if ((dirStr.charAt(0) == 's' && dirStr.indexOf( 'e' ) > 0) || dir == PlayerDirection.SOUTH_EAST) {
zm -= 1;
xm += 1;
} else if ((dirStr.charAt(0) == 'n' && dirStr.indexOf( 'e' ) > 0) || dir == PlayerDirection.NORTH_EAST) {
zm -= 1;
xm -= 1;
} else if (dirStr.charAt(0) == 'w' || dir == PlayerDirection.WEST) {
zm += 1;
} else if (dirStr.charAt(0) == 'e' || dir == PlayerDirection.EAST) {
zm -= 1;
} else if (dirStr.charAt(0) == 's' || dir == PlayerDirection.SOUTH) {
xm += 1;
} else if (dirStr.charAt(0) == 'n' || dir == PlayerDirection.NORTH) {
xm -= 1;
} else if (dirStr.charAt(0) == 'u') {
ym += 1;
} else if (dirStr.charAt(0) == 'd') {
ym -= 1;
} else {
if (wasDetected) {
throw new UnknownDirectionException(dir.name());
} else {
throw new UnknownDirectionException(dirStr);
}
}
return new Vector( xm, ym, zm );
}
/** /**
* Get the flip direction for a player's direction. May return * Get the flip direction for a player's direction. May return
* null if a direction could not be found. * null if a direction could not be found.

Datei anzeigen

@ -223,7 +223,7 @@ public class RegionCommands {
throws WorldEditException { throws WorldEditException {
int count = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : 1; int count = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : 1;
Vector dir = we.getDirection(player, Vector dir = we.getDiagonalDirection(player,
args.argsLength() > 1 ? args.getString(1).toLowerCase() : "me"); args.argsLength() > 1 ? args.getString(1).toLowerCase() : "me");
int affected = editSession.stackCuboidRegion(session.getSelection(player.getWorld()), int affected = editSession.stackCuboidRegion(session.getSelection(player.getWorld()),