當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。