本文整理汇总了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));
}
示例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));
}
}
}
示例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)));
}
}
示例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);
}
示例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()));
}
}
}
}
示例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.
}
示例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));
}
示例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);
}
}
}
}
}
}