/** * Extending Effect classes should use this method to obtain the * current "target" Location of the effect. * * Unlike getLocation, this may return null. */ public final Location getTarget() { return target == null ? null : target.getLocation(); }
/** * Extending Effect classes should use this method to obtain the * current "root" Location of the effect. * * This method will not return null when called from onRun. Effects * with invalid locations will be cancelled. */ public final Location getLocation() { return origin == null ? null : origin.getLocation(); }
@Nullable public Location getOrigin() { return origin == null ? null : origin.getLocation(); }
@Nullable public Location getTarget() { return target == null ? null : target.getLocation(); }
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()); } }
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()); } }
public void startEffects(DynamicLocation origin, DynamicLocation target) { 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());
protected final boolean validate() { // Check if the origin and target entities are present if (disappearWithOriginEntity && (origin != null && !origin.hasValidEntity())) { return false; } if (disappearWithTargetEntity && (target != null && !target.hasValidEntity())) { return false; } // Check for a valid Location updateLocation(); updateTarget(); Location location = getLocation(); if (location == null) { return false; } if (autoOrient) { Location targetLocation = target == null ? null : target.getLocation(); if (targetLocation != null) { Vector direction = targetLocation.toVector().subtract(location.toVector()); location.setDirection(direction); targetLocation.setDirection(direction.multiply(-1)); } } return true; }
@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();