Search in sources :

Example 6 with DynamicLocation

use of de.slikey.effectlib.util.DynamicLocation in project MagicPlugin by elBukkit.

the class EffectPlayer method performEffects.

@SuppressWarnings("deprecation")
protected void performEffects(DynamicLocation source, DynamicLocation target) {
    Location sourceLocation = source == null ? null : source.getLocation();
    if (sourceLocation == null)
        return;
    Entity sourceEntity = source == null ? null : source.getEntity();
    if (requireEntity && sourceEntity == null)
        return;
    if (effectLib != null && effectLibConfig != null) {
        EffectLibPlay play = new EffectLibPlay(effectLib.play(effectLibConfig, this, source, target, parameterMap));
        if (currentEffects != null) {
            currentEffects.add(play);
        }
    }
    if (effect != null) {
        int data = effectData == null ? 0 : effectData;
        if ((effect == Effect.STEP_SOUND) && effectData == null) {
            Material material = getWorkingMaterial().getMaterial();
            // Check for potential bad materials, this can get really hairy (client crashes)
            if (!material.isSolid()) {
                return;
            }
            data = material.getId();
        }
        sourceLocation.getWorld().playEffect(sourceLocation, effect, data);
    }
    if (entityEffect != null && sourceEntity != null) {
        sourceEntity.playEffect(entityEffect);
    }
    if (sound != null) {
        if (broadcastSound) {
            sound.play(plugin, sourceLocation);
        } else if (sourceEntity != null) {
            sound.play(plugin, sourceEntity);
        }
    }
    if (fireworkEffect != null) {
        EffectUtils.spawnFireworkEffect(plugin.getServer(), sourceLocation, fireworkEffect, fireworkPower, fireworkSilent);
    }
    if (particleType != null) {
        ParticleEffect useEffect = overrideParticle(particleType);
        Material material = getWorkingMaterial().getMaterial();
        Byte blockData = getWorkingMaterial().getBlockData();
        ParticleEffect.ParticleData data = useEffect.getData(material, blockData);
        if (data != null) {
            try {
                useEffect.display(data, sourceLocation, getColor1(), PARTICLE_RANGE, particleXOffset, particleYOffset, particleZOffset, particleData, particleCount);
            } catch (Exception ex) {
                if (effectLib.isDebugEnabled()) {
                    ex.printStackTrace();
                }
            }
        } else {
            if (!useEffect.requiresData()) {
                try {
                    useEffect.display(data, sourceLocation, getColor1(), PARTICLE_RANGE, particleXOffset, particleYOffset, particleZOffset, particleData, particleCount);
                } catch (Exception ex) {
                    if (effectLib.isDebugEnabled()) {
                        ex.printStackTrace();
                    }
                }
            }
        }
    }
}
Also used : ParticleEffect(de.slikey.effectlib.util.ParticleEffect) Entity(org.bukkit.entity.Entity) Material(org.bukkit.Material) Location(org.bukkit.Location) SourceLocation(com.elmakers.mine.bukkit.magic.SourceLocation) DynamicLocation(de.slikey.effectlib.util.DynamicLocation)

Example 7 with DynamicLocation

use of de.slikey.effectlib.util.DynamicLocation in project MagicPlugin by elBukkit.

the class EffectPlayer method setTarget.

public void setTarget(Location location) {
    if (target == null) {
        target = new DynamicLocation(location);
    } else {
        Location targetLocation = target.getLocation();
        targetLocation.setX(location.getX());
        targetLocation.setY(location.getY());
        targetLocation.setZ(location.getZ());
    }
}
Also used : DynamicLocation(de.slikey.effectlib.util.DynamicLocation) Location(org.bukkit.Location) SourceLocation(com.elmakers.mine.bukkit.magic.SourceLocation) DynamicLocation(de.slikey.effectlib.util.DynamicLocation)

Example 8 with DynamicLocation

use of de.slikey.effectlib.util.DynamicLocation in project MagicPlugin by elBukkit.

the class EffectPlayer method setOrigin.

public void setOrigin(Location location) {
    if (origin == null) {
        origin = new DynamicLocation(location);
    } else {
        Location originLocation = origin.getLocation();
        originLocation.setX(location.getX());
        originLocation.setY(location.getY());
        originLocation.setZ(location.getZ());
    }
}
Also used : DynamicLocation(de.slikey.effectlib.util.DynamicLocation) Location(org.bukkit.Location) SourceLocation(com.elmakers.mine.bukkit.magic.SourceLocation) DynamicLocation(de.slikey.effectlib.util.DynamicLocation)

Example 9 with DynamicLocation

use of de.slikey.effectlib.util.DynamicLocation in project MagicPlugin by elBukkit.

the class EffectRing method iterate.

@Override
public void iterate() {
    Location origin = getOrigin();
    if (origin == null)
        return;
    float currentRadius = scale(radius * scale);
    // Randomization
    double startRadians = Math.random() * Math.PI * 2;
    for (int i = 0; i < size; i++) {
        double radians = (double) i / size * Math.PI * 2 + startRadians;
        Vector direction = new Vector(Math.cos(radians) * currentRadius, 0, Math.sin(radians) * currentRadius);
        Location source = origin;
        Location target = getTarget();
        if (playAtOrigin) {
            source = source.clone();
            source.add(direction);
        }
        if (target != null && playAtTarget) {
            target = target.clone();
            target.add(direction);
        }
        playEffect(new DynamicLocation(source, getOriginEntity()), new DynamicLocation(target, getTargetEntity()));
    }
}
Also used : Vector(org.bukkit.util.Vector) DynamicLocation(de.slikey.effectlib.util.DynamicLocation) DynamicLocation(de.slikey.effectlib.util.DynamicLocation) Location(org.bukkit.Location)

Example 10 with DynamicLocation

use of de.slikey.effectlib.util.DynamicLocation in project MagicPlugin by elBukkit.

the class EffectTransform method iterate.

@Override
public void iterate() {
    if (positionTransform == null) {
        playEffect();
        return;
    }
    Location origin = getOrigin();
    Location target = getTarget();
    if (origin == null)
        return;
    if (steps > 0) {
        iterateSteps(origin, target);
        return;
    }
    Location source = origin;
    double t = (double) playTime / 1000;
    if (playAtOrigin) {
        source = source.clone();
        source.add(positionTransform.get(source, t));
    }
    if (target != null && playAtTarget) {
        target = target.clone();
        target.add(positionTransform.get(target, t));
    }
    long now = System.currentTimeMillis();
    playTime += (now - lastIteration);
    lastIteration = now;
    playEffect(new DynamicLocation(source, getOriginEntity()), new DynamicLocation(target, getTargetEntity()));
}
Also used : DynamicLocation(de.slikey.effectlib.util.DynamicLocation) DynamicLocation(de.slikey.effectlib.util.DynamicLocation) Location(org.bukkit.Location)

Aggregations

DynamicLocation (de.slikey.effectlib.util.DynamicLocation)10 Location (org.bukkit.Location)8 SourceLocation (com.elmakers.mine.bukkit.magic.SourceLocation)4 Entity (org.bukkit.entity.Entity)2 Vector (org.bukkit.util.Vector)2 EffectPlayer (com.elmakers.mine.bukkit.api.effect.EffectPlayer)1 ParticleEffect (de.slikey.effectlib.util.ParticleEffect)1 Material (org.bukkit.Material)1