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


Java Firework.setVelocity方法代碼示例

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


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

示例1: buildFirework

import org.bukkit.entity.Firework; //導入方法依賴的package包/類
private Firework buildFirework(Location loc) {
    Firework firework = (Firework) loc.getWorld().spawnEntity(loc, EntityType.FIREWORK);
    FireworkMeta fwm = firework.getFireworkMeta();
    fwm.addEffect(FireworkEffect.builder()
                  .withColor(AMERICA_COLORS)
                  .with(FireworkEffect.Type.STAR)
                  .withTrail()
                  .withFade(AMERICA_COLORS)
                  .build());
    firework.setFireworkMeta(fwm);

    firework.setVelocity(loc.getDirection().divide(new Vector(2, 1, 2)));

    return firework;
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:16,代碼來源:LauncherGizmo.java

示例2: displayFirework

import org.bukkit.entity.Firework; //導入方法依賴的package包/類
/**
 * Launches firework when receiving an achievement.
 *
 * @param player
 */
private void displayFirework(Player player) {
	Location location = player.getLocation();
	try {
		// Set firework to launch beneath user.
		location.setY(location.getY() - 1);

		Firework firework = player.getWorld().spawn(location, Firework.class);
		FireworkMeta fireworkMeta = firework.getFireworkMeta();
		Builder effectBuilder = FireworkEffect.builder().flicker(false).trail(false)
				.withColor(Color.WHITE.mixColors(Color.BLUE.mixColors(Color.NAVY))).withFade(Color.PURPLE);
		setFireworkType(effectBuilder);
		fireworkMeta.addEffects(effectBuilder.build());
		firework.setVelocity(player.getLocation().getDirection().multiply(0));
		firework.setFireworkMeta(fireworkMeta);

		// Firework launched by plugin: damage will later be cancelled out.
		plugin.getFireworkListener().addFirework(firework);
	} catch (Exception e) {
		// Particle effect workaround to handle various bugs in early Spigot 1.9 and 1.11 releases. We try to
		// simulate a firework.
		player.getWorld().playSound(location, Sound.ENTITY_FIREWORK_LAUNCH, 1, 0.6f);
		ParticleEffect.FIREWORKS_SPARK.display(0, 3, 0, 0.1f, 500, location, 1);
		player.getWorld().playSound(location, Sound.ENTITY_FIREWORK_BLAST, 1, 0.6f);
		player.getWorld().playSound(location, Sound.ENTITY_FIREWORK_TWINKLE, 1, 0.6f);
	}
}
 
開發者ID:PyvesB,項目名稱:AdvancedAchievements,代碼行數:32,代碼來源:PlayerAdvancedAchievementListener.java

示例3: doStep

import org.bukkit.entity.Firework; //導入方法依賴的package包/類
@Override
public void doStep(final Altar altar) {
    final Location loc = altar.getCenterLocation().toBukkitLocation().add(this.firework.getRelativeLocation());
    final Firework f = (Firework)loc.getWorld().spawnEntity(loc, EntityType.FIREWORK);
    if (f != null) {
        if (this.firework.hasVelocity()) {
            f.setVelocity(this.firework.getVelocity());
        }
        final FireworkMeta meta = f.getFireworkMeta();
        meta.addEffects(this.firework.getEffects());
        meta.setPower(0);
        f.setFireworkMeta(meta);
    }
}
 
開發者ID:Ribesg,項目名稱:NPlugins,代碼行數:15,代碼來源:FireworkStep.java

示例4: entityDamage

import org.bukkit.entity.Firework; //導入方法依賴的package包/類
@EventHandler
public void entityDamage(final EntityDamageEvent event) {
    if(!(event instanceof EntityDamageByEntityEvent)) return;
    EntityDamageByEntityEvent realEvent = (EntityDamageByEntityEvent) event;
    if(!(realEvent.getDamager() instanceof Player) || !(realEvent.getEntity() instanceof Player)) return;

    final Player damager = (Player) realEvent.getDamager();
    final Player victim = (Player) realEvent.getEntity();

    if(victim.hasPermission(GizmoConfig.EXEMPT_PERMISSION)) return;

    if(!(Gizmos.gizmoMap.get(damager) instanceof RocketGizmo)) return;
    if(damager.getItemInHand().getType() != this.getIcon()) return;

    boolean cancel = false;
    for(Rocket rocket : this.rockets) {
        if(rocket.getObserver().equals(damager) && rocket.getVictim().equals(victim)) {
            cancel = true;
            break;
        }
    }
    if(cancel) return;

    List<Firework> fireworks = Lists.newArrayList();
    for(int i = 0; i < GizmoConfig.FIREWORK_COUNT; i++) {
        Firework firework = RocketUtils.getRandomFirework(victim.getLocation());
        firework.setVelocity(firework.getVelocity().multiply(new Vector(1, GizmoConfig.ROCKET_VELOCITY_MOD, 1)));
        fireworks.add(firework);
    }

    this.rockets.add(new Rocket(damager, victim, fireworks));

    RocketUtils.fakeDelta(damager, victim, new Vector(0, 3, 0));
    RocketUtils.takeOff(damager, victim.getLocation());

    Integer count = rocketedCount.get(damager);
    if(count == null) count = 0;

    count++;
    rocketedCount.put(damager, count);

    if(count % 10 == 0) {
        RaindropUtil.giveRaindrops(
            Users.playerId(damager), 1, null,
            new TranslatableComponent("gizmo.rocket.raindropsResult", new Component(String.valueOf(count), net.md_5.bungee.api.ChatColor.GOLD))
        );
    }

    event.setCancelled(true);
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:51,代碼來源:RocketGizmo.java

示例5: onVoucherReward

import org.bukkit.entity.Firework; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true)
public void onVoucherReward(RVRewardEvent e) {
    Player p = e.getPlayer();
    String rw = e.getReward();
    Voucher v = e.getVoucher();

    String reward = rw
        .replace("%x%", "" + p.getLocation().getBlockX())
        .replace("%y%", "" + p.getLocation().getBlockY())
        .replace("%z%", "" + p.getLocation().getBlockZ())
        .replace("%tier%", v.getId())
        .replace("%player%", p.getName())
        .replace("%limit%", "" + v.getLimit());

    switch (getType(e.getAction())) {
        case "CONSOLE_COMMAND":
            Bukkit.dispatchCommand(Bukkit.getConsoleSender(), reward);
            break;
        case "PLAYER_COMMAND":
            p.performCommand(reward);
            break;
        case "TELL_PLAYER":
            p.sendMessage(ColorUtil.translate(reward));
            break;
        case "BROADCAST":
            Bukkit.broadcastMessage(ColorUtil.translate(reward));
            break;
        case "PLAY_SOUND":
            Sound s = Sound.valueOf(reward);
            p.playSound(p.getLocation(), s, 3, 3);
            break;
        case "PLAYER_TITLE":
            String title = reward.contains(";") ? reward.split(";")[0] : reward;
            String sub = reward.contains(";") ? reward.split(";")[1] : "";
            p.sendTitle(ColorUtil.translate(title), ColorUtil.translate(sub));
            break;
        case "CENTER_MESSAGE":
            CenterUtil.sendCenteredMessage(p, reward);
            break;
        case "CENTER_BROADCAST":
            for (Player player : Bukkit.getOnlinePlayers()) {
                CenterUtil.sendCenteredMessage(player, reward);
            }
            break;
        case "PLAYER_CHAT":
            p.sendMessage(ColorUtil.translate(reward));
            break;
        case "FIREWORK":
            Firework fw = p.getWorld().spawn(p.getLocation(), Firework.class);
            //use meta to customize the firework or add parameters to the method
            fw.setVelocity(p.getLocation().getDirection().multiply(50));
            fw.setGlowing(true);
            break;
    }
}
 
開發者ID:Chazmondo,項目名稱:RankVouchers,代碼行數:56,代碼來源:VoucherRewardEvent.java


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