当前位置: 首页>>代码示例>>Java>>正文


Java Location.getDirection方法代码示例

本文整理汇总了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));
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:32,代码来源:SurvivalGameLoop.java

示例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);
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:35,代码来源:InfernoTagEffect.java

示例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);
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:52,代码来源:GiantBlade.java


注:本文中的org.bukkit.Location.getDirection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。