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


Java Firework.detonate方法代碼示例

本文整理匯總了Java中org.bukkit.entity.Firework.detonate方法的典型用法代碼示例。如果您正苦於以下問題:Java Firework.detonate方法的具體用法?Java Firework.detonate怎麽用?Java Firework.detonate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.entity.Firework的用法示例。


在下文中一共展示了Firework.detonate方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: detonate

import org.bukkit.entity.Firework; //導入方法依賴的package包/類
protected void detonate(Location location, Vector v) {
    final Firework fw = (Firework) location.getWorld().spawnEntity(location.add(v), EntityType.FIREWORK);
    location.subtract(v);
    FireworkMeta meta = fw.getFireworkMeta();
    meta.setPower(0);
    for (int i = 0; i < intensity; i++) {
        meta.addEffect(firework);
    }
    fw.setFireworkMeta(meta);
    fw.detonate();
}
 
開發者ID:Slikey,項目名稱:EffectLib,代碼行數:12,代碼來源:BigBangEffect.java

示例2: explosion

import org.bukkit.entity.Firework; //導入方法依賴的package包/類
private final void explosion(Location location)
{
	if (shotFrom.getExplosionType().equals("TNT"))
	{
		double x = location.getX();
		double y = location.getY();
		double z = location.getZ();

		location.getWorld().createExplosion(x, y, z, (float) shotFrom.getExplodeRadius(), false, false);
	}
	else
	{
		World world = location.getWorld();
		Firework firework = world.spawn(location, Firework.class);

		FireworkMeta meta = firework.getFireworkMeta();
		meta.addEffect(getFireworkEffect());
		meta.setPower(1);

		firework.setFireworkMeta(meta);

		try
		{
			firework.detonate();
		} catch (Throwable ex) { }
	}
}
 
開發者ID:dmulloy2,項目名稱:SwornGuns,代碼行數:28,代碼來源:Bullet.java

示例3: run

import org.bukkit.entity.Firework; //導入方法依賴的package包/類
public void run() {

		double speed = this.arrow.getVelocity().length();
		if ((this.arrow.isOnGround()) || (this.arrow.isDead()) || (this.target.isDead())) {
			cancel();
			Firework f = (Firework) this.arrow.getWorld().spawn(this.arrow.getLocation(), Firework.class);
			List<Color> colors = new ArrayList<Color>();
			colors.add(Color.RED);
			colors.add(Color.YELLOW);
			colors.add(Color.ORANGE);
			FireworkMeta fm = f.getFireworkMeta();
			fm.clearEffects();
			fm.setPower(1);
			fm.addEffect(FireworkEffect.builder().with(FireworkEffect.Type.BALL_LARGE).withColor(colors).withFade().flicker(true).trail(true).build());
			f.setFireworkMeta(fm);
			f.detonate();
			this.target.getWorld().playEffect(this.target.getLocation(), Effect.ENDER_SIGNAL, 0);
			this.arrow.getWorld().playSound(this.arrow.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 25, 0.75F);
			this.arrow.getWorld().playSound(this.arrow.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 25, 10F);
			return;
		}
		Vector toTarget = this.target.getLocation().clone().add(new Vector(0.0D, 0.5D, 0.0D)).subtract(this.arrow.getLocation()).toVector();

		Vector dirVelocity = this.arrow.getVelocity().clone().normalize();
		Vector dirToTarget = toTarget.clone().normalize();
		double angle = dirVelocity.angle(dirToTarget);

		double newSpeed = 0.9D * speed + 0.14D;
		if (((this.target instanceof Player)) && (this.arrow.getLocation().distance(this.target.getLocation()) < 8.0D)) {
			Player player = (Player) this.target;
			if (player.isBlocking()) {
				newSpeed = speed * 0.6D;
			}
		}
		Vector newVelocity;
		if (angle < 0.12D) {
			newVelocity = dirVelocity.clone().multiply(newSpeed);
		} else {
			Vector newDir = dirVelocity.clone().multiply((angle - 0.12D) / angle).add(dirToTarget.clone().multiply(0.12D / angle));
			newDir.normalize();
			newVelocity = newDir.clone().multiply(newSpeed);
		}
		this.arrow.setVelocity(newVelocity.add(new Vector(0.0D, 0.03D, 0.0D)));
		this.arrow.getWorld().playEffect(this.arrow.getLocation(), Effect.MOBSPAWNER_FLAMES, 0);
	}
 
開發者ID:StarQuestMinecraft,項目名稱:StarQuestCode,代碼行數:46,代碼來源:HomingTask.java

示例4: spawnTrappedEgg

import org.bukkit.entity.Firework; //導入方法依賴的package包/類
public void spawnTrappedEgg() {
	eggLocation.getBlock().setType(Material.DRAGON_EGG);

	// Spawning fireworks twice because it doesn't always works on the first try…
	for(int i = 0; i < 2; i++) {
		Firework fw = (Firework) eggLocation.getWorld()
				.spawnEntity(eggLocation.clone().add(0.5, 1, 0.5), EntityType.FIREWORK);

		FireworkMeta meta = fw.getFireworkMeta();
		Builder builder = FireworkEffect.builder()
				.with(Type.BALL)
				.withColor(Color.fromRGB(0x08080c));
		meta.addEffect(builder.build());
		builder = FireworkEffect.builder()
				.with(Type.BALL)
				.withColor(Color.fromRGB(0x2d0133));
		meta.addEffect(builder.build());
		meta.setPower(1);

		fw.setFireworkMeta(meta);
		fw.detonate();
	}

	for(Player player : Bukkit.getOnlinePlayers())
		player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1, 1);

	StringBuilder msg = new StringBuilder();
	msg.append("[");
	msg.append(ChatColor.DARK_PURPLE + "ENDERDRAGON");
	msg.append(ChatColor.WHITE + "] ");
	msg.append(ChatColor.RED + "Vous pensiez vous être débarrassé de moi ?");
	Bukkit.broadcastMessage(msg.toString());

	msg = new StringBuilder();
	msg.append("[");
	msg.append(ChatColor.DARK_PURPLE + "ENDERDRAGON");
	msg.append(ChatColor.WHITE + "] ");
	msg.append(ChatColor.DARK_RED + "Je vous attends où vous auriez dû me déposer...");
	Bukkit.broadcastMessage(msg.toString());

	String msgHelp = "Noobs : Rendez-vous en x=" + eggLocation.getBlockX() + ", z=" + eggLocation.getBlockZ();
	RftdLogger.broadcast(Level.INFO, msgHelp);

	trappedEgg = true;

	// Start sound between 3 seconds (60 ticks) and 5 seconds (100 ticks)
	long nextTick = Math.round(Math.random() * 40) + 60;
	Bukkit.getScheduler().runTaskLater(plugin, new TrappedEggSoundTask(), nextTick);
}
 
開發者ID:kyriog,項目名稱:rftd,代碼行數:50,代碼來源:RftdController.java

示例5: SpawnFireworkExplosion

import org.bukkit.entity.Firework; //導入方法依賴的package包/類
/**
 * Display a firework explosion at a location
 * 
 * @param spawnLocation the location for the explosion
 * @param type the firework effect type
 * @param color the color of the fireworks
 */
static public void SpawnFireworkExplosion(Location spawnLocation, FireworkEffect.Type type, Color color) {
	Firework firework = LaunchFirework(spawnLocation, type, 1, color);
	firework.detonate();
}
 
開發者ID:CodingBadgers,項目名稱:MineKart,代碼行數:12,代碼來源:FireworkFactory.java


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