Java Code Examples for org.bukkit.Particle#DustOptions

The following examples show how to use org.bukkit.Particle#DustOptions . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ParticleDisplay.java    From XSeries with MIT License 6 votes vote down vote up
/**
 * Displays the particle in the specified location.
 * This method does not support rotations if used directly.
 *
 * @param loc the location to display the particle at.
 * @see #spawn(double, double, double)
 * @since 2.1.0
 */
public void spawn(@Nonnull Location loc, boolean rotate) {
    if (rotate) loc = rotate(location, loc.getX(), loc.getY(), loc.getZ(), rotation);
    if (data != null) {
        if (data instanceof float[]) {
            float[] datas = (float[]) data;
            if (ISFLAT) {
                Particle.DustOptions dust = new Particle.DustOptions(org.bukkit.Color
                        .fromRGB((int) datas[0], (int) datas[1], (int) datas[2]), datas[3]);
                loc.getWorld().spawnParticle(particle, loc, count, offsetx, offsety, offsetz, extra, dust);
            } else {
                loc.getWorld().spawnParticle(particle, loc, count, (int) datas[0], (int) datas[1], (int) datas[2], datas[3]);
            }
        }
    } else {
        loc.getWorld().spawnParticle(particle, loc, count, offsetx, offsety, offsetz, extra);
    }
}
 
Example 2
Source File: XParticle.java    From XSeries with MIT License 5 votes vote down vote up
/**
 * Display a rendered image repeatedly.
 *
 * @param render   the rendered image map.
 * @param location the dynamic location to display the image at.
 * @param quality  the quality of the image is exactly the number of particles display for each pixel. Recommended value is 1
 * @param speed    the speed is exactly the same value as the speed of particles. Recommended amount is 0
 * @param size     the size of the particle. Recommended amount is 0.8
 * @since 1.0.0
 */
public static void displayRenderedImage(Map<Location, Color> render, Location location, int quality, int speed, float size) {
    for (Map.Entry<Location, Color> pixel : render.entrySet()) {
        Particle.DustOptions data = new Particle.DustOptions(pixel.getValue(), size);
        Location pixelLoc = pixel.getKey();

        Location loc = new Location(location.getWorld(), location.getX() - pixelLoc.getX(),
                location.getY() - pixelLoc.getY(), location.getZ() - pixelLoc.getZ());
        loc.getWorld().spawnParticle(Particle.REDSTONE, loc, quality, 0, 0, 0, speed, data);
    }
}
 
Example 3
Source File: ParticleDisplay_13.java    From EffectLib with MIT License 5 votes vote down vote up
@Override
public void display(Particle particle, Location center, float offsetX, float offsetY, float offsetZ, float speed, int amount, float size, Color color, Material material, byte materialData, double range, List<Player> targetPlayers) {
    // Legacy colorizeable particles
    if (color != null && (particle == Particle.SPELL_MOB || particle == Particle.SPELL_MOB_AMBIENT)) {
        displayLegacyColored(particle, center, speed, color, range, targetPlayers);
        return;
    }

    if (particle == Particle.ITEM_CRACK) {
        displayItem(particle, center, offsetX, offsetY, offsetZ, speed, amount, material, materialData, range, targetPlayers);
        return;
    }

    Object data = null;
    if (particle == Particle.BLOCK_CRACK || particle == Particle.BLOCK_DUST || particle == Particle.FALLING_DUST) {
        if (material == null || material == Material.AIR) {
            return;
        }
        data = material.createBlockData();
        if (data == null) {
            return;
        }
    }

    if (particle == Particle.REDSTONE) {
        // color is required for 1.13
        if (color == null) {
            color = Color.RED;
        }
        data = new Particle.DustOptions(color, size);
    }

    display(particle, center, offsetX, offsetY, offsetZ, speed, amount, data, range, targetPlayers);
}
 
Example 4
Source File: XParticle.java    From XSeries with MIT License 2 votes vote down vote up
/**
 * Generate a random colorized dust with a random size.
 *
 * @return a REDSTONE colored dust.
 * @since 1.0.0
 */
public static Particle.DustOptions randomDust() {
    float size = randInt(5, 10) / 0.1f;
    return new Particle.DustOptions(randomColor(), size);
}