2023-03-16 02:51:40 -05:00
|
|
|
package noppes.npcs.scripted.event;
|
|
|
|
|
|
2023-12-31 16:10:38 -05:00
|
|
|
import noppes.npcs.api.IBlock;
|
|
|
|
|
import noppes.npcs.api.entity.IEntity;
|
2023-03-16 02:51:40 -05:00
|
|
|
import noppes.npcs.api.entity.IProjectile;
|
2023-12-31 16:10:38 -05:00
|
|
|
import noppes.npcs.api.event.IProjectileEvent;
|
2023-03-16 02:51:40 -05:00
|
|
|
|
2024-08-22 16:47:45 -04:00
|
|
|
public class ProjectileEvent extends CustomNPCsEvent implements IProjectileEvent {
|
2023-03-16 02:51:40 -05:00
|
|
|
public IProjectile projectile;
|
2023-12-31 16:10:38 -05:00
|
|
|
public IEntity source;
|
2023-03-16 02:51:40 -05:00
|
|
|
|
|
|
|
|
public ProjectileEvent(IProjectile projectile) {
|
|
|
|
|
this.projectile = projectile;
|
2023-12-31 16:10:38 -05:00
|
|
|
this.source = projectile.getThrower();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IProjectile getProjectile() {
|
|
|
|
|
return projectile;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IEntity getSource() {
|
|
|
|
|
return source;
|
2023-03-16 02:51:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* projectileTick
|
|
|
|
|
*/
|
2023-12-31 16:10:38 -05:00
|
|
|
public static class UpdateEvent extends ProjectileEvent implements IProjectileEvent.UpdateEvent {
|
2023-03-16 02:51:40 -05:00
|
|
|
public UpdateEvent(IProjectile projectile) {
|
|
|
|
|
super(projectile);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* projectileImpact
|
|
|
|
|
*/
|
2025-03-13 17:14:45 -04:00
|
|
|
public static class ImpactEvent extends ProjectileEvent implements IProjectileEvent.ImpactEvent {
|
2023-03-16 02:51:40 -05:00
|
|
|
/**
|
|
|
|
|
* 0:entity, 1:block
|
|
|
|
|
*/
|
|
|
|
|
public final int type;
|
|
|
|
|
public final Object target;
|
|
|
|
|
|
|
|
|
|
public ImpactEvent(IProjectile projectile, int type, Object target) {
|
|
|
|
|
super(projectile);
|
|
|
|
|
this.type = type;
|
|
|
|
|
this.target = target;
|
|
|
|
|
}
|
2023-12-31 16:10:38 -05:00
|
|
|
|
|
|
|
|
public int getType() {
|
|
|
|
|
return type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IEntity getEntity() {
|
2025-03-13 17:14:45 -04:00
|
|
|
if (type == 0)
|
2023-12-31 16:10:38 -05:00
|
|
|
return (IEntity) target;
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IBlock getBlock() {
|
2025-03-13 17:14:45 -04:00
|
|
|
if (type == 1)
|
2023-12-31 16:10:38 -05:00
|
|
|
return (IBlock) target;
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2023-03-16 02:51:40 -05:00
|
|
|
}
|
|
|
|
|
}
|