net.minestom.server.event.entity.EntityShootEvent Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of minestom-snapshots Show documentation
Show all versions of minestom-snapshots Show documentation
1.20.4 Lightweight Minecraft server
package net.minestom.server.event.entity;
import net.minestom.server.coordinate.Point;
import net.minestom.server.entity.Entity;
import net.minestom.server.entity.EntityProjectile;
import net.minestom.server.event.trait.CancellableEvent;
import net.minestom.server.event.trait.EntityInstanceEvent;
import org.jetbrains.annotations.NotNull;
/**
* Called with {@link EntityProjectile#shoot(Point, double, double)}
*/
public class EntityShootEvent implements EntityInstanceEvent, CancellableEvent {
private final Entity entity;
private final Entity projectile;
private final Point to;
private double power;
private double spread;
private boolean cancelled;
public EntityShootEvent(@NotNull Entity entity, @NotNull Entity projectile, @NotNull Point to, double power, double spread) {
this.entity = entity;
this.projectile = projectile;
this.to = to;
this.power = power;
this.spread = spread;
}
/**
* Gets the projectile.
*
* @return the projectile.
*/
public Entity getProjectile() {
return this.projectile;
}
/**
* Gets the position projectile was shot to.
*
* @return the position projectile was shot to.
*/
public Point getTo() {
return this.to;
}
/**
* Gets shot spread.
*
* @return shot spread.
*/
public double getSpread() {
return this.spread;
}
/**
* Sets shot spread.
*
* @param spread shot spread.
*/
public void setSpread(double spread) {
this.spread = spread;
}
/**
* Gets shot power.
*
* @return shot power.
*/
public double getPower() {
return this.power;
}
/**
* Sets shot power.
*
* @param power shot power.
*/
public void setPower(double power) {
this.power = power;
}
@Override
public boolean isCancelled() {
return this.cancelled;
}
@Override
public void setCancelled(boolean cancel) {
this.cancelled = cancel;
}
@Override
public @NotNull Entity getEntity() {
return entity;
}
}