Merge Dev into PR 110

This commit is contained in:
Kam committed 2024-01-18 14:45:08 -05:00
commit 3e43855128
39 files changed
+1149 -355

No files matched your search

@@ -915,4 +915,9 @@ public class ScriptEntity<T extends Entity> implements IEntity {
public boolean equals(Object object) {
return object instanceof IEntity && ((IEntity<?>)object).getMCEntity().equals(this.entity);
}
public void updateEntity() {
IWorld world = NpcAPI.Instance().getIWorld(entity.worldObj);
entity.dimension = world.getDimensionID();
}
}
@@ -10,13 +10,16 @@ import noppes.npcs.api.entity.IPlayer;
import noppes.npcs.api.entity.data.IModelData;
import noppes.npcs.api.handler.IOverlayHandler;
import noppes.npcs.api.handler.data.IAnimationData;
import noppes.npcs.api.handler.data.IDialog;
import noppes.npcs.api.handler.data.IFaction;
import noppes.npcs.api.handler.data.ILines;
import noppes.npcs.api.item.IItemStack;
import noppes.npcs.api.jobs.IJob;
import noppes.npcs.api.roles.IRole;
import noppes.npcs.config.ConfigMain;
import noppes.npcs.constants.*;
import noppes.npcs.controllers.FactionController;
import noppes.npcs.controllers.data.DialogOption;
import noppes.npcs.controllers.data.Line;
import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.entity.EntityNPCInterface;
@@ -326,7 +329,49 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
return;
npc.say((EntityPlayer) player.getMCEntity(), new Line(message));
}
public IDialog getDialog(int slot) {
return NpcAPI.Instance().getDialogs().get(this.getDialogId(slot));
}
public int getDialogId(int slot) {
if (npc.dialogs.containsKey(slot)) {
DialogOption option = npc.dialogs.get(slot);
if (option.hasDialog()) {
return option.dialogId;
}
}
return -1;
}
public void setDialog(int slot, IDialog dialog) {
this.setDialog(slot, dialog.getId());
}
public void setDialog(int slot, int dialogId) {
NoppesUtilServer.setNpcDialog(slot,dialogId, this.npc);
}
public ILines getInteractLines() {
return this.npc.advanced.interactLines;
}
public ILines getWorldLines() {
return this.npc.advanced.worldLines;
}
public ILines getAttackLines() {
return this.npc.advanced.attackLines;
}
public ILines getKilledLines() {
return this.npc.advanced.killedLines;
}
public ILines getKillLines() {
return this.npc.advanced.killLines;
}
/**
* Kill the npc, doesnt't despawn it
*/
@@ -79,6 +79,10 @@ public class ScriptProjectile<T extends EntityProjectile> extends ScriptEntity<T
return type == EntityType.PROJECTILE || super.typeOf(type);
}
public IEntity getThrower() {
return NpcAPI.Instance().getIEntity(entity.getThrower());
}
public void enableEvents() {
if(ScriptContainer.Current == null)
throw new CustomNPCsException("Can only be called during scripts");
@@ -1,18 +1,31 @@
package noppes.npcs.scripted.event;
import noppes.npcs.api.IBlock;
import noppes.npcs.api.entity.IEntity;
import noppes.npcs.api.entity.IProjectile;
import noppes.npcs.api.event.IProjectileEvent;
public class ProjectileEvent extends CustomNPCsEvent {
public class ProjectileEvent extends CustomNPCsEvent implements IProjectileEvent {
public IProjectile projectile;
public IEntity source;
public ProjectileEvent(IProjectile projectile) {
this.projectile = projectile;
this.source = projectile.getThrower();
}
public IProjectile getProjectile() {
return projectile;
}
public IEntity getSource() {
return source;
}
/**
* projectileTick
*/
public static class UpdateEvent extends ProjectileEvent {
public static class UpdateEvent extends ProjectileEvent implements IProjectileEvent.UpdateEvent {
public UpdateEvent(IProjectile projectile) {
super(projectile);
}
@@ -21,7 +34,7 @@ public class ProjectileEvent extends CustomNPCsEvent {
/**
* projectileImpact
*/
public static class ImpactEvent extends ProjectileEvent {
public static class ImpactEvent extends ProjectileEvent implements IProjectileEvent.ImpactEvent {
/**
* 0:entity, 1:block
*/
@@ -33,5 +46,21 @@ public class ProjectileEvent extends CustomNPCsEvent {
this.type = type;
this.target = target;
}
public int getType() {
return type;
}
public IEntity getEntity() {
if(type == 0)
return (IEntity) target;
return null;
}
public IBlock getBlock() {
if(type == 1)
return (IBlock) target;
return null;
}
}
}