Added a new utility method to BukkitUtil to do the common task of shifting coordinates for an entity to the center of a block.

This commit is contained in:
hash 2011-06-15 20:01:03 -05:00
parent 4aaa127efe
commit 1784b29f02

View File

@ -71,6 +71,17 @@ public class BukkitUtil {
return new Location(world, pt.getX(), pt.getY(), pt.getZ()); return new Location(world, pt.getX(), pt.getY(), pt.getZ());
} }
public static Location center(Location loc) {
return new Location(
loc.getWorld(),
loc.getBlockX()+0.5,
loc.getBlockY()+0.5,
loc.getBlockZ()+0.5,
loc.getPitch(),
loc.getYaw()
);
}
public static Player matchSinglePlayer(Server server, String name) { public static Player matchSinglePlayer(Server server, String name) {
List<Player> players = server.matchPlayer(name); List<Player> players = server.matchPlayer(name);
if (players.size() == 0) { if (players.size() == 0) {