FireworkFactory.java 文件源码

java
阅读 32 收藏 0 点赞 0 评论 0

项目:MineKart 作者:
/**
 * Launch a firework at a given location with specified properties
 * 
 * @param spawnLocation the location for the firework
 * @param type the firework type
 * @param power the power of the firework
 * @param colors the colors of the fireworks
 * @param fadecolors the colors for the firework to fade to
 * @param trail if the firework should leave a trail
 * @param flicker if the firework should flicker
 */
static public Firework LaunchFirework(Location spawnLocation, FireworkEffect.Type type, int power, ArrayList<Color> colors, ArrayList<Color> fadecolors, boolean flicker, boolean trail) {

    Firework firework = spawnLocation.getWorld().spawn(spawnLocation, Firework.class);
    FireworkMeta metadata = firework.getFireworkMeta();

    Builder builder = FireworkEffect.builder();
    builder.with(type);
    builder.flicker(flicker);
    builder.trail(trail);
    builder.withColor(colors);
    builder.withFade(fadecolors);

    FireworkEffect effect = builder.build();
    metadata.addEffect(effect);
    metadata.setPower(power);

    firework.setFireworkMeta(metadata);

    return firework;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号