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


Java Snowball.setVelocity方法代码示例

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


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

示例1: shoot

import org.bukkit.entity.Snowball; //导入方法依赖的package包/类
public void shoot(Player player){
    setAttackTimer(getAttackTimer() + System.currentTimeMillis() - getLastAttackTimer());
    setLastAttackTimer(System.currentTimeMillis());
    if(getAttackTimer() < getShootCooldown()) return;

    /*if (hasBullets()) {
        System.out.println("Tiene balas: " + Integer.parseInt(lore.get(lore.size() - 1).split(" ")[1]));
        youShotM8();
    }*/
    
    Snowball snowball = player.getWorld().spawn(player.getEyeLocation(), Snowball.class);
    snowball.setVelocity(player.getLocation().getDirection().multiply(distance()));
    snowball.setShooter(player);
    snowball.setMetadata("twd", new FixedMetadataValue(WCTWD.getInstance(), "weapon_" + getId()));

    //
    player.playSound(player.getLocation(), sound, 1, 1);
    particle.display(particleData, 0, 0, 0, 1, 3, player.getLocation(), 20);
}
 
开发者ID:cadox8,项目名称:WC,代码行数:20,代码来源:Weapon.java

示例2: onRightClickItem

import org.bukkit.entity.Snowball; //导入方法依赖的package包/类
@EventHandler
public void onRightClickItem(PlayerInteractEvent event){
    Player p = event.getPlayer();
    if(event.getItem() != null){
        if(event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
            if (event.getItem().hasItemMeta()) {
                switch (event.getItem().getType()) {
                    default:
                        break;
                    case FIREWORK_CHARGE:
                        event.setCancelled(true);
                        shootFirework(p);
                        break;
                    case FIREWORK:
                        if(event.getItem().getItemMeta().hasDisplayName()){
                            if(ChatColor.stripColor(event.getItem().getItemMeta().getDisplayName()).contains("Gadget")){
                                event.setCancelled(true);
                                shootFireworkRide(p);
                            }
                        }
                        break;
                    case WOOD_HOE:
                        Snowball sb = p.launchProjectile(Snowball.class);
                        sb.setShooter(p);
                        sb.setVelocity(p.getLocation().getDirection().multiply(1.7));
                        p.playSound(p.getLocation(), Sound.IRONGOLEM_THROW, 100, 1);
                        break;
                    case RECORD_11:
                        event.setCancelled(true);
                        playMusic(p);
                        break;
                }
            }
        }
    }
}
 
开发者ID:Cooltimmetje,项目名称:PretparkCore,代码行数:37,代码来源:GadgetTriggers.java

示例3: spawnProjectile

import org.bukkit.entity.Snowball; //导入方法依赖的package包/类
/**
 * This is the shooting mechanic
 * @param player the player that the projectile should be spawned at
 * @param accuracy the accuracy of the projectile, 0 is 100% accurate
 * @param speed the speed the projectile will have
 */
public static void spawnProjectile(Player player, double accuracy, double speed, ItemList weapon){
	
	double randX, randY, randZ;
	randX = Math.random()*accuracy;
	randY = Math.random()*accuracy;
	randZ = Math.random()*accuracy;
	
	Snowball bullet = player.getWorld().spawn(player.getEyeLocation(), Snowball.class);
	Vector velocity = new Vector().setX(randX).setY(randY).setZ(randZ);
	velocity.add(player.getLocation().getDirection().multiply(speed));
	bullet.setVelocity(velocity); 
	bullet.setShooter(player);
	bullets.put(bullet.getEntityId(), new BulletInfo(bullet, player, weapon));
}
 
开发者ID:viktorstrate,项目名称:mcAssault,代码行数:21,代码来源:Weapons.java

示例4: checkProjectileAbility

import org.bukkit.entity.Snowball; //导入方法依赖的package包/类
/**
 * Checks if any projectile should be launched when a PlayerInteractEvent is fired
 * @param event the PlayerInteractEvent to check
 * @return true if a projectile is launched
 */
@SuppressWarnings("deprecation")
public boolean checkProjectileAbility(PlayerInteractEvent event) {
	final Player player = event.getPlayer();
	if (!api.getGameManager().isPlayerInGame(player))
		return false;

	event.setCancelled(true); // Players do not need to interact if they're not using a special ability.

	Game game = api.getGameManager().getGame(player);
	if (game.getState() != GameState.PLAYING)
		return false;
	if (player.getItemInHand() == null)
		return false;

	Material hand = player.getItemInHand().getType();
	if (hand != Material.SLIME_BALL && hand != Material.SNOW_BALL && hand != Material.getMaterial(175))
		return false;

	PlantType type = game.getPlants().getMembers().get(player.getUniqueId());
	if (type == null)
		return false;

	switch (type) {
	case PEASHOOTER:
		useAbility(Ability.SNOWBALL, player);
		return true;
	case REPEATER:
		useAbility(Ability.SNOWBALL, player);
		new BukkitRunnable() {	// Launch a second snowball a fourth of a second later...
			@Override
			public void run() {
				useAbility(Ability.SNOWBALL, player);
			}
		}.runTaskLater(api.getPlugin(), 10l);
		return true;
	case WINTER_MELON:
		if (game.getInCooldown().contains(player.getUniqueId()))
			return false;

		player.getInventory().setItemInHand(new ItemStack(Material.AIR));
		Snowball snowball = player.launchProjectile(Snowball.class);
		snowball.setVelocity(snowball.getVelocity().multiply(2));
		snowball.setShooter(player);
		ArrayList<UUID> inCooldown = game.getInCooldown();
		inCooldown.add(player.getUniqueId());
		game.setInCooldown(inCooldown);

		// Make a cooldown for a second.
		RemoveFromCooldown rfc = new RemoveFromCooldown(player.getUniqueId(), game.getSlot(), false, true);
		rfc.runTaskLater(api.getPlugin(), 20l);
		return true;
	case SUNFLOWER:
		if (game.getInCooldown().contains(player.getUniqueId()))
			return false;

		useAbility(Ability.SUNFLOWER_BOOST, player, game);
		return true;
	case BONK_CHOY:
		return false;
	default:
		return false;
	}
}
 
开发者ID:Lactem,项目名称:PvZ,代码行数:69,代码来源:AbilityUtil.java

示例5: fire

import org.bukkit.entity.Snowball; //导入方法依赖的package包/类
public void fire() {
    if (canFire)
        if (p.getItemInHand().getDurability() < 31) {
            if (cockHash.get(p)) {

                //gun fire sound
                p.playSound(p.getLocation(), Sound.ZOMBIE_METAL, 1, -3f);

                //gun fire smoke effect
                Location smokePos = gunTools.getSpawnLoc(p);
                p.playEffect(smokePos, Effect.SMOKE, 0);

                //smoke and gun for other players
                List<Player> plList = gunTools.getPlayersWithin(p, 50);
                double distance = 0;
                for (int i = 0; i < plList.size(); i++) {
                    plList.get(i).playEffect(smokePos, Effect.SMOKE, 0);
                    distance = plList.get(i).getLocation().distance(p.getLocation());
                    if (distance <= 50 && distance > 0) {
                        plList.get(i).playSound(smokePos, Sound.ZOMBIE_METAL, (float) (1 - (distance / 50)), -3f);
                    }
                }

                Random randomGenerator = new Random();
                for (int i = 0; i < shotNo; i++) {
                    Snowball snowball = p.launchProjectile(Snowball.class);
                    snowball.setVelocity(p.getLocation().getDirection().multiply(5));

                    int randomInt = randomGenerator.nextInt(2);
                    switch (randomInt) {
                        case 0:
                            snowball.setVelocity(snowball.getVelocity().add(new Vector(0, 0, snowball.getVelocity().getZ() / 4)));
                            break;
                        case 1:
                            snowball.setVelocity(snowball.getVelocity().add(new Vector(snowball.getVelocity().getX() / 4, 0, 0)));
                            break;
                        case 2:
                            snowball.setVelocity(snowball.getVelocity().add(new Vector(0, snowball.getVelocity().getY() / 4, 0)));
                            break;
                    }

                    snowball.setShooter(p);
                    firedEntity.add(snowball.getEntityId());
                    Bukkit.getServer().getScheduler().runTaskLater(plugin, new DestroyAfter(snowball), 6);
                }

                p.getItemInHand().setDurability((short) (p.getItemInHand().getDurability() + 30));
                cockHash.put(p, false);

                FiringDelay fd = new FiringDelay();
                Bukkit.getServer().getScheduler().runTaskLater(plugin, fd, fireDelay);
                canFire = false;
            } else {
                p.playSound(p.getLocation(), Sound.NOTE_BASS_DRUM, 10, -1f);
            }
        } else {
            p.playSound(p.getLocation(), Sound.CLICK, 5, 2f);
        }
}
 
开发者ID:GoldRushMC,项目名称:GoldRushPlugin,代码行数:60,代码来源:Shotgun.java

示例6: fire

import org.bukkit.entity.Snowball; //导入方法依赖的package包/类
public void fire() {
    if (canFire)
        if (p.getItemInHand().getDurability() < 31) {
            if (cockHash.get(p)) {

                //gun fire sound
                p.playSound(p.getLocation(), Sound.ZOMBIE_METAL, 1, -3f);

                //gun fire smoke effect
                Location smokePos = gunTools.getSpawnLoc(p);
                p.playEffect(smokePos, Effect.SMOKE, 0);

                //smoke and gun for other players
                List<Player> plList = gunTools.getPlayersWithin(p, 50);
                double distance = 0;
                for (int i = 0; i < plList.size(); i++) {
                    plList.get(i).playEffect(smokePos, Effect.SMOKE, 0);
                    distance = plList.get(i).getLocation().distance(p.getLocation());
                    if (distance <= 50 && distance > 0) {
                        plList.get(i).playSound(smokePos, Sound.ZOMBIE_METAL, (float) (1 - (distance / 50)), -3f);
                    }
                }

                Snowball snowball = p.launchProjectile(Snowball.class);
                snowball.setVelocity(p.getLocation().getDirection().multiply(5));
                snowball.setShooter(p);

                firedEntity = snowball.getEntityId();

                Bukkit.getServer().getScheduler().runTaskLater(plugin, new DestroyAfter(snowball), 40);

                p.getItemInHand().setDurability((short) (p.getItemInHand().getDurability() + 30));
                cockHash.put(p, false);

                FiringDelay fd = new FiringDelay();
                Bukkit.getServer().getScheduler().runTaskLater(plugin, fd, fireDelay);
                canFire = false;
            } else {
                p.playSound(p.getLocation(), Sound.NOTE_BASS_DRUM, 10, -1f);
            }
        } else {
            p.playSound(p.getLocation(), Sound.CLICK, 5, 2f);
        }
}
 
开发者ID:GoldRushMC,项目名称:GoldRushPlugin,代码行数:45,代码来源:Rifle.java

示例7: fire

import org.bukkit.entity.Snowball; //导入方法依赖的package包/类
public void fire() {
    if (canFire)
        if (p.getItemInHand().getDurability() < 31) {
            if (cockHash.get(p)) {

                //gun fire sound
                p.playSound(p.getLocation(), Sound.ZOMBIE_METAL, 1, -3f);

                //gun fire smoke effect
                Location smokePos = gunTools.getSpawnLoc(p);
                p.playEffect(smokePos, Effect.SMOKE, 0);

                //smoke and gun for other players
                List<Player> plList = gunTools.getPlayersWithin(p, 50);
                double distance = 0;
                for (int i = 0; i < plList.size(); i++) {
                    plList.get(i).playEffect(smokePos, Effect.SMOKE, 0);
                    distance = plList.get(i).getLocation().distance(p.getLocation());
                    if (distance <= 50 && distance > 0) {
                        plList.get(i).playSound(smokePos, Sound.ZOMBIE_METAL, (float) (1 - (distance / 50)), -3f);
                    }
                }

                Snowball snowball = p.launchProjectile(Snowball.class);
                snowball.setVelocity(p.getLocation().getDirection().multiply(5));
                snowball.setShooter(p);

                firedEntity = snowball.getEntityId();

                Bukkit.getServer().getScheduler().runTaskLater(plugin, new DestroyAfter(snowball), 20);

                p.getItemInHand().setDurability((short) (p.getItemInHand().getDurability() + 6));
                cockHash.put(p, false);

                FiringDelay fd = new FiringDelay();
                Bukkit.getServer().getScheduler().runTaskLater(plugin, fd, fireDelay);
                canFire = false;
            } else {
                p.playSound(p.getLocation(), Sound.NOTE_BASS_DRUM, 10, -1f);
            }
        } else {
            p.playSound(p.getLocation(), Sound.CLICK, 5, 2f);
        }
}
 
开发者ID:GoldRushMC,项目名称:GoldRushPlugin,代码行数:45,代码来源:Revolver.java

示例8: fire

import org.bukkit.entity.Snowball; //导入方法依赖的package包/类
public void fire() {
	if(canFire)
	if (p.getItemInHand().getDurability() < 31) {
		if (cockHash.get(p)) {
			
			//gun fire sound
			p.playSound(p.getLocation(), Sound.ZOMBIE_METAL,1, -3f);
			
			//gun fire smoke effect
			Location smokePos = gunTools.getSpawnLoc(p);
			p.playEffect(smokePos, Effect.SMOKE, 0);
			
			//smoke and gun for other players
			List<Player> plList = gunTools.getPlayersWithin(p, 50);
			double distance = 0;
			for(int i = 0; i < plList.size();i++) {
				plList.get(i).playEffect(smokePos, Effect.SMOKE, 0);
				distance = plList.get(i).getLocation().distance(p.getLocation());
				if(distance <=50 && distance > 0){
					plList.get(i).playSound(smokePos, Sound.ZOMBIE_METAL, (float)  (1 - (distance / 50)), -3f);
				}
			}
			
			Random randomGenerator = new Random();
			for(int i = 0; i < shotNo; i++) {
				Snowball snowball = p.launchProjectile(Snowball.class);
				snowball.setVelocity(p.getLocation().getDirection().multiply(5));
								
				int randomInt = randomGenerator.nextInt(2);
				switch(randomInt) {
				case 0:
					snowball.setVelocity(snowball.getVelocity().add(new Vector(0, 0, snowball.getVelocity().getZ()/4)));
					break;
				case 1:
					snowball.setVelocity(snowball.getVelocity().add(new Vector(snowball.getVelocity().getX()/4, 0, 0)));
					break;
				case 2:
					snowball.setVelocity(snowball.getVelocity().add(new Vector(0, snowball.getVelocity().getY()/4, 0)));
					break;
				}					
				
				snowball.setShooter(p);					
				firedEntity.add(snowball.getEntityId());
				Bukkit.getServer().getScheduler().runTaskLater(plugin, new DestroyAfter(snowball), 6);
			}
							
			p.getItemInHand().setDurability((short) (p.getItemInHand().getDurability() + 30));
			cockHash.put(p, false);
			
			FiringDelay fd = new FiringDelay();
			Bukkit.getServer().getScheduler().runTaskLater(plugin, fd, fireDelay);
			canFire = false;
		} else {
			p.playSound(p.getLocation(), Sound.NOTE_BASS_DRUM,10, -1f);
		}
	} else {
		p.playSound(p.getLocation(), Sound.CLICK,5, 2f);
	}
}
 
开发者ID:lexwebb,项目名称:GoldRushMC,代码行数:60,代码来源:Shotgun.java

示例9: fire

import org.bukkit.entity.Snowball; //导入方法依赖的package包/类
public void fire() {
	if(canFire)
	if (p.getItemInHand().getDurability() < 31) {
		if (cockHash.get(p)) {
			
			//gun fire sound
			p.playSound(p.getLocation(), Sound.ZOMBIE_METAL,1, -3f);
			
			//gun fire smoke effect
			Location smokePos = gunTools.getSpawnLoc(p);
			p.playEffect(smokePos, Effect.SMOKE, 0);
			
			//smoke and gun for other players
			List<Player> plList = gunTools.getPlayersWithin(p, 50);
			double distance = 0;
			for(int i = 0; i < plList.size();i++) {
				plList.get(i).playEffect(smokePos, Effect.SMOKE, 0);
				distance = plList.get(i).getLocation().distance(p.getLocation());
				if(distance <=50 && distance > 0){
					plList.get(i).playSound(smokePos, Sound.ZOMBIE_METAL, (float)  (1 - (distance / 50)), -3f);
				}
			}
			
			Snowball snowball = p.launchProjectile(Snowball.class);
			snowball.setVelocity(p.getLocation().getDirection().multiply(5));
			snowball.setShooter(p);
			
			firedEntity = snowball.getEntityId();
			
			Bukkit.getServer().getScheduler().runTaskLater(plugin, new DestroyAfter(snowball), 40);
			
			p.getItemInHand().setDurability((short) (p.getItemInHand().getDurability() + 30));
			cockHash.put(p, false);
			
			FiringDelay fd = new FiringDelay();
			Bukkit.getServer().getScheduler().runTaskLater(plugin, fd, fireDelay);
			canFire = false;
		} else {
			p.playSound(p.getLocation(), Sound.NOTE_BASS_DRUM,10, -1f);
		}
	} else {
		p.playSound(p.getLocation(), Sound.CLICK,5, 2f);
	}
}
 
开发者ID:lexwebb,项目名称:GoldRushMC,代码行数:45,代码来源:Rifle.java

示例10: fire

import org.bukkit.entity.Snowball; //导入方法依赖的package包/类
public void fire() {
	if(canFire)
	if (p.getItemInHand().getDurability() < 31) {
		if (cockHash.get(p)) {
			
			//gun fire sound
			p.playSound(p.getLocation(), Sound.ZOMBIE_METAL,1, -3f);
			
			//gun fire smoke effect
			Location smokePos = gunTools.getSpawnLoc(p);
			p.playEffect(smokePos, Effect.SMOKE, 0);
			
			//smoke and gun for other players
			List<Player> plList = gunTools.getPlayersWithin(p, 50);
			double distance = 0;
			for(int i = 0; i < plList.size();i++) {
				plList.get(i).playEffect(smokePos, Effect.SMOKE, 0);
				distance = plList.get(i).getLocation().distance(p.getLocation());
				if(distance <=50 && distance > 0){
					plList.get(i).playSound(smokePos, Sound.ZOMBIE_METAL, (float)  (1 - (distance / 50)), -3f);
				}
			}
			
			Snowball snowball = p.launchProjectile(Snowball.class);
			snowball.setVelocity(p.getLocation().getDirection().multiply(5));
			snowball.setShooter(p);
			
			firedEntity = snowball.getEntityId();
			
			Bukkit.getServer().getScheduler().runTaskLater(plugin, new DestroyAfter(snowball), 20);
			
			p.getItemInHand().setDurability((short) (p.getItemInHand().getDurability() + 6));
			cockHash.put(p, false);
			
			FiringDelay fd = new FiringDelay();
			Bukkit.getServer().getScheduler().runTaskLater(plugin, fd, fireDelay);
			canFire = false;
		} else {
			p.playSound(p.getLocation(), Sound.NOTE_BASS_DRUM,10, -1f);
		}
	} else {
		p.playSound(p.getLocation(), Sound.CLICK,5, 2f);
	}
}
 
开发者ID:lexwebb,项目名称:GoldRushMC,代码行数:45,代码来源:Revolver.java

示例11: fire

import org.bukkit.entity.Snowball; //导入方法依赖的package包/类
@EventHandler
public void fire(PlayerInteractEvent event){
	Player player = event.getPlayer();
	SplatterShot gun = SplatterShot.getGun(player.getItemInHand());
	if (gun == null) return;
	switch (event.getAction()){
	case RIGHT_CLICK_AIR:
	case RIGHT_CLICK_BLOCK:
		// Primary
		Location ploc = player.getEyeLocation();
		Snowball snowball = (Snowball)player.getWorld().spawn(ploc.add(ploc.getDirection()), Snowball.class);
		snowball.setVelocity(ploc.getDirection());
		
		
		
		
		break;
	case LEFT_CLICK_AIR:
	case LEFT_CLICK_BLOCK:
		// Secondary
		
		
		
		

		break;
	default:
		break;
	}
	
	
}
 
开发者ID:connection-lost,项目名称:Splatoon,代码行数:33,代码来源:SplatoonGunListener.java

示例12: onCommand

import org.bukkit.entity.Snowball; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public boolean onCommand(CommandSender sender, Command cmd, String lbl, String[] args) {
	
	if(sender instanceof Player){
		
		Player p = (Player) sender;
		
		if(lbl.equals("castskill")){
			if(args.length == 1){
				String skillType = args[0];
				
				if(skillType.equals("throw-snowball")){
					
					for(int i = 0 ; i < snowballAmount ; i++){
						
						Snowball s = p.getWorld().spawn(p.getEyeLocation(), Snowball.class);
						s.setShooter(p);
						s.setVelocity(p.getLocation().getDirection().multiply(1.5));  
						
					}
					
				}
				
			}
		}
		
	}
	
	return true;
}
 
开发者ID:Zarkopafilis,项目名称:Random-Notes,代码行数:32,代码来源:SkillCastClass.java


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