当前位置: 首页>>代码示例>>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;未经允许,请勿转载。