當前位置: 首頁>>代碼示例>>Java>>正文


Java Projectile.setShooter方法代碼示例

本文整理匯總了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;
}
 
開發者ID:ProgrammerDan,項目名稱:AddGun,代碼行數:31,代碼來源:StandardGun.java

示例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);
}
 
開發者ID:Recraft,項目名稱:Recreator,代碼行數:27,代碼來源:StructureTurret.java

示例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);
	}
 
開發者ID:StarQuestMinecraft,項目名稱:StarQuestCode,代碼行數:27,代碼來源:FireballTurret.java

示例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);
}
 
開發者ID:Recraft,項目名稱:Recreator,代碼行數:36,代碼來源:ItemFatMan.java

示例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, "冷卻時間還沒有結束呢!");
    }
}
 
開發者ID:Recraft,項目名稱:Recreator,代碼行數:34,代碼來源:ItemRedstoneCannon.java

示例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);	
  } 

    }
  } 
}
 
開發者ID:youuw,項目名稱:eGuns,代碼行數:36,代碼來源:onPlayerInteract.java


注:本文中的org.bukkit.entity.Projectile.setShooter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。