Merge branch 'master' into dev

This commit is contained in:
KAMKEEL committed 2022-04-09 01:22:15 -04:00
commit 5ad6bb094a
8 files changed
+50 -16

No files matched your search

+1 -1
View File
@@ -123,6 +123,6 @@ public class CmdDialog extends ChMcLogger {
option.dialogId = diagid;
option.title = dialog.title;
npc.dialogs.put(0, option);
NoppesUtilServer.openDialog(player, npc, dialog);
NoppesUtilServer.openDialog(player, npc, dialog, 0);
}
}
+8 -7
View File
@@ -56,6 +56,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);
WrapperNpcAPI.EVENT_BUS.post(event);
}
@@ -69,13 +70,13 @@ public class EventHooks {
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onNPCDialog(EntityNPCInterface npc, EntityPlayer player, int id, Dialog dialog) {
public static void onNPCDialog(EntityNPCInterface npc, EntityPlayer player, int dialogId, int optionId, Dialog dialog) {
if(npc == null || npc.wrappedNPC == null)
return;
NpcEvent.DialogEvent event = new NpcEvent.DialogEvent(npc.wrappedNPC, player, id, dialog);
NpcEvent.DialogEvent event = new NpcEvent.DialogEvent(npc.wrappedNPC, player, dialogId, optionId, dialog);
ScriptController.Instance.npcScripts.callScript(EnumScriptType.DIALOG, event);
npc.script.callScript(EnumScriptType.DIALOG, "event", new ScriptEventDialog(), "player", player, "dialog", dialog.id);
npc.script.callScript(EnumScriptType.DIALOG, "event", new ScriptEventDialog(player,dialogId,optionId,dialog));
WrapperNpcAPI.EVENT_BUS.post(event);
}
@@ -85,7 +86,7 @@ public class EventHooks {
NpcEvent.DialogClosedEvent event = new NpcEvent.DialogClosedEvent(npc.wrappedNPC, player, dialogId, optionId, dialog);
ScriptController.Instance.npcScripts.callScript(EnumScriptType.DIALOG_CLOSE, event);
npc.script.callScript(EnumScriptType.DIALOG_CLOSE, "player", player, "dialog", dialogId, "option", optionId + 1);
npc.script.callScript(EnumScriptType.DIALOG_CLOSE, "event", new ScriptEventDialog(player,dialogId,optionId,dialog));
WrapperNpcAPI.EVENT_BUS.post(event);
}
@@ -106,7 +107,7 @@ public class EventHooks {
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", event, "target", target);
boolean result = npc.script.callScript(EnumScriptType.ATTACK, "event", new ScriptEventAttack(damage,target,false), "target", target);
WrapperNpcAPI.EVENT_BUS.post(event);
return result;
}
@@ -117,7 +118,7 @@ public class EventHooks {
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", event, "target", target);
boolean result = npc.script.callScript(EnumScriptType.ATTACK, "event", new ScriptEventAttack(damage,target,true), "target", target);
WrapperNpcAPI.EVENT_BUS.post(event);
return result;
}
@@ -138,7 +139,7 @@ public class EventHooks {
NpcEvent.TargetEvent event = new NpcEvent.TargetEvent(npc.wrappedNPC,target);
ScriptController.Instance.npcScripts.callScript(EnumScriptType.TARGET, event);
boolean result = npc.script.callScript(EnumScriptType.TARGET, "event", event);
boolean result = npc.script.callScript(EnumScriptType.TARGET, "event", new ScriptEventTarget(target));
WrapperNpcAPI.EVENT_BUS.post(event);
return result;
}
@@ -271,7 +271,7 @@ public class NoppesUtilPlayer {
Server.sendData(player, EnumPacketClient.GUI_CLOSE);
}
else if(option.optionType == EnumOptionType.DialogOption){
NoppesUtilServer.openDialog(player, npc, option.getDialog());
NoppesUtilServer.openDialog(player, npc, option.getDialog(), optionId+1);
}
else if(option.optionType == EnumOptionType.CommandBlock){
Server.sendData(player, EnumPacketClient.GUI_CLOSE);
@@ -180,7 +180,7 @@ public class NoppesUtilServer {
return item;
}
public static void openDialog(EntityPlayer player, EntityNPCInterface npc, Dialog dia){
public static void openDialog(EntityPlayer player, EntityNPCInterface npc, Dialog dia, int optionId){
Dialog dialog = dia.copy(player);
EventHooks.onDialogOpen(new DialogEvent.DialogOpen(new ScriptPlayer((EntityPlayerMP) player), dialog));
@@ -203,7 +203,7 @@ public class NoppesUtilServer {
if(!data.dialogsRead.contains(dialog.id))
data.dialogsRead.add(dialog.id);
setEditingNpc(player, npc);
EventHooks.onNPCDialog(npc, player, dialog.id, dialog);
EventHooks.onNPCDialog(npc, player, dialog.id, optionId, dialog);
}
public static void runCommand(EntityPlayer player, String name, String command){
runCommand(player, name, command, player);
@@ -399,7 +399,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
Server.sendData((EntityPlayerMP)player, EnumPacketClient.QUEST_COMPLETION, data.quest.writeToNBT(new NBTTagCompound()));
}
else if (dialog != null){
NoppesUtilServer.openDialog(player, this, dialog);
NoppesUtilServer.openDialog(player, this, dialog, 0);
}
else if(roleInterface != null)
roleInterface.interact(player);
@@ -1062,7 +1062,6 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
jobInterface.reset();
EventHooks.onNPCInit(this);
script.callScript(EnumScriptType.INIT);
}
public void onCollide() {
@@ -113,7 +113,7 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
if(dialog == null)
return;
NoppesUtilServer.openDialog(player, new EntityDialogNpc(this.player.worldObj), dialog);
NoppesUtilServer.openDialog(player, new EntityDialogNpc(this.player.worldObj), dialog, 0);
}
public boolean hasReadDialog(int id){
@@ -123,12 +123,14 @@ public class NpcEvent extends CustomNPCsEvent {
public static class DialogEvent extends NpcEvent {
public final IPlayer player;
public final int id;
public final int optionId;
public final Dialog dialog;
public DialogEvent(ICustomNpc npc, EntityPlayer player, int id, Dialog dialog) {
public DialogEvent(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;
}
}
@@ -1,7 +1,39 @@
package noppes.npcs.scripted.event;
import net.minecraft.entity.player.EntityPlayer;
import noppes.npcs.controllers.Dialog;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.interfaces.IPlayer;
public class ScriptEventDialog extends ScriptEvent{
public EntityPlayer player;
public int dialog;
public int option;
public Dialog dialogObj;
public ScriptEventDialog(EntityPlayer player, int dialog, int option, Dialog dialogObj){
this.player = player;
this.dialog = dialog;
this.option = option;
this.dialogObj = dialogObj;
}
public EntityPlayer getPlayer() {
return player;
}
public Dialog getDialog() {
return dialogObj;
}
public int getDialogId() {
return dialog;
}
public int getOptionId() {
return option;
}
/**
* @deprecated
*/