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


Java Arrow.setVelocity方法代码示例

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


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

示例1: fire

import org.bukkit.entity.Arrow; //导入方法依赖的package包/类
@Override
public void fire(Location turretLoc, Entity targetEntity) {
	if (!buildable.isValid()) {
		return;
	}
	
	Location playerLoc = targetEntity.getLocation();
	playerLoc.setY(playerLoc.getY()+1); //Target the head instead of feet.
				
	turretLoc = adjustTurretLocation(turretLoc, playerLoc);
	Vector dir = getVectorBetween(playerLoc, turretLoc).normalize();
	Arrow arrow = buildable.getCorner().getLocation().getWorld().spawnArrow(turretLoc, dir, (float)power, 0.0f);
	arrow.setVelocity(dir.multiply(power));
	
	if (buildable.getTown().getBuffManager().hasBuff(Buff.FIRE_BOMB)) {
		arrow.setFireTicks(1000);
	}
	
	CivCache.arrowsFired.put(arrow.getUniqueId(), new ArrowFiredCache(this, targetEntity, arrow));
}
 
开发者ID:netizen539,项目名称:civcraft,代码行数:21,代码来源:ProjectileArrowComponent.java

示例2: onEntityShootBow

import org.bukkit.entity.Arrow; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGH)
private void onEntityShootBow(EntityShootBowEvent event) {
    // Return for disabled world
    if (Zones.inNoDemigodsZone(event.getEntity().getLocation())) return;

    // If they right clicked a block with the ITEM in hand, do stuff
    if (Items.areEqual(event.getBow(), ITEM)) {
        PlayerInventory inventory = null;
        Arrow startArrow = (Arrow) event.getProjectile();
        startArrow.setVelocity(startArrow.getVelocity().multiply(.8));

        if (event.getEntity() instanceof Player) inventory = ((Player) event.getEntity()).getInventory();

        for (int i = 1; i < 3; i++) {
            if (inventory != null) {
                if (!inventory.contains(Material.ARROW, 1)) break;
                inventory.remove(new ItemStack(Material.ARROW, 1));
            }

            Arrow spawnedArrow = (Arrow) event.getEntity().getWorld().spawnEntity(startArrow.getLocation(), EntityType.ARROW);
            spawnedArrow.setShooter(event.getEntity());
            spawnedArrow.setVelocity(startArrow.getVelocity().multiply(.9 / i));
        }
    }
}
 
开发者ID:DemigodsRPG,项目名称:Demigods3,代码行数:26,代码来源:BowOfTria.java

示例3: onShoot

import org.bukkit.entity.Arrow; //导入方法依赖的package包/类
@Override
public void onShoot(ProjectileLaunchEvent event) {
    super.onShoot(event);

    if(event.getEntity() instanceof Arrow) {
        Arrow arrow = (Arrow) event.getEntity();
        arrow.setDamage(modifier.apply(arrow.getDamage()));
        arrow.setVelocity(arrow.getVelocity().multiply(modifier.apply(1d)));
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:11,代码来源:ArcherySymptom.java

示例4: launch

import org.bukkit.entity.Arrow; //导入方法依赖的package包/类
@Override
public void launch(Player p, Vector vector) {
    Arrow arrow = p.launchProjectile(Arrow.class);
    if (vector == null) {
        arrow.setVelocity(p.getEyeLocation().getDirection().multiply(2));
    } else {
        arrow.setVelocity(vector);
    }
    arrow.setShooter(p);
    arrow.setMetadata("skill_type", new FixedMetadataValue(Main.getInstance(), getName()));
    CooldownManager.getInstance().add(p);
}
 
开发者ID:Soldier233,项目名称:ArchersBattle,代码行数:13,代码来源:Archer.java

示例5: onShoot

import org.bukkit.entity.Arrow; //导入方法依赖的package包/类
@EventHandler
	  public void onShoot(EntityShootBowEvent e)
	  {
	    if ((e.getEntity() instanceof Player))
	    {
	      Player p = (Player)e.getEntity();
	   
	        
if(Habilidad.getPercentAbility(p, HabilidadType.TRIPLE_ARROW)==0){
	return;
}
	        if (new Random().nextInt(100)+1 <= Habilidad.getPercentAbility(p, HabilidadType.TRIPLE_ARROW))
	        {
	          Arrow a1 = (Arrow)p.launchProjectile(Arrow.class);
	          Arrow a2 = (Arrow)p.launchProjectile(Arrow.class);
	          if ((getDirection(Float.valueOf(p.getLocation().getYaw())) == "EAST") || (getDirection(Float.valueOf(p.getLocation().getYaw())) == "WEST"))
	          {
	            a1.setVelocity(new Vector(a1.getVelocity().getX(), a1.getVelocity().getY(), a1.getVelocity().getZ() - 0.1D));
	            a2.setVelocity(new Vector(a2.getVelocity().getX(), a2.getVelocity().getY(), a2.getVelocity().getZ() + 0.1D));
	          }
	          else
	          {
	            a1.setVelocity(new Vector(a1.getVelocity().getX() - 0.1D, a1.getVelocity().getY(), a1.getVelocity().getZ()));
	            a2.setVelocity(new Vector(a2.getVelocity().getX() + 0.1D, a2.getVelocity().getY(), a2.getVelocity().getZ()));
	          }
	        }
	   
	    }
	  }
 
开发者ID:SpikyBite,项目名称:BiteSkywars,代码行数:30,代码来源:TripleArrow.java

示例6: volley

import org.bukkit.entity.Arrow; //导入方法依赖的package包/类
private void volley(EntityShootBowEvent e, ItemStack item, int lvl) {
    Player p = (Player) e.getEntity();
    int amount = 1 + 2 * lvl; // Keep amount of arrows uneven, 2 extra arrows in a volley per level.

    Arrow oldArrow = (Arrow) e.getProjectile();
    int fireTicks = oldArrow.getFireTicks();
    int knockbackStrength = oldArrow.getKnockbackStrength();
    boolean critical = oldArrow.isCritical();
    String metadata = oldArrow.getMetadata("ce.bow.enchantment").get(0).asString();

    double angleBetweenArrows = (CONE_DEGREES / (amount - 1)) * Math.PI / 180;
    double pitch = (p.getLocation().getPitch() + 90) * Math.PI / 180;
    double yaw = (p.getLocation().getYaw() + 90 - CONE_DEGREES / 2) * Math.PI / 180;

    // Starting direction values for the cone, each arrow increments it's direction on these values.
    double sZ = Math.cos(pitch);

    for (int i = 0; i < amount; i++) { // spawn all arrows in a cone of 90 degrees (equally distributed).;
        double nX = Math.sin(pitch) * Math.cos(yaw + angleBetweenArrows * i);
        double nY = Math.sin(pitch) * Math.sin(yaw + angleBetweenArrows * i);
        Vector newDir = new Vector(nX, sZ, nY);

        Arrow arrow = p.launchProjectile(Arrow.class);
        arrow.setShooter(p);
        arrow.setVelocity(newDir.normalize().multiply(oldArrow.getVelocity().length())); // Need to make sure arrow has same speed as original arrow.
        arrow.setFireTicks(fireTicks); // Set the new arrows on fire if the original one was 
        arrow.setKnockbackStrength(knockbackStrength);
        arrow.setCritical(critical);

        if (i == 0) {
            if (p.getGameMode().equals(GameMode.CREATIVE))
                arrow.setMetadata("ce.Volley", new FixedMetadataValue(getPlugin(), null)); //Control metadata to prevent players from duplicating arrows
        } else {
            arrow.setMetadata("ce.Volley", new FixedMetadataValue(getPlugin(), null)); //Control metadata to prevent players from duplicating arrows
        }
        arrow.setMetadata("ce.bow.enchantment", new FixedMetadataValue(getPlugin(), metadata));
    }
    oldArrow.remove(); // Remove original arrow.
}
 
开发者ID:Taiterio,项目名称:ce,代码行数:40,代码来源:Volley.java

示例7: run

import org.bukkit.entity.Arrow; //导入方法依赖的package包/类
@Override
public void run()
{
    Arrow shot = player.launchProjectile(Arrow.class);
    shot.setVelocity(shot.getVelocity().multiply(2.0));
}
 
开发者ID:Yoshi41023,项目名称:TatsuCraftMod,代码行数:7,代码来源:TFM_PlayerData.java

示例8: onPlayerInteract

import org.bukkit.entity.Arrow; //导入方法依赖的package包/类
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
	Player player = event.getPlayer();
	if (player.getItemInHand().hasItemMeta()) {
		if (player.getInventory().getItemInHand().getItemMeta().hasDisplayName()) {
			if (player.getInventory().getItemInHand().getType() == Material.BOW) {
				if (player.getInventory().getItemInHand().getItemMeta().getDisplayName()
						.equalsIgnoreCase(Methods.setColours(plugin.getConfig().getString("machine.name")))) {
					if (player.hasPermission("dirtyarrows.machine") && plugin.getConfig().getBoolean("machine.enabled")) {
						if (plugin.isActivated(player) && (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)) {
							if (player.getInventory().contains(Material.ARROW) || player.getGameMode() == GameMode.CREATIVE) {
								if (player.getInventory().getItemInHand().containsEnchantment(Enchantment.DURABILITY)) {
									e = player.getInventory().getItemInHand().getEnchantmentLevel(Enchantment.DURABILITY);
									if (e == 1) {
										e = 4;
									} else if (e == 2) {
										e = 3;
									} else {
										e = 2;
									}
									hasUnbreaking = true;
								} else {
									hasUnbreaking = false;
								}
								
								Location loc = player.getEyeLocation().toVector().add(player.getLocation().getDirection().multiply(3)).toLocation(player.getWorld(), player.getLocation().getYaw(), player.getLocation().getPitch());
								removeSwap(player.getUniqueId().toString());
								Arrow arrow = player.getWorld().spawn(loc, Arrow.class);
								if (player.getItemInHand().containsEnchantment(Enchantment.ARROW_FIRE)) {
									arrow.setFireTicks(2000);
								}
								if (player.getGameMode() != GameMode.CREATIVE) {
									if (!(player.getInventory().getItemInHand().containsEnchantment(Enchantment.ARROW_INFINITE))) {
										player.getInventory().removeItem(new ItemStack(Material.ARROW, 1));
									}
									if (player.getInventory().getItemInHand().getDurability() < (short) 384) {
										if (hasUnbreaking && ran.nextInt(e) == 0) { } else {
											player.getInventory().getItemInHand().setDurability((short) (player.getItemInHand().getDurability() + 1));
										}
									} else {
										player.getInventory().remove(player.getInventory().getItemInHand());
										player.playSound(player.getLocation(), Sound.ITEM_BREAK, 10, 10);
									}
								}
								arrow.setShooter(player);
								player.playEffect(player.getLocation(), Effect.BOW_FIRE, null);
								arrow.setVelocity(player.getEyeLocation().getDirection().multiply(3));
								event.setCancelled(true);
							}
						}
					} else {
						Error.noMachine(player);
					}
				}
			}
		}
	}
}
 
开发者ID:SugarCaney,项目名称:DirtyArrows,代码行数:59,代码来源:ArrowListener.java


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