Files
CustomNPC-Plus/src/main/java/noppes/npcs/scripted/event/ProjectileEvent.java
T

66 lines
1.6 KiB
Java
Raw Normal View History

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-05-26 19:26:47 -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
*/
2023-12-31 16:10:38 -05: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() {
if(type == 0)
return (IEntity) target;
return null;
}
public IBlock getBlock() {
if(type == 1)
return (IBlock) target;
return null;
}
2023-03-16 02:51:40 -05:00
}
}