mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-20 05:19:41 +00:00
Implemented scripted timers for players and NPCs.
This commit is contained in:
1 parent
a993c8feff
commit
4de969f6c9
15 files changed
+327
-16
No files matched your search
@@ -13,6 +13,7 @@ import noppes.npcs.scripted.ScriptItemStack;
|
||||
import noppes.npcs.scripted.constants.AnimationType;
|
||||
import noppes.npcs.scripted.constants.EntityType;
|
||||
import noppes.npcs.scripted.interfaces.ICustomNpc;
|
||||
import noppes.npcs.scripted.interfaces.ITimers;
|
||||
import noppes.npcs.scripted.roles.ScriptJobBard;
|
||||
import noppes.npcs.scripted.roles.ScriptJobConversation;
|
||||
import noppes.npcs.scripted.roles.ScriptJobFollower;
|
||||
@@ -678,4 +679,8 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
|
||||
public long getAge(){
|
||||
return npc.totalTicksAlive;
|
||||
}
|
||||
|
||||
public ITimers getTimers() {
|
||||
return ((EntityNPCInterface)this.npc).timers;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package noppes.npcs.scripted.entity;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -26,10 +27,12 @@ import noppes.npcs.scripted.ScriptItemStack;
|
||||
import noppes.npcs.scripted.ScriptPixelmonPlayerData;
|
||||
import noppes.npcs.scripted.constants.EntityType;
|
||||
import noppes.npcs.scripted.interfaces.IPlayer;
|
||||
import noppes.npcs.scripted.interfaces.ITimers;
|
||||
import noppes.npcs.util.ValueUtil;
|
||||
|
||||
public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T> implements IPlayer {
|
||||
public T player;
|
||||
private PlayerData data;
|
||||
public ScriptPlayer(T player){
|
||||
super(player);
|
||||
this.player = player;
|
||||
@@ -350,4 +353,16 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
||||
return null;
|
||||
return new ScriptPixelmonPlayerData(player);
|
||||
}
|
||||
|
||||
private PlayerData getData() {
|
||||
if (this.data == null) {
|
||||
this.data = PlayerData.get(player);
|
||||
}
|
||||
|
||||
return this.data;
|
||||
}
|
||||
|
||||
public ITimers getTimers() {
|
||||
return this.getData().timers;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
|
||||
package noppes.npcs.scripted.event;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.interfaces.*;
|
||||
|
||||
public class NpcEvent extends CustomNPCsEvent {
|
||||
public final ICustomNpc npc;
|
||||
|
||||
public NpcEvent(ICustomNpc npc) {
|
||||
this.npc = npc;
|
||||
}
|
||||
|
||||
public static class TimerEvent extends NpcEvent {
|
||||
public final int id;
|
||||
|
||||
public TimerEvent(ICustomNpc npc, int id) {
|
||||
super(npc);
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
|
||||
public static class CollideEvent extends NpcEvent {
|
||||
public final IEntity entity;
|
||||
|
||||
public CollideEvent(ICustomNpc npc, Entity entity) {
|
||||
super(npc);
|
||||
this.entity = NpcAPI.Instance().getIEntity(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class DamagedEvent extends NpcEvent {
|
||||
public final IDamageSource damageSource;
|
||||
public final IEntity source;
|
||||
public float damage;
|
||||
public boolean clearTarget = false;
|
||||
|
||||
public DamagedEvent(ICustomNpc npc, Entity source, float damage, DamageSource damagesource) {
|
||||
super(npc);
|
||||
this.source = NpcAPI.Instance().getIEntity(source);
|
||||
this.damage = damage;
|
||||
this.damageSource = NpcAPI.Instance().getIDamageSource(damagesource);
|
||||
}
|
||||
}
|
||||
|
||||
public static class RangedLaunchedEvent extends NpcEvent {
|
||||
public final IEntityLivingBase target;
|
||||
public float damage;
|
||||
//public List<IProjectile> projectiles = new ArrayList();
|
||||
|
||||
public RangedLaunchedEvent(ICustomNpc npc, EntityLivingBase target, float damage) {
|
||||
super(npc);
|
||||
this.target = (IEntityLivingBase)NpcAPI.Instance().getIEntity(target);
|
||||
this.damage = damage;
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class MeleeAttackEvent extends NpcEvent {
|
||||
public final IEntityLivingBase target;
|
||||
public float damage;
|
||||
|
||||
public MeleeAttackEvent(ICustomNpc npc, EntityLivingBase target, float damage) {
|
||||
super(npc);
|
||||
this.target = (IEntityLivingBase)NpcAPI.Instance().getIEntity(target);
|
||||
this.damage = damage;
|
||||
}
|
||||
}
|
||||
|
||||
public static class KilledEntityEvent extends NpcEvent {
|
||||
public final IEntityLivingBase entity;
|
||||
|
||||
public KilledEntityEvent(ICustomNpc npc, EntityLivingBase entity) {
|
||||
super(npc);
|
||||
this.entity = (IEntityLivingBase)NpcAPI.Instance().getIEntity(entity);
|
||||
}
|
||||
}
|
||||
|
||||
public static class DiedEvent extends NpcEvent {
|
||||
public final IDamageSource damageSource;
|
||||
public final String type;
|
||||
public final IEntity source;
|
||||
public IItemStack[] droppedItems;
|
||||
public int expDropped;
|
||||
|
||||
public DiedEvent(ICustomNpc npc, DamageSource damagesource, Entity entity) {
|
||||
super(npc);
|
||||
this.damageSource = NpcAPI.Instance().getIDamageSource(damagesource);
|
||||
this.type = damagesource.damageType;
|
||||
this.source = NpcAPI.Instance().getIEntity(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class InteractEvent extends NpcEvent {
|
||||
public final IPlayer player;
|
||||
|
||||
public InteractEvent(ICustomNpc npc, EntityPlayer player) {
|
||||
super(npc);
|
||||
this.player = (IPlayer)NpcAPI.Instance().getIEntity(player);
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class TargetLostEvent extends NpcEvent {
|
||||
public final IEntityLivingBase entity;
|
||||
|
||||
public TargetLostEvent(ICustomNpc npc, EntityLivingBase entity) {
|
||||
super(npc);
|
||||
this.entity = (IEntityLivingBase)NpcAPI.Instance().getIEntity(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class TargetEvent extends NpcEvent {
|
||||
public IEntityLivingBase entity;
|
||||
|
||||
public TargetEvent(ICustomNpc npc, EntityLivingBase entity) {
|
||||
super(npc);
|
||||
this.entity = (IEntityLivingBase) NpcAPI.Instance().getIEntity(entity);
|
||||
}
|
||||
}
|
||||
|
||||
public static class UpdateEvent extends NpcEvent {
|
||||
public UpdateEvent(ICustomNpc npc) {
|
||||
super(npc);
|
||||
}
|
||||
}
|
||||
|
||||
public static class InitEvent extends NpcEvent {
|
||||
public InitEvent(ICustomNpc npc) {
|
||||
super(npc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import net.minecraft.entity.EntityLivingBase;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
import noppes.npcs.scripted.entity.ScriptLivingBase;
|
||||
|
||||
public class ScriptEventTarget extends ScriptEvent{
|
||||
public class ScriptEventTarget extends ScriptEvent {
|
||||
|
||||
private ScriptLivingBase target;
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -166,4 +166,6 @@ public interface IPlayer<T extends EntityPlayerMP> extends IEntityLivingBase<T>
|
||||
* @since 1.7.10d
|
||||
*/
|
||||
public ScriptPixelmonPlayerData getPixelmonData();
|
||||
|
||||
public ITimers getTimers();
|
||||
}
|
||||
Reference in new issue
Block a user