geforkt von Mirrors/FastAsyncWorldEdit
Fixed minor issues, moved some classes.
Dieser Commit ist enthalten in:
Ursprung
2bb9a9390f
Commit
af1acd42b8
@ -28,20 +28,6 @@ import com.sk89q.worldedit.util.TargetBlock;
|
|||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public abstract class LocalPlayer {
|
public abstract class LocalPlayer {
|
||||||
/**
|
|
||||||
* Directions.
|
|
||||||
*/
|
|
||||||
public enum DIRECTION {
|
|
||||||
NORTH,
|
|
||||||
NORTH_EAST,
|
|
||||||
EAST,
|
|
||||||
SOUTH_EAST,
|
|
||||||
SOUTH,
|
|
||||||
SOUTH_WEST,
|
|
||||||
WEST,
|
|
||||||
NORTH_WEST
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Server.
|
* Server.
|
||||||
*/
|
*/
|
||||||
@ -320,7 +306,7 @@ public abstract class LocalPlayer {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public LocalPlayer.DIRECTION getCardinalDirection() {
|
public PlayerDirection getCardinalDirection() {
|
||||||
// From hey0's code
|
// From hey0's code
|
||||||
double rot = (getYaw() - 90) % 360;
|
double rot = (getYaw() - 90) % 360;
|
||||||
if (rot < 0) {
|
if (rot < 0) {
|
||||||
@ -335,25 +321,25 @@ public abstract class LocalPlayer {
|
|||||||
* @param rot
|
* @param rot
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private static LocalPlayer.DIRECTION getDirection(double rot) {
|
private static PlayerDirection getDirection(double rot) {
|
||||||
if (0 <= rot && rot < 22.5) {
|
if (0 <= rot && rot < 22.5) {
|
||||||
return LocalPlayer.DIRECTION.NORTH;
|
return PlayerDirection.NORTH;
|
||||||
} else if (22.5 <= rot && rot < 67.5) {
|
} else if (22.5 <= rot && rot < 67.5) {
|
||||||
return LocalPlayer.DIRECTION.NORTH_EAST;
|
return PlayerDirection.NORTH_EAST;
|
||||||
} else if (67.5 <= rot && rot < 112.5) {
|
} else if (67.5 <= rot && rot < 112.5) {
|
||||||
return LocalPlayer.DIRECTION.EAST;
|
return PlayerDirection.EAST;
|
||||||
} else if (112.5 <= rot && rot < 157.5) {
|
} else if (112.5 <= rot && rot < 157.5) {
|
||||||
return LocalPlayer.DIRECTION.SOUTH_EAST;
|
return PlayerDirection.SOUTH_EAST;
|
||||||
} else if (157.5 <= rot && rot < 202.5) {
|
} else if (157.5 <= rot && rot < 202.5) {
|
||||||
return LocalPlayer.DIRECTION.SOUTH;
|
return PlayerDirection.SOUTH;
|
||||||
} else if (202.5 <= rot && rot < 247.5) {
|
} else if (202.5 <= rot && rot < 247.5) {
|
||||||
return LocalPlayer.DIRECTION.SOUTH_WEST;
|
return PlayerDirection.SOUTH_WEST;
|
||||||
} else if (247.5 <= rot && rot < 292.5) {
|
} else if (247.5 <= rot && rot < 292.5) {
|
||||||
return LocalPlayer.DIRECTION.WEST;
|
return PlayerDirection.WEST;
|
||||||
} else if (292.5 <= rot && rot < 337.5) {
|
} else if (292.5 <= rot && rot < 337.5) {
|
||||||
return LocalPlayer.DIRECTION.NORTH_WEST;
|
return PlayerDirection.NORTH_WEST;
|
||||||
} else if (337.5 <= rot && rot < 360.0) {
|
} else if (337.5 <= rot && rot < 360.0) {
|
||||||
return LocalPlayer.DIRECTION.NORTH;
|
return PlayerDirection.NORTH;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
56
src/com/sk89q/worldedit/PlayerDirection.java
Normale Datei
56
src/com/sk89q/worldedit/PlayerDirection.java
Normale Datei
@ -0,0 +1,56 @@
|
|||||||
|
// $Id$
|
||||||
|
/*
|
||||||
|
* WorldEdit
|
||||||
|
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sk89q.worldedit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Direction.
|
||||||
|
*/
|
||||||
|
public enum PlayerDirection {
|
||||||
|
NORTH(new Vector(-1, 0, 0), new Vector(0, 0, 1), true),
|
||||||
|
NORTH_EAST((new Vector(-1, 0, -1)).normalize(), (new Vector(-1, 0, 1)).normalize(), false),
|
||||||
|
EAST(new Vector(0, 0, -1), new Vector(-1, 0, 0), true),
|
||||||
|
SOUTH_EAST((new Vector(1, 0, -1)).normalize(), (new Vector(-1, 0, -1)).normalize(), false),
|
||||||
|
SOUTH(new Vector(1, 0, 0), new Vector(0, 0, -1), true),
|
||||||
|
SOUTH_WEST((new Vector(1, 0, 1)).normalize(), (new Vector(1, 0, -1)).normalize(), false),
|
||||||
|
WEST(new Vector(0, 0, 1), new Vector(1, 0, 0), true),
|
||||||
|
NORTH_WEST((new Vector(-1, 0, 1)).normalize(), (new Vector(1, 0, 1)).normalize(), false);
|
||||||
|
|
||||||
|
private Vector dir;
|
||||||
|
private Vector leftDir;
|
||||||
|
private boolean isOrthogonal;
|
||||||
|
|
||||||
|
PlayerDirection(Vector vec, Vector leftDir, boolean isOrthogonal) {
|
||||||
|
this.dir = vec;
|
||||||
|
this.leftDir = leftDir;
|
||||||
|
this.isOrthogonal = isOrthogonal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector vector() {
|
||||||
|
return dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector leftVector() {
|
||||||
|
return leftDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isOrthogonal() {
|
||||||
|
return isOrthogonal;
|
||||||
|
}
|
||||||
|
}
|
@ -434,6 +434,18 @@ public class Vector {
|
|||||||
return new Vector(x / n, y / n, z / n);
|
return new Vector(x / n, y / n, z / n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the length of the vector.
|
||||||
|
*
|
||||||
|
* @param pt
|
||||||
|
* @return distance
|
||||||
|
*/
|
||||||
|
public double length() {
|
||||||
|
return Math.sqrt(Math.pow(x, 2) +
|
||||||
|
Math.pow(y, 2) +
|
||||||
|
Math.pow(z, 2));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the distance away from a point.
|
* Get the distance away from a point.
|
||||||
*
|
*
|
||||||
@ -458,6 +470,16 @@ public class Vector {
|
|||||||
Math.pow(pt.z - z, 2);
|
Math.pow(pt.z - z, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the normalized vector.
|
||||||
|
*
|
||||||
|
* @param pt
|
||||||
|
* @return vector
|
||||||
|
*/
|
||||||
|
public Vector normalize() {
|
||||||
|
return divide(length());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks to see if a vector is contained with another.
|
* Checks to see if a vector is contained with another.
|
||||||
*
|
*
|
||||||
|
@ -1747,7 +1747,7 @@ public class WorldEditController {
|
|||||||
int ym = 0;
|
int ym = 0;
|
||||||
int zm = 0;
|
int zm = 0;
|
||||||
|
|
||||||
LocalPlayer.DIRECTION dir = null;
|
PlayerDirection dir = null;
|
||||||
|
|
||||||
dirStr = dirStr.toLowerCase();
|
dirStr = dirStr.toLowerCase();
|
||||||
boolean wasDetected = false;
|
boolean wasDetected = false;
|
||||||
@ -1757,13 +1757,13 @@ public class WorldEditController {
|
|||||||
wasDetected = true;
|
wasDetected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dirStr.charAt(0) == 'w' || dir == LocalPlayer.DIRECTION.WEST) {
|
if (dirStr.charAt(0) == 'w' || dir == PlayerDirection.WEST) {
|
||||||
zm += 1;
|
zm += 1;
|
||||||
} else if (dirStr.charAt(0) == 'e' || dir == LocalPlayer.DIRECTION.EAST) {
|
} else if (dirStr.charAt(0) == 'e' || dir == PlayerDirection.EAST) {
|
||||||
zm -= 1;
|
zm -= 1;
|
||||||
} else if (dirStr.charAt(0) == 's' || dir == LocalPlayer.DIRECTION.SOUTH) {
|
} else if (dirStr.charAt(0) == 's' || dir == PlayerDirection.SOUTH) {
|
||||||
xm += 1;
|
xm += 1;
|
||||||
} else if (dirStr.charAt(0) == 'n' || dir == LocalPlayer.DIRECTION.NORTH) {
|
} else if (dirStr.charAt(0) == 'n' || dir == PlayerDirection.NORTH) {
|
||||||
xm -= 1;
|
xm -= 1;
|
||||||
} else if (dirStr.charAt(0) == 'u') {
|
} else if (dirStr.charAt(0) == 'u') {
|
||||||
ym += 1;
|
ym += 1;
|
||||||
@ -1791,19 +1791,19 @@ public class WorldEditController {
|
|||||||
public CuboidClipboard.FlipDirection getFlipDirection(
|
public CuboidClipboard.FlipDirection getFlipDirection(
|
||||||
LocalPlayer player, String dirStr)
|
LocalPlayer player, String dirStr)
|
||||||
throws UnknownDirectionException {
|
throws UnknownDirectionException {
|
||||||
LocalPlayer.DIRECTION dir = null;
|
PlayerDirection dir = null;
|
||||||
|
|
||||||
if (dirStr.equals("me")) {
|
if (dirStr.equals("me")) {
|
||||||
dir = player.getCardinalDirection();
|
dir = player.getCardinalDirection();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dirStr.charAt(0) == 'w' || dir == LocalPlayer.DIRECTION.EAST) {
|
if (dirStr.charAt(0) == 'w' || dir == PlayerDirection.EAST) {
|
||||||
return CuboidClipboard.FlipDirection.WEST_EAST;
|
return CuboidClipboard.FlipDirection.WEST_EAST;
|
||||||
} else if (dirStr.charAt(0) == 'e' || dir == LocalPlayer.DIRECTION.EAST) {
|
} else if (dirStr.charAt(0) == 'e' || dir == PlayerDirection.EAST) {
|
||||||
return CuboidClipboard.FlipDirection.WEST_EAST;
|
return CuboidClipboard.FlipDirection.WEST_EAST;
|
||||||
} else if (dirStr.charAt(0) == 's' || dir == LocalPlayer.DIRECTION.SOUTH) {
|
} else if (dirStr.charAt(0) == 's' || dir == PlayerDirection.SOUTH) {
|
||||||
return CuboidClipboard.FlipDirection.NORTH_SOUTH;
|
return CuboidClipboard.FlipDirection.NORTH_SOUTH;
|
||||||
} else if (dirStr.charAt(0) == 'n' || dir == LocalPlayer.DIRECTION.SOUTH) {
|
} else if (dirStr.charAt(0) == 'n' || dir == PlayerDirection.SOUTH) {
|
||||||
return CuboidClipboard.FlipDirection.NORTH_SOUTH;
|
return CuboidClipboard.FlipDirection.NORTH_SOUTH;
|
||||||
} else if (dirStr.charAt(0) == 'u') {
|
} else if (dirStr.charAt(0) == 'u') {
|
||||||
return CuboidClipboard.FlipDirection.UP_DOWN;
|
return CuboidClipboard.FlipDirection.UP_DOWN;
|
||||||
|
@ -35,7 +35,17 @@ public class NoteBlock extends BaseBlock implements TileEntityBlock {
|
|||||||
private byte note;
|
private byte note;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the sign without text.
|
* Construct the note block.
|
||||||
|
*
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
|
public NoteBlock() {
|
||||||
|
super(25);
|
||||||
|
this.note = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct the note block.
|
||||||
*
|
*
|
||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
@ -45,7 +55,7 @@ public class NoteBlock extends BaseBlock implements TileEntityBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the sign with text.
|
* Construct the note block.
|
||||||
*
|
*
|
||||||
* @param note
|
* @param note
|
||||||
*/
|
*/
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren