mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-21 09:12:22 +00:00
Implemented Global NPC Events!
All NPCs activate these scripts. If a player wants to create a script that's universally used by all NPCs, this allows for that to happen with a lot of ease!
This commit is contained in:
1 parent
092592bd27
commit
18ff2bff78
15 files changed
+562
-38
No files matched your search
@@ -0,0 +1,33 @@
|
||||
package noppes.npcs.client.gui.script;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.client.Client;
|
||||
import noppes.npcs.client.gui.util.GuiNPCInterface;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
import noppes.npcs.controllers.data.ForgeDataScript;
|
||||
import noppes.npcs.controllers.data.NPCDataScript;
|
||||
|
||||
public class GuiScriptAllNPCs extends GuiScriptInterface {
|
||||
private NPCDataScript script = new NPCDataScript(null);
|
||||
|
||||
public GuiScriptAllNPCs() {
|
||||
this.handler = this.script;
|
||||
Client.sendData(EnumPacketServer.ScriptNPCGet, new Object[0]);
|
||||
}
|
||||
|
||||
public void setGuiData(NBTTagCompound compound) {
|
||||
this.script.readFromNBT(compound);
|
||||
super.setGuiData(compound);
|
||||
}
|
||||
|
||||
public void save() {
|
||||
super.save();
|
||||
Client.sendData(EnumPacketServer.ScriptNPCSave, new Object[]{this.script.writeToNBT(new NBTTagCompound())});
|
||||
}
|
||||
|
||||
public void close() {
|
||||
super.close();
|
||||
ScriptController.Instance.npcScripts.errored.clear();
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@ public class GuiScriptGlobal extends GuiNPCInterface {
|
||||
super.initGui();
|
||||
this.addButton(new GuiNpcButton(0, this.guiLeft + 38, this.guiTop + 20, 100, 20, "Players"));
|
||||
this.addButton(new GuiNpcButton(1, this.guiLeft + 38, this.guiTop + 50, 100, 20, "Forge"));
|
||||
this.addButton(new GuiNpcButton(2, this.guiLeft + 38, this.guiTop + 80, 100, 20, "NPCs"));
|
||||
}
|
||||
|
||||
public void drawScreen(int i, int j, float f) {
|
||||
@@ -42,6 +43,9 @@ public class GuiScriptGlobal extends GuiNPCInterface {
|
||||
if (guibutton.id == 1) {
|
||||
this.displayGuiScreen(new GuiScriptForge());
|
||||
}
|
||||
if (guibutton.id == 2) {
|
||||
this.displayGuiScreen(new GuiScriptAllNPCs());
|
||||
}
|
||||
}
|
||||
|
||||
public void keyTyped(char c, int i) {
|
||||
|
||||
@@ -35,6 +35,7 @@ import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.controllers.IScriptHandler;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
import noppes.npcs.controllers.data.ForgeDataScript;
|
||||
import noppes.npcs.controllers.data.NPCDataScript;
|
||||
import noppes.npcs.controllers.data.PlayerDataScript;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@@ -147,6 +148,22 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
|
||||
hookList.add("customGuiSlot");
|
||||
hookList.add("customGuiScroll");
|
||||
hookList.add("customGuiTextfield");
|
||||
|
||||
}
|
||||
else if(handler instanceof NPCDataScript) {
|
||||
hookList.add("init");
|
||||
hookList.add("tick");
|
||||
hookList.add("interact");
|
||||
hookList.add("dialog");
|
||||
hookList.add("damaged");
|
||||
hookList.add("killed");
|
||||
hookList.add("meleeAttack");
|
||||
hookList.add("rangedLaunched");
|
||||
hookList.add("target");
|
||||
hookList.add("collide");
|
||||
hookList.add("kills");
|
||||
hookList.add("dialogClose");
|
||||
hookList.add("timer");
|
||||
}
|
||||
else if(handler instanceof ForgeDataScript) {
|
||||
hooks.setSize(238, 198);
|
||||
|
||||
Reference in new issue
Block a user