mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-27 03:52:55 +00:00
Used interfaces in implementations instead of the real classes for most scripted classes.
This commit is contained in:
1 parent
6896cec417
commit
cf33b90b26
63 files changed
+466
-551
No files matched your search
@@ -6,7 +6,7 @@
|
||||
package noppes.npcs.scripted.event;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import noppes.npcs.scripted.AbstractNpcAPI;
|
||||
import noppes.npcs.scripted.interfaces.AbstractNpcAPI;
|
||||
|
||||
public class CustomNPCsEvent extends Event{
|
||||
public final AbstractNpcAPI API = AbstractNpcAPI.Instance();
|
||||
|
||||
@@ -18,7 +18,7 @@ import noppes.npcs.scripted.interfaces.entity.IEntity;
|
||||
import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
|
||||
import noppes.npcs.scripted.interfaces.entity.IPlayer;
|
||||
import noppes.npcs.scripted.interfaces.item.IItemStack;
|
||||
import noppes.npcs.scripted.wrapper.NpcAPI;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
|
||||
public class NpcEvent extends CustomNPCsEvent {
|
||||
public final ICustomNpc npc;
|
||||
@@ -41,7 +41,7 @@ public class NpcEvent extends CustomNPCsEvent {
|
||||
|
||||
public CollideEvent(ICustomNpc npc, Entity entity) {
|
||||
super(npc);
|
||||
this.entity = ScriptController.Instance.getScriptForEntity(entity);
|
||||
this.entity = NpcAPI.Instance().getIEntity(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class NpcEvent extends CustomNPCsEvent {
|
||||
|
||||
public DamagedEvent(ICustomNpc npc, Entity source, float damage, DamageSource damagesource) {
|
||||
super(npc);
|
||||
this.source = ScriptController.Instance.getScriptForEntity(source);
|
||||
this.source = NpcAPI.Instance().getIEntity(source);
|
||||
this.damage = damage;
|
||||
this.damageSource = NpcAPI.Instance().getIDamageSource(damagesource);
|
||||
}
|
||||
@@ -71,7 +71,7 @@ public class NpcEvent extends CustomNPCsEvent {
|
||||
|
||||
public RangedLaunchedEvent(ICustomNpc npc, float damage, EntityLivingBase target) {
|
||||
super(npc);
|
||||
this.target = (IEntityLivingBase)ScriptController.Instance.getScriptForEntity(target);
|
||||
this.target = (IEntityLivingBase)NpcAPI.Instance().getIEntity(target);
|
||||
this.damage = damage;
|
||||
}
|
||||
}
|
||||
@@ -83,7 +83,7 @@ public class NpcEvent extends CustomNPCsEvent {
|
||||
|
||||
public MeleeAttackEvent(ICustomNpc npc, float damage, EntityLivingBase target) {
|
||||
super(npc);
|
||||
this.target = (IEntityLivingBase)ScriptController.Instance.getScriptForEntity(target);
|
||||
this.target = (IEntityLivingBase)NpcAPI.Instance().getIEntity(target);
|
||||
this.damage = damage;
|
||||
}
|
||||
}
|
||||
@@ -93,7 +93,7 @@ public class NpcEvent extends CustomNPCsEvent {
|
||||
|
||||
public KilledEntityEvent(ICustomNpc npc, EntityLivingBase entity) {
|
||||
super(npc);
|
||||
this.entity = (IEntityLivingBase)ScriptController.Instance.getScriptForEntity(entity);
|
||||
this.entity = (IEntityLivingBase)NpcAPI.Instance().getIEntity(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ public class NpcEvent extends CustomNPCsEvent {
|
||||
super(npc);
|
||||
this.damageSource = NpcAPI.Instance().getIDamageSource(damagesource);
|
||||
this.type = damagesource.damageType;
|
||||
this.source = ScriptController.Instance.getScriptForEntity(entity);
|
||||
this.source = NpcAPI.Instance().getIEntity(entity);
|
||||
}
|
||||
|
||||
public String getType(){
|
||||
@@ -122,7 +122,7 @@ public class NpcEvent extends CustomNPCsEvent {
|
||||
|
||||
public InteractEvent(ICustomNpc npc, EntityPlayer player) {
|
||||
super(npc);
|
||||
this.player = (IPlayer)ScriptController.Instance.getScriptForEntity(player);
|
||||
this.player = (IPlayer)NpcAPI.Instance().getIEntity(player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ public class NpcEvent extends CustomNPCsEvent {
|
||||
|
||||
public DialogEvent(ICustomNpc npc, EntityPlayer player, int id, int optionId, Dialog dialog) {
|
||||
super(npc);
|
||||
this.player = (IPlayer)ScriptController.Instance.getScriptForEntity(player);
|
||||
this.player = (IPlayer)NpcAPI.Instance().getIEntity(player);
|
||||
this.id = id;
|
||||
this.optionId = optionId;
|
||||
this.dialog = dialog;
|
||||
@@ -149,7 +149,7 @@ public class NpcEvent extends CustomNPCsEvent {
|
||||
|
||||
public DialogClosedEvent(ICustomNpc npc, EntityPlayer player, int id, int optionId, Dialog dialog) {
|
||||
super(npc);
|
||||
this.player = (IPlayer)ScriptController.Instance.getScriptForEntity(player);
|
||||
this.player = (IPlayer)NpcAPI.Instance().getIEntity(player);
|
||||
this.id = id;
|
||||
this.optionId = optionId;
|
||||
this.dialog = dialog;
|
||||
@@ -162,7 +162,7 @@ public class NpcEvent extends CustomNPCsEvent {
|
||||
|
||||
public TargetLostEvent(ICustomNpc npc, EntityLivingBase entity) {
|
||||
super(npc);
|
||||
this.entity = (IEntityLivingBase) ScriptController.Instance.getScriptForEntity(entity);
|
||||
this.entity = (IEntityLivingBase) NpcAPI.Instance().getIEntity(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ public class NpcEvent extends CustomNPCsEvent {
|
||||
|
||||
public TargetEvent(ICustomNpc npc, EntityLivingBase entity) {
|
||||
super(npc);
|
||||
this.entity = (IEntityLivingBase) ScriptController.Instance.getScriptForEntity(entity);
|
||||
this.entity = (IEntityLivingBase) NpcAPI.Instance().getIEntity(entity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,15 +12,12 @@ import net.minecraft.entity.item.EntityXPOrb;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
import noppes.npcs.scripted.entity.ScriptLivingBase;
|
||||
import noppes.npcs.scripted.interfaces.*;
|
||||
import noppes.npcs.scripted.interfaces.entity.IEntity;
|
||||
import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
|
||||
import noppes.npcs.scripted.interfaces.entity.IPlayer;
|
||||
import noppes.npcs.scripted.interfaces.item.IItemStack;
|
||||
import noppes.npcs.scripted.item.ScriptItemStack;
|
||||
import noppes.npcs.scripted.wrapper.NpcAPI;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
|
||||
public class PlayerEvent extends CustomNPCsEvent {
|
||||
public final IPlayer player;
|
||||
@@ -138,7 +135,7 @@ public class PlayerEvent extends CustomNPCsEvent {
|
||||
|
||||
public DamagedEvent(IPlayer player, Entity source, float damage, DamageSource damagesource) {
|
||||
super(player);
|
||||
this.source = ScriptController.Instance.getScriptForEntity(source);
|
||||
this.source = NpcAPI.Instance().getIEntity(source);
|
||||
this.damage = damage;
|
||||
this.damageSource = NpcAPI.Instance().getIDamageSource(damagesource);
|
||||
}
|
||||
@@ -185,7 +182,7 @@ public class PlayerEvent extends CustomNPCsEvent {
|
||||
|
||||
public KilledEntityEvent(IPlayer player, EntityLivingBase entity) {
|
||||
super(player);
|
||||
this.entity = new ScriptLivingBase<>(entity);//NpcAPI.Instance().getIEntity(entity);
|
||||
this.entity = (IEntityLivingBase) NpcAPI.Instance().getIEntity(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,7 +196,7 @@ public class PlayerEvent extends CustomNPCsEvent {
|
||||
super(player);
|
||||
this.damageSource = NpcAPI.Instance().getIDamageSource(damagesource);
|
||||
this.type = damagesource.getDamageType();
|
||||
this.source = ScriptController.Instance.getScriptForEntity(entity);
|
||||
this.source = NpcAPI.Instance().getIEntity(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,7 +220,7 @@ public class PlayerEvent extends CustomNPCsEvent {
|
||||
|
||||
public DamagedEntityEvent(IPlayer player, Entity target, float damage, DamageSource damagesource) {
|
||||
super(player);
|
||||
this.target = ScriptController.Instance.getScriptForEntity(target);
|
||||
this.target = NpcAPI.Instance().getIEntity(target);
|
||||
this.damage = damage;
|
||||
this.damageSource = NpcAPI.Instance().getIDamageSource(damagesource);
|
||||
}
|
||||
@@ -378,7 +375,7 @@ public class PlayerEvent extends CustomNPCsEvent {
|
||||
|
||||
public UseHoe(IPlayer player, ItemStack item, int x, int y, int z) {
|
||||
super(player);
|
||||
this.hoe = new ScriptItemStack(item);
|
||||
this.hoe = NpcAPI.Instance().getIItemStack(item);
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
@@ -422,8 +419,8 @@ public class PlayerEvent extends CustomNPCsEvent {
|
||||
|
||||
public FillBucket(IPlayer player, ItemStack current, ItemStack result) {
|
||||
super(player);
|
||||
this.current = new ScriptItemStack(current);
|
||||
this.result = new ScriptItemStack(result);
|
||||
this.current = NpcAPI.Instance().getIItemStack(current);
|
||||
this.result = NpcAPI.Instance().getIItemStack(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
package noppes.npcs.scripted.event;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
import noppes.npcs.scripted.entity.ScriptLivingBase;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
|
||||
|
||||
public class ScriptEventAttack extends ScriptEvent{
|
||||
|
||||
private float damage;
|
||||
private ScriptLivingBase target;
|
||||
private IEntityLivingBase target;
|
||||
private boolean isRanged;
|
||||
|
||||
public ScriptEventAttack(float damage, EntityLivingBase target, boolean isRanged){
|
||||
this.damage = damage;
|
||||
this.isRanged = isRanged;
|
||||
this.target = (ScriptLivingBase)ScriptController.Instance.getScriptForEntity(target);
|
||||
this.target = (IEntityLivingBase) NpcAPI.Instance().getIEntity(target);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The source of the damage
|
||||
* @deprecated
|
||||
*/
|
||||
public ScriptLivingBase getTarget(){
|
||||
public IEntityLivingBase getTarget(){
|
||||
return target;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,26 +2,26 @@ package noppes.npcs.scripted.event;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
import noppes.npcs.scripted.entity.ScriptLivingBase;
|
||||
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 ScriptLivingBase source;
|
||||
private IEntityLivingBase source;
|
||||
private DamageSource damagesource;
|
||||
|
||||
public ScriptEventDamaged(float damage, EntityLivingBase attackingEntity, DamageSource damagesource){
|
||||
this.damage = damage;
|
||||
this.damagesource = damagesource;
|
||||
this.source = (ScriptLivingBase)ScriptController.Instance.getScriptForEntity(attackingEntity);
|
||||
this.source = (IEntityLivingBase) NpcAPI.Instance().getIEntity(attackingEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The source of the damage
|
||||
*/
|
||||
public ScriptLivingBase getSource(){
|
||||
public IEntityLivingBase getSource(){
|
||||
return source;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package noppes.npcs.scripted.event;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import noppes.npcs.controllers.Dialog;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.interfaces.entity.IPlayer;
|
||||
|
||||
public class ScriptEventDialog extends ScriptEvent{
|
||||
@@ -12,7 +13,7 @@ public class ScriptEventDialog extends ScriptEvent{
|
||||
public Dialog dialogObj;
|
||||
|
||||
public ScriptEventDialog(EntityPlayer player, int dialog, int option, Dialog dialogObj){
|
||||
this.player = (IPlayer) ScriptController.Instance.getScriptForEntity(player);
|
||||
this.player = (IPlayer) NpcAPI.Instance().getIEntity(player);
|
||||
this.dialog = dialog;
|
||||
this.option = option;
|
||||
this.dialogObj = dialogObj;
|
||||
|
||||
@@ -2,26 +2,28 @@ package noppes.npcs.scripted.event;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
import noppes.npcs.scripted.entity.ScriptLivingBase;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.interfaces.IDamageSource;
|
||||
import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
|
||||
|
||||
public class ScriptEventKilled extends ScriptEvent{
|
||||
|
||||
private ScriptLivingBase source;
|
||||
private IEntityLivingBase source;
|
||||
private DamageSource damagesource;
|
||||
|
||||
public ScriptEventKilled(EntityLivingBase target, DamageSource damagesource){
|
||||
this.damagesource = damagesource;
|
||||
this.source = (ScriptLivingBase)ScriptController.Instance.getScriptForEntity(target);
|
||||
this.source = (IEntityLivingBase) NpcAPI.Instance().getIEntity(target);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The source of the damage
|
||||
*/
|
||||
public ScriptLivingBase getSource(){
|
||||
public IEntityLivingBase getSource(){
|
||||
return source;
|
||||
}
|
||||
|
||||
public IDamageSource getDamageSource() { return NpcAPI.Instance().getIDamageSource(damagesource); }
|
||||
|
||||
/**
|
||||
* @return Returns the damage type
|
||||
*/
|
||||
|
||||
@@ -1,27 +1,26 @@
|
||||
package noppes.npcs.scripted.event;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
import noppes.npcs.scripted.entity.ScriptLivingBase;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
|
||||
|
||||
public class ScriptEventTarget extends ScriptEvent {
|
||||
|
||||
private ScriptLivingBase target;
|
||||
private IEntityLivingBase target;
|
||||
|
||||
public ScriptEventTarget(EntityLivingBase target){
|
||||
if(target != null)
|
||||
this.target = (ScriptLivingBase)ScriptController.Instance.getScriptForEntity(target);
|
||||
this.target = (IEntityLivingBase) NpcAPI.Instance().getIEntity(target);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return The source of the damage
|
||||
*/
|
||||
public ScriptLivingBase getTarget(){
|
||||
public IEntityLivingBase getTarget(){
|
||||
return target;
|
||||
}
|
||||
|
||||
public void setTarget(ScriptLivingBase target){
|
||||
public void setTarget(IEntityLivingBase target){
|
||||
this.target = target;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user