Melee Swing Event

This commit is contained in:
Kam committed 2024-02-12 02:56:11 -05:00
1 parent 4f697e574e
commit 1393de181d
4 files changed
+33

No files matched your search

@@ -179,6 +179,15 @@ public class EventHooks {
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onNPCMeleeSwing(EntityNPCInterface npc, NpcEvent.SwingEvent event){
if(npc == null || npc.wrappedNPC == null)
return false;
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.ATTACK_SWING, event);
npc.script.callScript(EnumScriptType.ATTACK_SWING, event);
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onNPCRangedAttack(EntityNPCInterface npc, NpcEvent.RangedLaunchedEvent event){
if(npc == null || npc.wrappedNPC == null)
return false;
@@ -23,6 +23,7 @@ public class GuiNPCEventScripts extends GuiScriptInterface {
hookList.add("damaged");
hookList.add("killed");
hookList.add("meleeAttack");
hookList.add("meleeSwing");
hookList.add("rangedLaunched");
hookList.add("target");
hookList.add("collide");
@@ -19,6 +19,7 @@ public enum EnumScriptType {
ATTACKED("attacked"),
ATTACK_MELEE("meleeAttack"),
ATTACK_SWING("meleeSwing"),
ROLE("role"),
RANGED_CHARGE("rangedCharge"),
RANGED_LAUNCHED("rangedLaunched"),
@@ -226,6 +226,28 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent {
}
}
@Cancelable
public static class SwingEvent extends NpcEvent implements INpcEvent.SwingEvent {
public final IItemStack itemStack;
public SwingEvent(ICustomNpc npc, ItemStack itemStack) {
super(npc);
this.itemStack = (IItemStack)NpcAPI.Instance().getIItemStack(itemStack);
}
public String getHookName() {
return EnumScriptType.ATTACK_SWING.function;
}
/**
* @return Returns the swung item
*/
@Override
public IItemStack getItemStack() {
return itemStack;
}
}
public static class KilledEntityEvent extends NpcEvent implements INpcEvent.KilledEntityEvent {
public final IEntityLivingBase entity;