本文整理汇总了Java中org.bukkit.Location.getDirection方法的典型用法代码示例。如果您正苦于以下问题:Java Location.getDirection方法的具体用法?Java Location.getDirection怎么用?Java Location.getDirection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.Location
的用法示例。
在下文中一共展示了Location.getDirection方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDirection
import org.bukkit.Location; //导入方法依赖的package包/类
/**
* Get the arrow corresponding to the location between two given players
*
* @param p First player
* @param mate Second player
*
* @return A arrow
*/
protected static String getDirection(Location p, Location mate)
{
Location ploc = p.clone();
Location point = mate.clone();
if (ploc.getWorld().getEnvironment() != point.getWorld().getEnvironment())
return "•";
ploc.setY(0);
point.setY(0);
Vector d = ploc.getDirection();
Vector v = point.subtract(ploc).toVector().normalize();
double a = Math.toDegrees(Math.atan2(d.getX(), d.getZ()));
a -= Math.toDegrees(Math.atan2(v.getX(), v.getZ()));
a = (int) (a + 22.5) % 360;
if (a < 0)
a += 360;
return Character.toString("⬆⬈➡⬊⬇⬋⬅⬉".charAt((int) a / 45));
}
示例2: onRun
import org.bukkit.Location; //导入方法依赖的package包/类
@Override
public void onRun() {
if (font == null) {
cancel();
return;
}
Location location = getLocation();
location.add(0, 1.2, 0);
if(!lockedYaw) {
yaw = -location.getYaw();
dir = location.getDirection();
dir = dir.normalize().setY(0);
lockedYaw = true;
}
location.add(dir);
try {
if (image == null) {
image = StringParser.stringToBufferedImage(font, text);
}
for (int y = 0; y < image.getHeight(); y += stepY) {
for (int x = 0; x < image.getWidth(); x += stepX) {
int clr = image.getRGB(image.getWidth() - 1 - x, y);
if (clr != Color.black.getRGB())
continue;
Vector v = new Vector((float) image.getWidth() / 2 - x, (float) image.getHeight() / 2 - y, 0).multiply(size);
VectorUtils.rotateAroundAxisY(v, yaw * MathUtils.degreesToRadians);
display(particle, location.add(v));
location.subtract(v);
}
}
} catch (Exception ex) {
cancel(true);
}
}
示例3: ChargeForward
import org.bukkit.Location; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private void ChargeForward(Player player, int velocity)
{
player.sendMessage(ChatColor.BLUE + "" + ChatColor.BOLD + Survival.Words.get("CHARGE!"));
Score score = charge.getScore(player);
score.setScore(1);
Location loc = player.getLocation();
if(loc.getPitch() < 0)
loc.setPitch(0);
Vector vel = loc.getDirection();
Vector newVel = vel.multiply(velocity);
player.setVelocity(newVel);
final Player chargingPlayer = player;
charging.getScore(chargingPlayer).setScore(8);
final Runnable task = new Runnable()
{
public void run()
{
damageNearbyEnemies(chargingPlayer, 8);
Random rand = new Random();
chargingPlayer.getLocation().getWorld().playSound(chargingPlayer.getLocation(), Sound.ENTITY_SHULKER_BULLET_HIT, 1.5F, rand.nextFloat() * 0.4F + 0.8F);
ParticleEffect.EXPLOSION_NORMAL.display(0, 0, 0, 0, 10, chargingPlayer.getLocation(), 64);
int times = charging.getScore(chargingPlayer).getScore();
if(--times > 1)
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Survival.instance, this, 1L);
charging.getScore(chargingPlayer).setScore(times);
}
};
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Survival.instance, task, -1L);
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Survival.instance, new Runnable()
{
Score score = charge.getScore(chargingPlayer);
public void run()
{
score.setScore(0);
chargingPlayer.sendMessage(ChatColor.GREEN + Survival.Words.get("Ready to Charge"));
}
},
100L);
}