mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-16 17:44:46 +00:00
Merged local and global NPC events, deleting old unused event classes.
This commit is contained in:
1 parent
8f16e6b20f
commit
9c29aabea8
11 files changed
+132
-350
No files matched your search
@@ -121,7 +121,7 @@ public class EventHooks {
|
||||
|
||||
noppes.npcs.scripted.event.NpcEvent.InitEvent event = new noppes.npcs.scripted.event.NpcEvent.InitEvent(npc.wrappedNPC);
|
||||
ScriptController.Instance.npcScripts.callScript(EnumScriptType.INIT, event);
|
||||
npc.script.callScript(EnumScriptType.INIT);
|
||||
npc.script.callScript(EnumScriptType.INIT, event);
|
||||
NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ public class EventHooks {
|
||||
|
||||
noppes.npcs.scripted.event.NpcEvent.UpdateEvent event = new noppes.npcs.scripted.event.NpcEvent.UpdateEvent(npc.wrappedNPC);
|
||||
ScriptController.Instance.npcScripts.callScript(EnumScriptType.TICK, event);
|
||||
npc.script.callScript(EnumScriptType.TICK);
|
||||
npc.script.callScript(EnumScriptType.TICK, event);
|
||||
NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
@@ -141,9 +141,7 @@ public class EventHooks {
|
||||
|
||||
NpcEvent.DialogEvent event = new NpcEvent.DialogEvent(npc.wrappedNPC, player, dialogId, optionId, dialog);
|
||||
ScriptController.Instance.npcScripts.callScript(EnumScriptType.DIALOG, event);
|
||||
|
||||
ScriptEventDialog npcEvent = new ScriptEventDialog(player,dialogId,optionId,dialog);
|
||||
npc.script.callScript(EnumScriptType.DIALOG, "event", npcEvent, "player", npcEvent.getPlayer(), "dialog", npcEvent.getDialogId(), "option", npcEvent.getOptionId(), "dialogObj", npcEvent.getDialog());
|
||||
npc.script.callScript(EnumScriptType.DIALOG, event, "player", event.getPlayer(), "dialog", event.getDialogId(), "option", event.getOptionId(), "dialogObj", event.getDialog());
|
||||
|
||||
NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
@@ -154,9 +152,7 @@ public class EventHooks {
|
||||
|
||||
NpcEvent.DialogClosedEvent event = new NpcEvent.DialogClosedEvent(npc.wrappedNPC, player, dialogId, optionId, dialog);
|
||||
ScriptController.Instance.npcScripts.callScript(EnumScriptType.DIALOG_CLOSE, event);
|
||||
|
||||
ScriptEventDialog npcEvent = new ScriptEventDialog(player,dialogId,optionId,dialog);
|
||||
npc.script.callScript(EnumScriptType.DIALOG_CLOSE, "event", npcEvent, "player", npcEvent.getPlayer(), "dialog", npcEvent.getDialogId(), "option", npcEvent.getOptionId(), "dialogObj", npcEvent.getDialog());
|
||||
npc.script.callScript(EnumScriptType.DIALOG_CLOSE, event, "player", event.getPlayer(), "dialog", event.getDialogId(), "option", event.getOptionId(), "dialogObj", event.getDialog());
|
||||
|
||||
NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
@@ -167,31 +163,27 @@ public class EventHooks {
|
||||
|
||||
NpcEvent.InteractEvent event = new NpcEvent.InteractEvent(npc.wrappedNPC,player);
|
||||
ScriptController.Instance.npcScripts.callScript(EnumScriptType.INTERACT, event);
|
||||
boolean result = npc.script.callScript(EnumScriptType.INTERACT, "player", player);
|
||||
boolean result = npc.script.callScript(EnumScriptType.INTERACT, event, "player", player);
|
||||
NpcAPI.EVENT_BUS.post(event);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static boolean onNPCMeleeAttack(EntityNPCInterface npc, float damage, EntityLivingBase target){
|
||||
public static boolean onNPCMeleeAttack(EntityNPCInterface npc, NpcEvent.MeleeAttackEvent event){
|
||||
if(npc == null || npc.wrappedNPC == null)
|
||||
return false;
|
||||
|
||||
NpcEvent.MeleeAttackEvent event = new NpcEvent.MeleeAttackEvent(npc.wrappedNPC,damage,target);
|
||||
ScriptController.Instance.npcScripts.callScript(EnumScriptType.ATTACK_MELEE, event);
|
||||
boolean result = npc.script.callScript(EnumScriptType.ATTACK, "event", new ScriptEventAttack(damage,target,false), "target", target);
|
||||
NpcAPI.EVENT_BUS.post(event);
|
||||
return result;
|
||||
npc.script.callScript(EnumScriptType.ATTACK, event, "target", event.target);
|
||||
return NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onNPCRangedAttack(EntityNPCInterface npc, float damage, EntityLivingBase target){
|
||||
public static boolean onNPCRangedAttack(EntityNPCInterface npc, NpcEvent.RangedLaunchedEvent event){
|
||||
if(npc == null || npc.wrappedNPC == null)
|
||||
return false;
|
||||
|
||||
NpcEvent.RangedLaunchedEvent event = new NpcEvent.RangedLaunchedEvent(npc.wrappedNPC,damage,target);
|
||||
ScriptController.Instance.npcScripts.callScript(EnumScriptType.RANGED_LAUNCHED, event);
|
||||
boolean result = npc.script.callScript(EnumScriptType.ATTACK, "event", new ScriptEventAttack(damage,target,true), "target", target);
|
||||
NpcAPI.EVENT_BUS.post(event);
|
||||
return result;
|
||||
npc.script.callScript(EnumScriptType.ATTACK, event, "target", event.target);
|
||||
return NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static void onNPCKilledEntity(EntityNPCInterface npc, EntityLivingBase entity){
|
||||
@@ -200,19 +192,17 @@ public class EventHooks {
|
||||
|
||||
NpcEvent.KilledEntityEvent event = new NpcEvent.KilledEntityEvent(npc.wrappedNPC,entity);
|
||||
ScriptController.Instance.npcScripts.callScript(EnumScriptType.KILLS, event);
|
||||
npc.script.callScript(EnumScriptType.KILLS, "target", entity);
|
||||
npc.script.callScript(EnumScriptType.KILLS, event, "target", entity);
|
||||
NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onNPCTarget(EntityNPCInterface npc, EntityLivingBase target){
|
||||
public static boolean onNPCTarget(EntityNPCInterface npc, NpcEvent.TargetEvent event){
|
||||
if(npc == null || npc.wrappedNPC == null)
|
||||
return false;
|
||||
|
||||
NpcEvent.TargetEvent event = new NpcEvent.TargetEvent(npc.wrappedNPC,target);
|
||||
ScriptController.Instance.npcScripts.callScript(EnumScriptType.TARGET, event);
|
||||
boolean result = npc.script.callScript(EnumScriptType.TARGET, "event", new ScriptEventTarget(target));
|
||||
NpcAPI.EVENT_BUS.post(event);
|
||||
return result;
|
||||
npc.script.callScript(EnumScriptType.TARGET, event);
|
||||
return NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static void onNPCCollide(EntityNPCInterface npc, Entity entity){
|
||||
@@ -221,29 +211,26 @@ public class EventHooks {
|
||||
|
||||
NpcEvent.CollideEvent event = new NpcEvent.CollideEvent(npc.wrappedNPC,entity);
|
||||
ScriptController.Instance.npcScripts.callScript(EnumScriptType.COLLIDE, event);
|
||||
npc.script.callScript(EnumScriptType.COLLIDE, "entity", entity);
|
||||
npc.script.callScript(EnumScriptType.COLLIDE, event, "entity", entity);
|
||||
NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onNPCDamaged(EntityNPCInterface npc, Entity source, float damage, DamageSource damagesource, ScriptEventDamaged damagedEvent){
|
||||
public static boolean onNPCDamaged(EntityNPCInterface npc, NpcEvent.DamagedEvent event){
|
||||
if(npc == null || npc.wrappedNPC == null)
|
||||
return false;
|
||||
|
||||
NpcEvent.DamagedEvent event = new NpcEvent.DamagedEvent(npc.wrappedNPC,source,damage,damagesource);
|
||||
ScriptController.Instance.npcScripts.callScript(EnumScriptType.DAMAGED, event);
|
||||
boolean result = npc.script.callScript(EnumScriptType.DAMAGED, "event", damagedEvent);
|
||||
NpcAPI.EVENT_BUS.post(event);
|
||||
return result;
|
||||
npc.script.callScript(EnumScriptType.DAMAGED, event);
|
||||
return NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onNPCKilled(EntityNPCInterface npc, NpcEvent.DiedEvent event, ScriptEventKilled killedEvent){
|
||||
public static boolean onNPCKilled(EntityNPCInterface npc, NpcEvent.DiedEvent event){
|
||||
if(npc == null || npc.wrappedNPC == null)
|
||||
return false;
|
||||
|
||||
ScriptController.Instance.npcScripts.callScript(EnumScriptType.KILLED, event);
|
||||
boolean result = npc.script.callScript(EnumScriptType.KILLED, "event", killedEvent);
|
||||
NpcAPI.EVENT_BUS.post(event);
|
||||
return result;
|
||||
npc.script.callScript(EnumScriptType.KILLED, event);
|
||||
return NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static void onNPCTimer(EntityNPCInterface npc, int id) {
|
||||
@@ -251,8 +238,7 @@ public class EventHooks {
|
||||
return;
|
||||
|
||||
NpcEvent.TimerEvent event = new NpcEvent.TimerEvent(npc.wrappedNPC, id);
|
||||
ScriptEventTimer scriptEvent = new ScriptEventTimer(id);
|
||||
npc.script.callScript(EnumScriptType.TIMER, "event", scriptEvent);
|
||||
npc.script.callScript(EnumScriptType.TIMER, event);
|
||||
ScriptController.Instance.npcScripts.callScript(EnumScriptType.TIMER, event);
|
||||
NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ import noppes.npcs.controllers.IScriptHandler;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.scripted.entity.ScriptNpc;
|
||||
import noppes.npcs.scripted.event.ScriptEvent;
|
||||
import noppes.npcs.scripted.ScriptWorld;
|
||||
import noppes.npcs.scripted.constants.EntityType;
|
||||
import noppes.npcs.scripted.constants.JobType;
|
||||
@@ -105,7 +104,7 @@ public class DataScript implements IScriptHandler {
|
||||
return list;
|
||||
}
|
||||
|
||||
public boolean callScript(EnumScriptType type, Object... obs){
|
||||
public boolean callScript(EnumScriptType type, Event event, Object... obs){
|
||||
if(aiNeedsUpdate){
|
||||
npc.updateAI = true;
|
||||
aiNeedsUpdate = false;
|
||||
@@ -116,10 +115,9 @@ public class DataScript implements IScriptHandler {
|
||||
}
|
||||
if(!isEnabled())
|
||||
return false;
|
||||
if(!hasInited && !npc.isRemote()){
|
||||
if(!hasInited && !npc.isRemote() && type != EnumScriptType.INIT){
|
||||
hasInited = true;
|
||||
EventHooks.onNPCInit(this.npc);
|
||||
callScript(EnumScriptType.INIT);
|
||||
}
|
||||
ScriptContainer script = scripts.get(type.ordinal());
|
||||
if(script == null || script.errored || !script.hasCode())
|
||||
@@ -134,16 +132,14 @@ public class DataScript implements IScriptHandler {
|
||||
script.engine.put(obs[i].toString(), ob);
|
||||
}
|
||||
|
||||
return callScript(script);
|
||||
return callScript(script, event);
|
||||
}
|
||||
|
||||
private boolean callScript(ScriptContainer script){
|
||||
private boolean callScript(ScriptContainer script, Event event){
|
||||
ScriptEngine engine = script.engine;
|
||||
engine.put("npc", dummyNpc);
|
||||
engine.put("world", dummyWorld);
|
||||
ScriptEvent result = (ScriptEvent) engine.get("event");
|
||||
if(result == null)
|
||||
engine.put("event", result = new ScriptEvent());
|
||||
engine.put("event", event);
|
||||
engine.put("API", new NpcAPI());
|
||||
engine.put("EntityType", entities);
|
||||
engine.put("RoleType", roles);
|
||||
@@ -158,17 +154,13 @@ public class DataScript implements IScriptHandler {
|
||||
npc.updateAI = true;
|
||||
aiNeedsUpdate = false;
|
||||
}
|
||||
return result.isCancelled();
|
||||
return event.isCanceled();
|
||||
}
|
||||
|
||||
public boolean isEnabled(){
|
||||
return enabled && ScriptController.HasStart && !npc.worldObj.isRemote && !scripts.isEmpty();
|
||||
}
|
||||
|
||||
public void callScript(EnumScriptType var1, Event var2, Object... obs) {
|
||||
|
||||
}
|
||||
|
||||
public Map<Long, String> getConsoleText() {
|
||||
Map<Long, String> map = new TreeMap();
|
||||
int tab = 0;
|
||||
@@ -200,7 +192,7 @@ public class DataScript implements IScriptHandler {
|
||||
|
||||
@Override
|
||||
public void callScript(EnumScriptType var1, Event var2) {
|
||||
|
||||
callScript(var1, var2, "$$IGNORED$$", null);
|
||||
}
|
||||
|
||||
public boolean isClient() {
|
||||
|
||||
@@ -235,8 +235,8 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
par1Entity.hurtResistantTime = 0;
|
||||
}
|
||||
if(par1Entity instanceof EntityLivingBase && !isRemote()){
|
||||
ScriptEventAttack event = new ScriptEventAttack(f, (EntityLivingBase)par1Entity, false);
|
||||
if(EventHooks.onNPCMeleeAttack(this, f, (EntityLivingBase)par1Entity))
|
||||
NpcEvent.MeleeAttackEvent event = new NpcEvent.MeleeAttackEvent(wrappedNPC, f, (EntityLivingBase)par1Entity);
|
||||
if(EventHooks.onNPCMeleeAttack(this, event))
|
||||
return false;
|
||||
f = event.getDamage();
|
||||
}
|
||||
@@ -493,10 +493,10 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
}
|
||||
else if (attackingEntity instanceof EntityPlayer && faction.isFriendlyToPlayer((EntityPlayer) attackingEntity))
|
||||
return false;
|
||||
ScriptEventDamaged result = new ScriptEventDamaged(i, attackingEntity, damagesource);
|
||||
if(EventHooks.onNPCDamaged(this, attackingEntity, i, damagesource, result) || isKilled())
|
||||
NpcEvent.DamagedEvent event = new NpcEvent.DamagedEvent(this.wrappedNPC, attackingEntity, i, damagesource);
|
||||
if(EventHooks.onNPCDamaged(this, event) || isKilled())
|
||||
return false;
|
||||
i = result.getDamage();
|
||||
i = event.getDamage();
|
||||
|
||||
if(isKilled())
|
||||
return false;
|
||||
@@ -526,7 +526,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
return super.attackEntityFrom(damagesource, i);
|
||||
}
|
||||
finally{
|
||||
if(result.getClearTarget()){
|
||||
if(event.getClearTarget()){
|
||||
setAttackTarget(null);
|
||||
setRevengeTarget(null);
|
||||
}
|
||||
@@ -544,8 +544,8 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
return;
|
||||
if (!isRemote()) {
|
||||
if (getAttackTarget() != entity && entity != null) {
|
||||
ScriptEventTarget event = new ScriptEventTarget(entity);
|
||||
if (EventHooks.onNPCTarget(this, entity))
|
||||
NpcEvent.TargetEvent event = new NpcEvent.TargetEvent(wrappedNPC,entity);
|
||||
if (EventHooks.onNPCTarget(this, event))
|
||||
return;
|
||||
|
||||
if (event.getTarget() == null)
|
||||
@@ -571,8 +571,8 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
return;
|
||||
}
|
||||
if (!isRemote()) {
|
||||
ScriptEventAttack event = new ScriptEventAttack(stats.pDamage, entity, true);
|
||||
if (EventHooks.onNPCRangedAttack(this, f, (EntityLivingBase) entity))
|
||||
NpcEvent.RangedLaunchedEvent event = new NpcEvent.RangedLaunchedEvent(wrappedNPC,stats.pDamage,entity);
|
||||
if (EventHooks.onNPCRangedAttack(this, event))
|
||||
return;
|
||||
for (int i = 0; i < this.stats.shotCount; i++) {
|
||||
EntityProjectile projectile = shoot(entity, stats.accuracy, proj, f == 1);
|
||||
@@ -1213,9 +1213,8 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
ArrayList<ItemStack> droppedItems = inventory.getDroppedItems(damagesource);
|
||||
|
||||
if(!isRemote()){
|
||||
ScriptEventKilled result = new ScriptEventKilled(attackingEntity, damagesource);
|
||||
NpcEvent.DiedEvent event = new NpcEvent.DiedEvent(this.wrappedNPC,damagesource,entity,droppedItems, droppedXp);
|
||||
if(EventHooks.onNPCKilled(this, event, result))
|
||||
if(EventHooks.onNPCKilled(this, event))
|
||||
return;
|
||||
|
||||
droppedItems.clear();
|
||||
|
||||
@@ -116,6 +116,36 @@ public class NpcEvent extends CustomNPCsEvent {
|
||||
this.target = (IEntityLivingBase)NpcAPI.Instance().getIEntity(target);
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The source of the damage
|
||||
* @deprecated
|
||||
*/
|
||||
public IEntityLivingBase getTarget(){
|
||||
return target;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Returns the damage value
|
||||
*/
|
||||
public float getDamage(){
|
||||
return damage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param damage The new damage value
|
||||
*/
|
||||
public void setDamage(float damage){
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the damage type
|
||||
*/
|
||||
public boolean isRange(){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
@@ -128,6 +158,36 @@ public class NpcEvent extends CustomNPCsEvent {
|
||||
this.target = (IEntityLivingBase)NpcAPI.Instance().getIEntity(target);
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The source of the damage
|
||||
* @deprecated
|
||||
*/
|
||||
public IEntityLivingBase getTarget(){
|
||||
return target;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Returns the damage value
|
||||
*/
|
||||
public float getDamage(){
|
||||
return damage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param damage The new damage value
|
||||
*/
|
||||
public void setDamage(float damage){
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the damage type
|
||||
*/
|
||||
public boolean isRange(){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static class KilledEntityEvent extends NpcEvent {
|
||||
@@ -236,14 +296,43 @@ public class NpcEvent extends CustomNPCsEvent {
|
||||
public final IPlayer player;
|
||||
public final int id;
|
||||
public final int optionId;
|
||||
public final Dialog dialog;
|
||||
public final Dialog dialogObj;
|
||||
|
||||
public final int dialog;
|
||||
public final int option;
|
||||
|
||||
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;
|
||||
this.dialogObj = dialog;
|
||||
|
||||
this.dialog = id;
|
||||
this.option = optionId;
|
||||
}
|
||||
|
||||
public IPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public Dialog getDialog() {
|
||||
return dialogObj;
|
||||
}
|
||||
|
||||
public int getDialogId() {
|
||||
return option;
|
||||
}
|
||||
|
||||
public int getOptionId() {
|
||||
return option;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public boolean isClosing(){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,47 +378,4 @@ public class NpcEvent extends CustomNPCsEvent {
|
||||
super(npc);
|
||||
}
|
||||
}
|
||||
|
||||
public static class AttackEvent extends NpcEvent{
|
||||
private float damage;
|
||||
private IEntityLivingBase target;
|
||||
private boolean isRanged;
|
||||
|
||||
public AttackEvent(ICustomNpc npc, float damage, EntityLivingBase target, boolean isRanged){
|
||||
super(npc);
|
||||
this.damage = damage;
|
||||
this.isRanged = isRanged;
|
||||
this.target = (IEntityLivingBase) NpcAPI.Instance().getIEntity(target);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The source of the damage
|
||||
* @deprecated
|
||||
*/
|
||||
public IEntityLivingBase getTarget(){
|
||||
return target;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Returns the damage value
|
||||
*/
|
||||
public float getDamage(){
|
||||
return damage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param damage The new damage value
|
||||
*/
|
||||
public void setDamage(float damage){
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the damage type
|
||||
*/
|
||||
public boolean isRange(){
|
||||
return isRanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package noppes.npcs.scripted.event;
|
||||
|
||||
public
|
||||
class ScriptEvent{
|
||||
private boolean isCancelled = false;
|
||||
|
||||
public void setCancelled(boolean bo){
|
||||
isCancelled = bo;
|
||||
}
|
||||
|
||||
public boolean isCancelled(){
|
||||
return isCancelled;
|
||||
}
|
||||
|
||||
public void setCanceled(boolean bo){
|
||||
isCancelled = bo;
|
||||
}
|
||||
|
||||
public boolean isCanceled(){
|
||||
return isCancelled;
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package noppes.npcs.scripted.event;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
|
||||
|
||||
public class ScriptEventAttack extends ScriptEvent{
|
||||
|
||||
private float damage;
|
||||
private IEntityLivingBase target;
|
||||
private boolean isRanged;
|
||||
|
||||
public ScriptEventAttack(float damage, EntityLivingBase target, boolean isRanged){
|
||||
this.damage = damage;
|
||||
this.isRanged = isRanged;
|
||||
this.target = (IEntityLivingBase) NpcAPI.Instance().getIEntity(target);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The source of the damage
|
||||
* @deprecated
|
||||
*/
|
||||
public IEntityLivingBase getTarget(){
|
||||
return target;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Returns the damage value
|
||||
*/
|
||||
public float getDamage(){
|
||||
return damage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param damage The new damage value
|
||||
*/
|
||||
public void setDamage(float damage){
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the damage type
|
||||
*/
|
||||
public boolean isRange(){
|
||||
return isRanged;
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
package noppes.npcs.scripted.event;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
|
||||
|
||||
public class ScriptEventDamaged extends ScriptEvent{
|
||||
|
||||
private float damage;
|
||||
private boolean clear = false;
|
||||
private IEntityLivingBase source;
|
||||
private DamageSource damagesource;
|
||||
|
||||
public ScriptEventDamaged(float damage, EntityLivingBase attackingEntity, DamageSource damagesource){
|
||||
this.damage = damage;
|
||||
this.damagesource = damagesource;
|
||||
this.source = (IEntityLivingBase) NpcAPI.Instance().getIEntity(attackingEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The source of the damage
|
||||
*/
|
||||
public IEntityLivingBase getSource(){
|
||||
return source;
|
||||
}
|
||||
|
||||
public void setClearTarget(boolean bo){
|
||||
this.clear = bo;
|
||||
}
|
||||
|
||||
public boolean getClearTarget(){
|
||||
return clear;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the damage value
|
||||
*/
|
||||
public float getDamage(){
|
||||
return damage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param damage The new damage value
|
||||
*/
|
||||
public void setDamage(float damage){
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the damage type
|
||||
*/
|
||||
public String getType(){
|
||||
return damagesource.damageType;
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package noppes.npcs.scripted.event;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import noppes.npcs.controllers.data.Dialog;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.interfaces.entity.IPlayer;
|
||||
|
||||
public class ScriptEventDialog extends ScriptEvent{
|
||||
public IPlayer player;
|
||||
public int dialog;
|
||||
public int option;
|
||||
public Dialog dialogObj;
|
||||
|
||||
public ScriptEventDialog(EntityPlayer player, int dialog, int option, Dialog dialogObj){
|
||||
this.player = (IPlayer) NpcAPI.Instance().getIEntity(player);
|
||||
this.dialog = dialog;
|
||||
this.option = option;
|
||||
this.dialogObj = dialogObj;
|
||||
}
|
||||
|
||||
public IPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public Dialog getDialog() {
|
||||
return dialogObj;
|
||||
}
|
||||
|
||||
public int getDialogId() {
|
||||
return dialog;
|
||||
}
|
||||
|
||||
public int getOptionId() {
|
||||
return option;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public boolean isClosing(){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package noppes.npcs.scripted.event;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.interfaces.IDamageSource;
|
||||
import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
|
||||
|
||||
public class ScriptEventKilled extends ScriptEvent{
|
||||
private IEntityLivingBase source;
|
||||
private DamageSource damagesource;
|
||||
|
||||
public ScriptEventKilled(EntityLivingBase target, DamageSource damagesource){
|
||||
this.damagesource = damagesource;
|
||||
this.source = (IEntityLivingBase) NpcAPI.Instance().getIEntity(target);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The source of the damage
|
||||
*/
|
||||
public IEntityLivingBase getSource(){
|
||||
return source;
|
||||
}
|
||||
|
||||
public IDamageSource getDamageSource() { return NpcAPI.Instance().getIDamageSource(damagesource); }
|
||||
|
||||
/**
|
||||
* @return Returns the damage type
|
||||
*/
|
||||
public String getType(){
|
||||
return damagesource.damageType;
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package noppes.npcs.scripted.event;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
|
||||
|
||||
public class ScriptEventTarget extends ScriptEvent {
|
||||
|
||||
private IEntityLivingBase target;
|
||||
|
||||
public ScriptEventTarget(EntityLivingBase target){
|
||||
if(target != null)
|
||||
this.target = (IEntityLivingBase) NpcAPI.Instance().getIEntity(target);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The source of the damage
|
||||
*/
|
||||
public IEntityLivingBase getTarget(){
|
||||
return target;
|
||||
}
|
||||
|
||||
public void setTarget(IEntityLivingBase target){
|
||||
this.target = target;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package noppes.npcs.scripted.event;
|
||||
|
||||
public class ScriptEventTimer extends ScriptEvent {
|
||||
private int id;
|
||||
|
||||
public ScriptEventTimer(int id){
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getId(){
|
||||
return id;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user