Search in sources :

Example 1 with PlayParticleMessage

use of net.glowstone.net.message.play.game.PlayParticleMessage in project Glowstone by GlowstoneMC.

the class GlowPlayer method spawnParticle.

@Override
public <T> void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, double offsetZ, double extra, T data) {
    double distance = getLocation().distanceSquared(location);
    boolean isLongDistance = GlowParticle.isLongDistance(particle);
    int particleId = GlowParticle.getId(particle);
    Object[] particleData = GlowParticle.getExtData(particle, data);
    if (distance <= 1024.0D || isLongDistance && distance <= 262144.0D) {
        getSession().send(new PlayParticleMessage(particleId, isLongDistance, location.getX(), location.getY(), location.getZ(), (float) offsetX, (float) offsetY, (float) offsetZ, (float) extra, count, particleData));
    }
}
Also used : PlayParticleMessage(net.glowstone.net.message.play.game.PlayParticleMessage) JSONObject(org.json.simple.JSONObject)

Example 2 with PlayParticleMessage

use of net.glowstone.net.message.play.game.PlayParticleMessage in project Glowstone by GlowstoneMC.

the class GlowPlayer method showParticle.

/**
 * Sends a {@link PlayParticleMessage} to display the given particle.
 *
 * @param loc      the location
 * @param particle the particle type
 * @param material the item or block data
 * @param offsetX  TODO: document this parameter
 * @param offsetY  TODO: document this parameter
 * @param offsetZ  TODO: document this parameter
 * @param speed    TODO: document this parameter
 * @param amount   the number of particles
 */
// @Override
public void showParticle(Location loc, Effect particle, MaterialData material, float offsetX, float offsetY, float offsetZ, float speed, int amount) {
    if (location == null || particle == null || particle.getType() != Type.VISUAL) {
        return;
    }
    int id = GlowParticle.getId(particle);
    boolean longDistance = GlowParticle.isLongDistance(particle);
    float x = (float) loc.getX();
    float y = (float) loc.getY();
    float z = (float) loc.getZ();
    Object[] extData = GlowParticle.getExtData(particle, material);
    session.send(new PlayParticleMessage(id, longDistance, x, y, z, offsetX, offsetY, offsetZ, speed, amount, extData));
}
Also used : PlayParticleMessage(net.glowstone.net.message.play.game.PlayParticleMessage) JSONObject(org.json.simple.JSONObject)

Aggregations

PlayParticleMessage (net.glowstone.net.message.play.game.PlayParticleMessage)2 JSONObject (org.json.simple.JSONObject)2