Important fix to some NPC hook scripts crashing, added option and dialog object fields to local NPC dialog and NPC dialog closed scripts

This commit is contained in:
Luis C.M committed 2022-04-09 00:17:16 -05:00
1 parent 4abe8dca92
commit 65bb3b5939
8 files changed
+50 -16

No files matched your search

@@ -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
*/