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


Java Player.getEyeLocation方法代码示例

本文整理汇总了Java中org.bukkit.entity.Player.getEyeLocation方法的典型用法代码示例。如果您正苦于以下问题:Java Player.getEyeLocation方法的具体用法?Java Player.getEyeLocation怎么用?Java Player.getEyeLocation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.entity.Player的用法示例。


在下文中一共展示了Player.getEyeLocation方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: notify

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void notify(Player player, Object extra) {
    Location eye = player.getEyeLocation();
    Vector direction = eye.getDirection().multiply(2);
    Block source = (Block) extra;
    Projectile projectile = player.getWorld().spawn(source.getRelative(BlockFace.UP).getLocation().setDirection(direction), LargeFireball.class);
    projectile.setShooter(player);
    projectile.setVelocity(direction);
    
    Inventory inv = player.getInventory();
    if (inv.contains(Material.TNT)) {
        int slot = inv.first(Material.TNT);
        ItemStack ammo = inv.getItem(slot);
        int amount = ammo.getAmount();
        if (amount > 1) {
            ammo.setAmount(amount - 1);
            inv.setItem(slot, ammo);
        } else {
            inv.setItem(slot, null);
        }
        
        projectile.setCustomName("recreator.structure.turret.tnt");
    }
    
    AzureAPI.playSound(player, Sound.ITEM_FIRECHARGE_USE, true);
}
 
开发者ID:Recraft,项目名称:Recreator,代码行数:27,代码来源:StructureTurret.java

示例2: particleCircle

import org.bukkit.entity.Player; //导入方法依赖的package包/类
private void particleCircle(Player player ,int particles, float radius, ParticleEffect particle)
{
    Location location = player.getEyeLocation();
	for (int i = 0; i < particles; i++) {
           double angle, x, z;
           angle = 2 * Math.PI * i / particles;
           x = Math.cos(angle) * radius;
           z = Math.sin(angle) * radius;
           location.add(x, -0.3, z);
           particle.display(0.05f, 0.05f, 0.05f, 0, 1, location, 64);
           location.subtract(x, -0.3, z);
       }
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:14,代码来源:Valkyrie.java

示例3: run

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void run(PlayerInteractEvent evt) {
    Player player = evt.getPlayer();
    Inventory inv = player.getInventory();
    if (!inv.contains(Material.FIREWORK_CHARGE)) {
        AzureAPI.log(player, "你没有弹药! 需要 " + ChatColor.RED + "迷你核弹" + ChatColor.GOLD + " 作为弹药");
        AzureAPI.playSound(player, Sound.ENTITY_ITEM_BREAK);
        return;
    }
    int slot = inv.first(Material.FIREWORK_CHARGE);
    ItemStack ammo = inv.getItem(slot);
    if (ammo.hasItemMeta()) {
        if (!ammo.getItemMeta().hasLore()) return;
        if (!ammo.getItemMeta().getLore().contains("弹药")) return;
    } else {
        return;
    }
    int amount = ammo.getAmount();
    if (amount > 1) {
        ammo.setAmount(amount - 1);
        inv.setItem(slot, ammo);
    } else {
        inv.setItem(slot, null);
    }
    
    Location eye = player.getEyeLocation();
    Vector direction = eye.getDirection().multiply(2);
    Projectile projectile = player.getWorld().spawn(eye.add(direction), DragonFireball.class);
    projectile.setBounce(true);
    projectile.setGravity(true);
    projectile.setShooter(player);
    projectile.setVelocity(direction);
    projectile.setCustomName("recreator.item.fatman");
    AzureAPI.playSound(player, Sound.ITEM_FIRECHARGE_USE, true);
}
 
开发者ID:Recraft,项目名称:Recreator,代码行数:36,代码来源:ItemFatMan.java

示例4: run

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void run(PlayerInteractEvent evt) {
    Player player = evt.getPlayer();
    if (CooldownTicker.can(this, player) || evt.getItem().getItemMeta().getLore().contains("§6高速射击")) {
        Inventory inv = player.getInventory();
        if (!inv.contains(Material.SULPHUR)) {
            AzureAPI.log(player, "你没有弹药! 需要 " + ChatColor.RED + "火药" + ChatColor.GOLD + " 作为弹药");
            AzureAPI.playSound(player, Sound.ENTITY_ITEM_BREAK);
            return;
        }
        int slot = inv.first(Material.SULPHUR);
        ItemStack ammo = inv.getItem(slot);
        int amount = ammo.getAmount();
        if (amount > 1) {
            ammo.setAmount(amount - 1);
            inv.setItem(slot, ammo);
        } else {
            inv.setItem(slot, null);
        }
        
        Location eye = player.getEyeLocation();
        Vector direction = eye.getDirection().multiply(2);
        Projectile projectile = player.getWorld().spawn(eye.add(direction), Fireball.class);
        projectile.setShooter(player);
        projectile.setVelocity(direction);
        AzureAPI.playSound(player, Sound.ITEM_FIRECHARGE_USE, true);
        
        CooldownTicker.cooldown(this, player, TimeUnit.SECONDS, 3);
    } else {
        AzureAPI.playSound(player, Sound.UI_BUTTON_CLICK);
        AzureAPI.log(player, "冷却时间还没有结束呢!");
    }
}
 
开发者ID:Recraft,项目名称:Recreator,代码行数:34,代码来源:ItemRedstoneCannon.java

示例5: onRightClick

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onRightClick(PlayerInteractEvent event){
if (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR) {
	System.out.println("イベントだよー");
	Player player = event.getPlayer();
    String playername = player.getName();
	Location loc = player.getEyeLocation();
    System.out.println(playername + "さんのXYZだよー" + loc.getX() +"、"+ loc.getY()+"、"+ loc.getZ());
}
else {

}
}
 
开发者ID:rintech,项目名称:Sword_Skill,代码行数:14,代码来源:Main.java


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