Java 类org.bukkit.Particle 实例源码

项目:AddGun    文件:StandardGun.java   
/**
 * Override this class, you can use it to provide particle effects along travel path. 
 * 
 * It is called after all other handling is done. Keep it lightweight
 * 
 * @param start The start location of flight
 * @param end The end location of impact / miss
 * @param type the type of bullet in play
 * @param endOfFlight is the bullet still flying after this or has it impacted?
 */
public void flightPath(Location start, Location end, Bullet type, boolean endOfFlight) {
    // no special flight path stuff. maybe a whizzing sound?

    World world = start.getWorld();
    if (endOfFlight) {
        // make a new sound where it hits.
        world.playSound(end, Sound.ENTITY_FIREWORK_BLAST, 1.0f, 1.5f);
    }
    if (type.getFireChance() > 0.0d) {
        if (start != null) {
            double distance = end.distance(start);

            Vector vector = end.subtract(start).toVector();
            vector = vector.multiply(0.1d / distance);
            for (int i = 0; i < distance; i++) {
                world.spawnParticle(Particle.SMOKE_NORMAL, start.add(vector), 5, 0.01, 0.01, 0.01, 0.001);
            }
        }
    }
}
项目:ProjectAres    文件:ProjectileTrailMatchModule.java   
@Repeatable(scope = MatchScope.RUNNING)
public void tick() {
    EntityUtils.entities(match.getWorld(), Projectile.class)
         .filter(projectile -> projectile.hasMetadata(TRAIL_META))
         .forEach(projectile -> {
             if(projectile.isDead() || projectile.isOnGround()) {
                 projectile.removeMetadata(TRAIL_META, PGM.get());
             } else {
                 final Color color = (Color) projectile.getMetadata(TRAIL_META, PGM.get()).value();
                 // Certain particles can have a specific color if:
                 // - Count is 0
                 // - Speed is 1
                 // - Delta vectors are RGB values from (0,1]
                 match.getWorld().spawnParticle(
                     Particle.REDSTONE,
                     projectile.getLocation(),
                     0,
                     rgbToParticle(color.getRed()),
                     rgbToParticle(color.getGreen()),
                     rgbToParticle(color.getBlue()),
                     1
                 );
             }
         });
}
项目:MystiCraft    文件:CraftingOperation.java   
public boolean craft(Player crafter) {
    // TODO Block crafting operation when not allowed for player
    String spell = getSpell();
    if (spell != null) {
        ItemStack tome = SpellTome.getSpellTome(spell, crafter);
        Location spawnLoc = block.getLocation().add(0.5, 1.5, 0.5);
        spawnLoc.getWorld().spawnParticle(Particle.ENCHANTMENT_TABLE, spawnLoc, 40);
        for (Entry<Item, BukkitRunnable> entry : items.entrySet()) {
            Item item = entry.getKey();
            item.remove();
            entry.getValue().cancel();
        }
        book.setCustomNameVisible(false);
        new BukkitRunnable() {
            public void run() {
                book.setItemStack(tome);
                book.setGlowing(false);
                book.setPickupDelay(0);
                book.getWorld().playSound(book.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1);
            }
        }.runTaskLater(MystiCraft.getInstance(), 32);
        return true;
    } else {
        return false;
    }
}
项目:Kineticraft    文件:GUIParticles.java   
@Override
public void addItems() {
    Particle effect = getWrapper().getEffect();
    for (Particle p : getParticles())
        if (p != Particle.MOB_APPEARANCE)
            addItem(Material.REDSTONE, ChatColor.GREEN + Utils.capitalize(p.name()),
                    "Click here to activate this particle effect.")
                    .anyClick(e -> {
                        getPlayer().sendMessage(ChatColor.GREEN + "Activated " + Utils.capitalize(p.name()) + ".");
                        getWrapper().setEffect(p);
                        reconstruct();
                    }).setGlowing(p == effect);

    toRight(2);

    if (effect != null)
        addItem(Material.INK_SACK, ChatColor.RED + "Disable Particles", "Click here to disable your active effect.")
                .anyClick(e -> {
                    getWrapper().setEffect(null);
                    getPlayer().sendMessage(ChatColor.RED + "Particles disabled.");
                    reconstruct();
                });

    addBackButton();
}
项目:AsgardAscension    文件:RuneManager.java   
private void handleDetonate(Player player, Rune rune) {
    player.spawnParticle(Particle.EXPLOSION_HUGE, player.getLocation(), 1);
    player.playSound(player.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 1F, 1F);
    for(Entity entity : player.getNearbyEntities(3D, 3D, 3D)) {
        if(!(entity instanceof Player)) {
            continue;
        }
        Player target = (Player) entity;

        if(Utility.canAttack(player, target)) {
            if(target.getHealth() > 6) {
                target.setHealth(target.getHealth() - 6);
            }
            else {
                target.damage(1000000D, player);
            }
        }
    }
    finish(player, false);
}
项目:BukkitPluginDevelopment    文件:Main.java   
/**
 * パーティクルを発生させる
 * @param loc
 */
@SuppressWarnings("unused")
private void particle(Location loc) {
    //loc.getWorld().spawnParticle(Particle.VILLAGER_HAPPY, loc,10);
    /*
    loc.getWorld().spawnParticle(
            Particle.VILLAGER_HAPPY,
            loc,
            50,
            10, // 散開させるXの範囲
            10, // 散開させるYの範囲
            10 // 散開させるZの範囲
    );//*/
    //*
    loc.getWorld().spawnParticle(
            Particle.CLOUD,
            loc,
            500,
            10, // 散開させるXの範囲
            10, // 散開させるYの範囲
            10, // 散開させるZの範囲
            0.1 // 速度?
    );//*/
}
项目:WildernessTp    文件:CheckConfig.java   
public boolean checkParticle(){
    if(wild.getConfig().getBoolean("DoParticle")) {
        try {
            String[] tmp = Bukkit.getVersion().split("MC: ");
            String version = tmp[tmp.length - 1].substring(0, 3);
            Particle particle;
            Effect effect;
            if (version.equals("1.9") || version.equals("1.1"))
                particle = Particle.valueOf(wild.getConfig().getString("Particle").toUpperCase());
            else
                effect = Effect.valueOf(wild.getConfig().getString("Particle").toUpperCase());
        } catch (IllegalArgumentException e) {
            return false;
        }
    }else
        return true;
    return true;
}
项目:CraftoPlugin    文件:HealthRegionComponent.java   
@TaskHandler(name = "HealthRegionTask", delay = TASK_DELAY)
public void t() {
    WorldModule worldModule = this.module.getModule(WorldModule.class).orElse(null);
    if (worldModule == null) { debug("t", "Failed to find worldModule"); return; }

    if (!healthRegion.isPresent()) {
        if (searched) { debug("t", "Didnt find healthRegion in the past"); return; }

        Optional<Region> region = worldModule.getRegion(Utility.getMainWorld(), "health_region_1");
        if (region.isPresent()) { this.healthRegion = region; debug("t", "Found healthregion"); }
        else { searched = true; debug("t", "Failed to find healthregion"); return; }
    }

    Location3i minPos = healthRegion.get().getMinLoc();
    Location3i maxPos = healthRegion.get().getMaxLoc();

    int x = Utility.randomInt(minPos.getX(), maxPos.getX());
    int y = Utility.randomInt(minPos.getY(), maxPos.getY());
    int z = Utility.randomInt(minPos.getZ(), maxPos.getZ());

    debug("t", "x: " + x + ", y: " + y + ",  z: " + z);

    minPos.getWorld().spawnParticle(Particle.HEART, x, y, z, 1);
}
项目:CraftoPlugin    文件:ProtectionEffectListener.java   
void displayProt(final Player player, final Protection prot) {
    if (prot instanceof EntityProtection) {
        Optional<Entity> entity = ((EntityProtection) prot).getStoredEntity().getEntity();
        if (entity.isPresent()) {
            final Location loc = entity.get().getLocation();

            if (prot.getOwner().getUniqueId().equals(player.getUniqueId())) {
                player.spawnParticle(Particle.SPELL_INSTANT, loc.getBlockX() + 0.5, loc.getBlockX() + 0.5, loc.getBlockX() + 0.5, 10);
            }
            else {
                player.spawnParticle(Particle.SPELL_WITCH, loc.getBlockX() + 0.5, loc.getBlockY() + 0.5, loc.getBlockZ() + 0.5, 10);
            }

            return;
        }
    }

    if (prot.getOwner().getUniqueId().equals(player.getUniqueId())) {
        player.spawnParticle(Particle.SPELL_INSTANT, prot.getX() + 0.5, prot.getY() + 0.5, prot.getZ() + 0.5, 10);
    }
    else {
        player.spawnParticle(Particle.SPELL_WITCH, prot.getX() + 0.5, prot.getY() + 0.5, prot.getZ() + 0.5, 10);
    }
}
项目:SpigotSource    文件:CraftWorld.java   
@Override
public <T> void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data) {
    if (data != null && !particle.getDataType().isInstance(data)) {
        throw new IllegalArgumentException("data should be " + particle.getDataType() + " got " + data.getClass());
    }
    getHandle().sendParticles(
            null, // Sender
            CraftParticle.toNMS(particle), // Particle
            true, // Extended range
            x, y, z, // Position
            count,  // Count
            offsetX, offsetY, offsetZ, // Random offset
            extra, // Speed?
            CraftParticle.toData(particle, data)

    );

}
项目:SpigotSource    文件:CraftParticle.java   
public static int[] toData(Particle particle, Object obj) {
    if (particle.getDataType().equals(Void.class)) {
        return new int[0];
    }
    if (particle.getDataType().equals(ItemStack.class)) {
        if (obj == null) {
            return new int[]{0, 0};
        }
        ItemStack itemStack = (ItemStack) obj;
        return new int[]{itemStack.getType().getId(), itemStack.getDurability()};
    }
    if (particle.getDataType().equals(MaterialData.class)) {
        if (obj == null) {
            return new int[]{0};
        }
        MaterialData data = (MaterialData) obj;
        return new int[]{data.getItemTypeId() + ((int)(data.getData()) << 12)};
    }
    throw new IllegalArgumentException(particle.getDataType().toString());
}
项目:CaulCrafting    文件:CaulCraftSuccessEvent.java   
public CaulCraftSuccessEvent(CraftArray craft, Player player, Block cauldron, Particle particle, Sound sound) {
    this.craft = craft;
    this.player = player;
    this.cauldron = cauldron;
    this.particle = particle;
    this.setSound(sound);
}
项目:CaulCrafting    文件:CaulCraftFailEvent.java   
public CaulCraftFailEvent(ArrayList<ItemStack> items, Player player, Block cauldron, Particle particle, Sound sound) {
    this.setItems(items);
    this.setPlayer(player);
    this.setCauldron(cauldron);
    this.setParticle(particle);
    this.setSound(sound);
}
项目:AddGun    文件:StandardGun.java   
/**
 * Subclasses are encouraged to override this.
 * Default behavior is to eject off of what you are riding, play a sound and spawn particle.
 *
 * 
 * @param hitData Data matrix showing hit
 * @param hit What entity was hit
 * @param bullet The bullet data.
 */
public void preHit(HitDigest hitData, Entity hit, Projectile bullet, Bullet type) {
    Location end = hitData.hitLocation;
    World world = end.getWorld();
    hit.eject(); // eject the player
    hit.getPassengers().forEach(e -> e.eject()); // and ejects your passengers
    // make a new sound where it hits.
    world.playSound(end, Sound.ENTITY_FIREWORK_BLAST, 1.0f, 1.5f);
    // make a splash
    world.spawnParticle(Particle.SMOKE_NORMAL, end, 35, 0.1, 0.1, 0.1, 0.1);
}
项目:ProjectAres    文件:Utils.java   
public static void resetPlayer(Player player) {
    player.getInventory().clear();
    player.getInventory().setChestplate(new ItemBuilder().material(Material.ELYTRA).unbreakable(true).get());
    player.setGameMode(GameMode.ADVENTURE);
    player.setAllowFlight(player.hasPermission("lobby.fly"));
    player.setWalkSpeed(0.2f);
    player.setFlySpeed(0.1f);
    player.setPotionParticles(false);
    player.hideTitle();
    player.getWorld().spawnParticle(Particle.CLOUD, player.getLocation(), 15, 0.5, 0.5, 0.5, 0);
}
项目:MockBukkit    文件:WorldMock.java   
@Override
public void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY,
        double offsetZ)
{
    // TODO Auto-generated method stub
    throw new UnimplementedOperationException();
}
项目:MockBukkit    文件:WorldMock.java   
@Override
public void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX,
        double offsetY, double offsetZ)
{
    // TODO Auto-generated method stub
    throw new UnimplementedOperationException();
}
项目:MockBukkit    文件:WorldMock.java   
@Override
public <T> void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY,
        double offsetZ, T data)
{
    // TODO Auto-generated method stub
    throw new UnimplementedOperationException();
}
项目:MockBukkit    文件:WorldMock.java   
@Override
public <T> void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX,
        double offsetY, double offsetZ, T data)
{
    // TODO Auto-generated method stub
    throw new UnimplementedOperationException();
}
项目:MockBukkit    文件:WorldMock.java   
@Override
public void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY,
        double offsetZ, double extra)
{
    // TODO Auto-generated method stub
    throw new UnimplementedOperationException();
}
项目:MockBukkit    文件:WorldMock.java   
@Override
public void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX,
        double offsetY, double offsetZ, double extra)
{
    // TODO Auto-generated method stub
    throw new UnimplementedOperationException();
}
项目:MockBukkit    文件:WorldMock.java   
@Override
public <T> void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY,
        double offsetZ, double extra, T data)
{
    // TODO Auto-generated method stub
    throw new UnimplementedOperationException();
}
项目:MockBukkit    文件:WorldMock.java   
@Override
public <T> void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX,
        double offsetY, double offsetZ, double extra, T data)
{
    // TODO Auto-generated method stub
    throw new UnimplementedOperationException();
}
项目:MockBukkit    文件:PlayerMock.java   
@Override
public void spawnParticle(Particle particle, Location location, int count)
{
    // TODO Auto-generated method stub
    throw new UnimplementedOperationException();

}
项目:MockBukkit    文件:PlayerMock.java   
@Override
public void spawnParticle(Particle particle, double x, double y, double z, int count)
{
    // TODO Auto-generated method stub
    throw new UnimplementedOperationException();

}
项目:MockBukkit    文件:PlayerMock.java   
@Override
public <T> void spawnParticle(Particle particle, Location location, int count, T data)
{
    // TODO Auto-generated method stub
    throw new UnimplementedOperationException();

}
项目:MockBukkit    文件:PlayerMock.java   
@Override
public <T> void spawnParticle(Particle particle, double x, double y, double z, int count, T data)
{
    // TODO Auto-generated method stub
    throw new UnimplementedOperationException();

}
项目:MockBukkit    文件:PlayerMock.java   
@Override
public void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY,
        double offsetZ)
{
    // TODO Auto-generated method stub
    throw new UnimplementedOperationException();

}
项目:MockBukkit    文件:PlayerMock.java   
@Override
public void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX,
        double offsetY, double offsetZ)
{
    // TODO Auto-generated method stub
    throw new UnimplementedOperationException();

}
项目:MockBukkit    文件:PlayerMock.java   
@Override
public <T> void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY,
        double offsetZ, T data)
{
    // TODO Auto-generated method stub
    throw new UnimplementedOperationException();

}
项目:MockBukkit    文件:PlayerMock.java   
@Override
public <T> void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX,
        double offsetY, double offsetZ, T data)
{
    // TODO Auto-generated method stub
    throw new UnimplementedOperationException();

}
项目:MockBukkit    文件:PlayerMock.java   
@Override
public void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY,
        double offsetZ, double extra)
{
    // TODO Auto-generated method stub
    throw new UnimplementedOperationException();

}
项目:MockBukkit    文件:PlayerMock.java   
@Override
public void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX,
        double offsetY, double offsetZ, double extra)
{
    // TODO Auto-generated method stub
    throw new UnimplementedOperationException();

}
项目:MockBukkit    文件:PlayerMock.java   
@Override
public <T> void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY,
        double offsetZ, double extra, T data)
{
    // TODO Auto-generated method stub
    throw new UnimplementedOperationException();

}
项目:MockBukkit    文件:PlayerMock.java   
@Override
public <T> void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX,
        double offsetY, double offsetZ, double extra, T data)
{
    // TODO Auto-generated method stub
    throw new UnimplementedOperationException();

}
项目:MiniWynn    文件:BowListener.java   
@EventHandler(priority = EventPriority.HIGHEST)
public void on(ProjectileLaunchEvent event){
    Projectile projectile = event.getEntity();
    if(projectile instanceof Arrow && projectile.getShooter() instanceof Player){
        final Arrow arrow = (Arrow) projectile;
        final int task = server.getScheduler().scheduleSyncRepeatingTask(plugin, ()-> {
            arrow.getLocation().getWorld().spawnParticle(Particle.LAVA, arrow.getLocation(), 1);
        }, 0L, 1L);
        particleTasks.put(arrow, task);
    }
}
项目:Kineticraft    文件:ParticleUtils.java   
/**
 * Create a horizonal circle at the given location.
 * @param particle
 * @param center
 * @param radius
 */
public static void makeCircle(Particle particle, Location center, double radius) {
    int amount = 100;
    for(int i = 0; i < amount; i++) {
        double angle = i * ((2 * Math.PI) / amount);
        double x = center.getX() + (radius * Math.cos(angle));
        double z = center.getZ() + (radius * Math.sin(angle));
        center.getWorld().spawnParticle(particle, new Location(center.getWorld(), x, center.getY(), z), 1);
    }
}
项目:MT_Core    文件:GeneratorListener.java   
@EventHandler
public void onLeverOrButton(PlayerInteractEvent event) {
    Block clickedBlock = event.getClickedBlock();
    Player player = event.getPlayer();

    if (clickedBlock == null)
        return;

    String chunk = clickedBlock.getLocation().getChunk().getX() + ";"
            + clickedBlock.getLocation().getChunk().getZ();
    if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
        return;
    if (!powerable.containsKey(clickedBlock.getWorld().getName()))
        return;
    if (powerable.get(clickedBlock.getWorld().getName()).getList(chunk).contains(clickedBlock.getLocation()))
        return;

    // We cancel; send smoke particles for button, and we just turn off the
    // lever (if it was, for some reason, on).
    if (clickedBlock.getType() == Material.STONE_BUTTON || clickedBlock.getType() == Material.WOOD_BUTTON) {

        clickedBlock.getWorld().spawnParticle(Particle.SMOKE_NORMAL, clickedBlock.getLocation().add(0.5, 1, 0.5), 7,
                0, 0.2, 0, 0.03);
        player.sendMessage(MortuusTerraCore.NOTI_PREFIX + ChatColor.RED + " There is no generator in range!");

    } else if (clickedBlock.getType() == Material.LEVER) {
        BlockState state = clickedBlock.getState();
        Lever lever = (Lever) state.getData();

        lever.setPowered(false);
        state.setData(lever);
        state.update();
        clickedBlock.getWorld().spawnParticle(Particle.SMOKE_NORMAL, clickedBlock.getLocation().add(0.5, 1, 0.5), 7,
                0, 0.2, 0, 0.03);
        player.sendMessage(MortuusTerraCore.NOTI_PREFIX + ChatColor.RED + " There is no generator in range!");
    }

}
项目:MT_Core    文件:GeneratorListener.java   
@EventHandler
public void onPower(BlockRedstoneEvent event) {
    Block block = event.getBlock();
    String chunk = block.getLocation().getChunk().getX() + ";" + block.getLocation().getChunk().getZ();

    if (!powerable.get(block.getWorld().getName()).getList(chunk).contains(block.getLocation())) {
        block.getWorld().spawnParticle(Particle.SMOKE_NORMAL, block.getLocation().add(0.5, 1, 0.5), 7, 0, 0.2, 0,
                0.03);
        event.setNewCurrent(0);
    }
}
项目:MCLibrary    文件:ParticleHolder.java   
public ParticleHolder(Particle particle, int count, double offsetX, double offsetY, double offsetZ, double extra, D data) {
    this.particle = particle;
    this.count = count;
    this.offsetX = offsetX;
    this.offsetY = offsetY;
    this.offsetZ = offsetZ;
    this.extra = extra;
    this.data = data;
}