本文整理汇总了Java中org.bukkit.entity.Projectile.setShooter方法的典型用法代码示例。如果您正苦于以下问题:Java Projectile.setShooter方法的具体用法?Java Projectile.setShooter怎么用?Java Projectile.setShooter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.entity.Projectile
的用法示例。
在下文中一共展示了Projectile.setShooter方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shoot
import org.bukkit.entity.Projectile; //导入方法依赖的package包/类
/**
* A basic shoot method, it _can_ be overridden but take care.
* Handles passing the bullet to its BulletType for configuration, sets shooter, velocity, etc.
*
* @param begin The location to shoot from
* @param bulletType the Bullet type of this bullet
* @param shooter the entity shooting
* @param velocity the velocity to use as base for this shooting, if any
* @param overrideVelocity if true, use the passed velocity and override anything set up by the bullet type.
* @return the new Projectile that has been unleashed.
*/
public Projectile shoot(Location begin, Bullet bulletType, ProjectileSource shooter, Vector velocity, boolean overrideVelocity) {
World world = begin.getWorld();
begin = begin.clone();
begin.setDirection(velocity);
Projectile newBullet = world.spawn(begin, bulletType.getProjectileType() );
newBullet.setCustomName(this.bulletTag);
newBullet.setBounce(false);
newBullet.setGravity(true);
newBullet.setShooter(shooter);
bulletType.configureBullet(newBullet, world, shooter, velocity);
if (overrideVelocity) {
newBullet.setVelocity(velocity);
}
return newBullet;
}
示例2: notify
import org.bukkit.entity.Projectile; //导入方法依赖的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);
}
示例3: shoot
import org.bukkit.entity.Projectile; //导入方法依赖的package包/类
public void shoot(final Player p) {
// First create a vector
Vector v = new Vector(getVelocity(), getVelocity(), getVelocity());
Vector pVec = p.getLocation().getDirection();
Vector finalVec = new Vector(v.getX() * pVec.getX(), v.getY() * pVec.getY(), v.getZ() * pVec.getZ());
Location eye = p.getEyeLocation();
Location oneUp = eye.add(0.0D, 1.0D, 0.0D);
Location loc = oneUp.toVector().add(p.getLocation().getDirection().multiply(2))
.toLocation(p.getWorld(), p.getLocation().getYaw(), p.getLocation().getPitch());
// then launch the projectile
Projectile proj = (Projectile) p.getWorld().spawnEntity(loc, EntityType.FIREBALL);
// launchProjectile(this.projectileClass, finalVec);
// finally, set the shooter
proj.setVelocity(finalVec);
/*if (!(proj instanceof Egg) || !(proj instanceof Snowball)) {
proj.setShooter((ProjectileSource) p);
}*/
proj.setShooter(p);
// play sounds
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ARROW_SHOOT, 2.0F, 1.0F);
}
示例4: run
import org.bukkit.entity.Projectile; //导入方法依赖的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);
}
示例5: run
import org.bukkit.entity.Projectile; //导入方法依赖的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, "冷却时间还没有结束呢!");
}
}
示例6: onGraczInteract
import org.bukkit.entity.Projectile; //导入方法依赖的package包/类
@EventHandler
public void onGraczInteract(PlayerInteractEvent pie) {
Player gracz = (Player) pie.getPlayer();
String mb = pie.getPlayer().getItemInHand().getItemMeta().getDisplayName();
if(mb.equals(plugin.nameM9) || mb.equals(plugin.nameSG) || mb.equals(plugin.nameM14) || mb.equals(plugin.nameM16) || mb.equals(plugin.nameAK47)) {
if (pie.getAction() == Action.LEFT_CLICK_BLOCK
|| pie.getAction() == Action.LEFT_CLICK_AIR) {
World world = gracz.getWorld();
org.bukkit.Location loc = pie.getPlayer().getEyeLocation();
Projectile zmienna = (Projectile) world.spawnEntity(loc,
EntityType.SNOWBALL);
Vector loce = gracz.getLocation().getDirection().multiply(4);
zmienna.setShooter(gracz);
zmienna.setVelocity(loce);
Map<Projectile, Amunicja> projMap = plugin.nabojeMap.get(gracz.getName());
if (projMap == null)
{
projMap = new HashMap<>();
plugin.nabojeMap.put(gracz.getName(), projMap);
}
if(mb.equals(plugin.nameAK47)) {
projMap.put(zmienna, Amunicja.amoAK47);
} else if(mb.equals(plugin.nameM16)) {
projMap.put(zmienna, Amunicja.amoM16);
} else if(mb.equals(plugin.nameM14)) {
projMap.put(zmienna, Amunicja.amoM14);
} else if(mb.equals(plugin.nameSG)) {
projMap.put(zmienna, Amunicja.amoSG);
} else if(mb.equals(plugin.nameM9)) {
projMap.put(zmienna, Amunicja.amoM9);
}
}
}
}