Implemented Global NPC Events!

All NPCs activate these scripts. If a player wants to create a script that's universally used by all NPCs, this allows for that to happen with a lot of ease!
This commit is contained in:
Luis C.M committed 2022-03-23 03:54:06 -05:00
1 parent 092592bd27
commit 18ff2bff78
15 files changed
+562 -38

No files matched your search

@@ -10,6 +10,7 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.DamageSource;
import noppes.npcs.controllers.Dialog;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.interfaces.*;
@@ -51,6 +52,10 @@ public class NpcEvent extends CustomNPCsEvent {
this.damage = damage;
this.damageSource = NpcAPI.Instance().getIDamageSource(damagesource);
}
public String getType(){
return damageSource.getMCDamageSource().damageType;
}
}
public static class RangedLaunchedEvent extends NpcEvent {
@@ -58,7 +63,7 @@ public class NpcEvent extends CustomNPCsEvent {
public float damage;
//public List<IProjectile> projectiles = new ArrayList();
public RangedLaunchedEvent(ICustomNpc npc, EntityLivingBase target, float damage) {
public RangedLaunchedEvent(ICustomNpc npc, float damage, EntityLivingBase target) {
super(npc);
this.target = (IEntityLivingBase)NpcAPI.Instance().getIEntity(target);
this.damage = damage;
@@ -70,7 +75,7 @@ public class NpcEvent extends CustomNPCsEvent {
public final IEntityLivingBase target;
public float damage;
public MeleeAttackEvent(ICustomNpc npc, EntityLivingBase target, float damage) {
public MeleeAttackEvent(ICustomNpc npc, float damage, EntityLivingBase target) {
super(npc);
this.target = (IEntityLivingBase)NpcAPI.Instance().getIEntity(target);
this.damage = damage;
@@ -99,6 +104,10 @@ public class NpcEvent extends CustomNPCsEvent {
this.type = damagesource.damageType;
this.source = NpcAPI.Instance().getIEntity(entity);
}
public String getType(){
return damageSource.getMCDamageSource().damageType;
}
}
@Cancelable
@@ -111,6 +120,34 @@ public class NpcEvent extends CustomNPCsEvent {
}
}
public static class DialogEvent extends NpcEvent {
public final IPlayer player;
public final int id;
public final Dialog dialog;
public DialogEvent(ICustomNpc npc, EntityPlayer player, int id, Dialog dialog) {
super(npc);
this.player = (IPlayer)NpcAPI.Instance().getIEntity(player);
this.id = id;
this.dialog = dialog;
}
}
public static class DialogClosedEvent extends NpcEvent {
public final IPlayer player;
public final int id;
public final int optionId;
public final Dialog dialog;
public DialogClosedEvent(ICustomNpc npc, EntityPlayer player, int id, int optionId, Dialog dialog) {
super(npc);
this.player = (IPlayer)NpcAPI.Instance().getIEntity(player);
this.id = id;
this.optionId = optionId;
this.dialog = dialog;
}
}
@Cancelable
public static class TargetLostEvent extends NpcEvent {
public final IEntityLivingBase entity;