use of de.slikey.effectlib.util.DynamicLocation in project MagicPlugin by elBukkit.
the class EffectTrail method iterate.
@Override
public void iterate() {
Location origin = getOrigin();
Location target = getTarget();
if (origin == null)
return;
Vector delta = direction.clone();
Location source = origin.clone();
if (playAtOrigin) {
source.add(delta.multiply(scale(size) + 1));
}
if (target != null && playAtTarget) {
target = target.clone();
target.add(delta.multiply(-scale(size) + 1));
}
playEffect(new DynamicLocation(source, getOriginEntity()), new DynamicLocation(target, getTargetEntity()));
}
use of de.slikey.effectlib.util.DynamicLocation in project MagicPlugin by elBukkit.
the class EffectTransform method iterateSteps.
public void iterateSteps(Location originalOrigin, Location originalTarget) {
for (int i = 0; i < steps; i++) {
Location source = originalOrigin;
Location target = originalTarget;
if (playAtOrigin) {
source = source.clone();
source.add(positionTransform.get(source, totalSteps));
}
if (target != null && playAtTarget) {
target = target.clone();
target.add(positionTransform.get(target, totalSteps));
}
playEffect(new DynamicLocation(source, getOriginEntity()), new DynamicLocation(target, getTargetEntity()));
totalSteps++;
if (maxStep > 0 && totalSteps >= maxStep) {
totalSteps = 0;
}
}
}
use of de.slikey.effectlib.util.DynamicLocation in project MagicPlugin by elBukkit.
the class EffectPlayer method startEffects.
public void startEffects(DynamicLocation origin, DynamicLocation target) {
// Kinda hacky, but makes cross-world trails (e.g. Repair, Backup) work
Location targetLocation = target == null ? null : target.getLocation();
Location originLocation = origin == null ? null : origin.getLocation();
if (targetLocation != null && originLocation != null && !originLocation.getWorld().equals(targetLocation.getWorld())) {
targetLocation.setWorld(originLocation.getWorld());
}
this.origin = origin;
this.target = target;
if (originRelativeOffset != null && this.origin != null) {
this.origin.addRelativeOffset(originRelativeOffset);
}
if (targetRelativeOffset != null && this.target != null) {
this.target.addRelativeOffset(targetRelativeOffset);
}
if (hasFirework) {
fireworkEffect = getFireworkEffect(getColor1(), getColor2(), fireworkType, fireworkFlicker, false);
} else {
fireworkEffect = null;
}
// Should I let EffectLib handle delay?
if (delayTicks > 0 && plugin != null) {
final EffectPlayer player = this;
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
player.startPlay();
}
}, delayTicks);
} else {
startPlay();
}
}
use of de.slikey.effectlib.util.DynamicLocation in project MagicPlugin by elBukkit.
the class CustomProjectileAction method startProjectileEffects.
protected void startProjectileEffects(CastContext context, String effectKey) {
Collection<EffectPlayer> projectileEffects = context.getEffects(effectKey);
for (EffectPlayer apiEffectPlayer : projectileEffects) {
if (effectLocation == null) {
effectLocation = new DynamicLocation(actionContext.getTargetLocation());
effectLocation.setDirection(velocity);
}
if (activeProjectileEffects == null) {
activeProjectileEffects = new ArrayList<>();
}
// Hrm- this is ugly, but I don't want the API to depend on EffectLib.
if (apiEffectPlayer instanceof com.elmakers.mine.bukkit.effect.EffectPlayer) {
com.elmakers.mine.bukkit.effect.EffectPlayer effectPlayer = (com.elmakers.mine.bukkit.effect.EffectPlayer) apiEffectPlayer;
effectPlayer.setEffectPlayList(activeProjectileEffects);
effectPlayer.startEffects(effectLocation, null);
}
}
}
use of de.slikey.effectlib.util.DynamicLocation in project MagicPlugin by elBukkit.
the class EffectPlayer method start.
public void start(Location origin, Entity originEntity, Collection<Entity> targets) {
if (targets == null || targets.size() == 0)
return;
DynamicLocation source = new DynamicLocation(origin, originEntity);
for (Entity targetEntity : targets) {
if (targetEntity == null)
continue;
// This is not really going to work out well for any Effect type but Single!
// TODO : Perhaps re-visit?
DynamicLocation target = new DynamicLocation(targetEntity);
startEffects(source, target);
}
}
Aggregations