本文整理汇总了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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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;
}
}