ProjectileSources now take EntityTypes instead of Projectile class
package org.spongepowered.api.projectile.source;
import org.spongepowered.api.entity.Entity;
+import org.spongepowered.api.entity.EntityType;
import org.spongepowered.api.entity.projectile.Projectile;
import org.spongepowered.math.vector.Vector3d;
import java.util.Optional;
+import java.util.function.Supplier;
/**
* Represents a valid source of a projectile.
/**
* Launches a {@link Projectile} from this projectile source.
*
- * @param projectileClass The class of the projectile
+ * @param projectileType The class of the projectile
* @param <T> The Type of Projectile
* @return The projectile instance if it was launched, or absent
*/
- <T extends Projectile> Optional<T> launchProjectile(Class<T> projectileClass);
+ <T extends Projectile> Optional<T> launchProjectile(EntityType<T> projectileType);
/**
* Launches a {@link Projectile} from this projectile source.
*
- * @param projectileClass The class of the projectile
+ * @param projectileType The class of the projectile
+ * @param <T> The Type of Projectile
+ * @return The projectile instance if it was launched, or absent
+ */
+ default <T extends Projectile> Optional<T> launchProjectile(Supplier<EntityType<T>> projectileType) {
+ return this.launchProjectile(projectileType.get());
+ }
+
+ /**
+ * Launches a {@link Projectile} from this projectile source.
+ *
+ * @param projectileType The class of the projectile
* @param velocity The velocity to launch the projectile
* @param <T> The Type of Projectile
* @return The projectile instance if it was launched, or absent
*/
- <T extends Projectile> Optional<T> launchProjectile(Class<T> projectileClass, Vector3d velocity);
+ <T extends Projectile> Optional<T> launchProjectile(EntityType<T> projectileType, Vector3d velocity);
+
+ /**
+ * Launches a {@link Projectile} from this projectile source.
+ *
+ * @param projectileType The class of the projectile
+ * @param velocity The velocity to launch the projectile
+ * @param <T> The Type of Projectile
+ * @return The projectile instance if it was launched, or absent
+ */
+ default <T extends Projectile> Optional<T> launchProjectile(Supplier<EntityType<T>> projectileType, Vector3d velocity) {
+ return this.launchProjectile(projectileType.get(), velocity);
+ }
/**
* Launches a new {@link Projectile} from this projectile source.
*
- * @param projectileClass The class of the projectile
+ * @param projectileType The class of the projectile
* @param <T> The Type of Projectile
* @param target the target to launch the projectile at
*
* @return the projectile if successfully launched, {@link Optional#empty()} otherwise
*/
- <T extends Projectile> Optional<T> launchProjectileTo(Class<T> projectileClass, Entity target);
+ <T extends Projectile> Optional<T> launchProjectileTo(EntityType<T> projectileType, Entity target);
+
+ /**
+ * Launches a new {@link Projectile} from this projectile source.
+ *
+ * @param projectileType The class of the projectile
+ * @param <T> The Type of Projectile
+ * @param target the target to launch the projectile at
+ *
+ * @return the projectile if successfully launched, {@link Optional#empty()} otherwise
+ */
+ default <T extends Projectile> Optional<T> launchProjectileTo(Supplier<EntityType<T>> projectileType, Entity target) {
+ return this.launchProjectileTo(projectileType.get(), target);
+ }
}
