Implemented global Forge events. Reorganized NPC API files.

This commit is contained in:
luisc committed 2021-10-18 06:33:39 -05:00
1 parent c5ed7497c8
commit 72f2c3c60a
72 files changed
+321 -395

No files matched your search

@@ -9,7 +9,7 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import net.minecraft.client.gui.GuiButton;
import noppes.npcs.PlayerScriptContainer;
import noppes.npcs.EventScriptContainer;
import noppes.npcs.client.gui.util.GuiCustomScroll;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
@@ -18,10 +18,10 @@ import noppes.npcs.client.gui.util.SubGuiInterface;
public class EventGuiScriptList extends SubGuiInterface {
private GuiCustomScroll scroll1;
private GuiCustomScroll scroll2;
private PlayerScriptContainer container;
private EventScriptContainer container;
private List<String> scripts;
public EventGuiScriptList(List<String> scripts, PlayerScriptContainer container) {
public EventGuiScriptList(List<String> scripts, EventScriptContainer container) {
this.container = container;
this.setBackground("menubg.png");
this.xSize = 346;
@@ -0,0 +1,30 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.client.gui.script;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.Client;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.controllers.data.ForgeDataScript;
public class GuiScriptForge extends GuiScriptInterface {
private ForgeDataScript script = new ForgeDataScript();
public GuiScriptForge() {
this.handler = this.script;
Client.sendData(EnumPacketServer.ScriptForgeGet);
}
public void setGuiData(NBTTagCompound compound) {
this.script.readFromNBT(compound);
super.setGuiData(compound);
}
public void save() {
super.save();
Client.sendData(EnumPacketServer.ScriptForgeSave, script.writeToNBT(new NBTTagCompound()));
}
}
@@ -39,9 +39,9 @@ public class GuiScriptGlobal extends GuiNPCInterface {
if (guibutton.id == 0) {
this.displayGuiScreen(new GuiScriptPlayers());
}
/*if (guibutton.id == 1) {
if (guibutton.id == 1) {
this.displayGuiScreen(new GuiScriptForge());
}*/
}
}
public void keyTyped(char c, int i) {
@@ -28,7 +28,7 @@ import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.data.ForgeDataScript;
import noppes.npcs.controllers.data.PlayerDataScript;
public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallback, IGuiData, ITextChangeListener, ICustomScrollListener, IJTextAreaListener {
public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallback, IGuiData, ITextChangeListener, ICustomScrollListener, IJTextAreaListener, ITextfieldListener {
private int activeTab = 0;
public IScriptHandler handler;
public Map<String, List<String>> languages = new HashMap();
@@ -56,49 +56,12 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
GuiMenuTopButton top;
this.addTopButton(top = new GuiMenuTopButton(0, this.guiLeft + 4, this.guiTop - 17, "gui.settings"));
List<String> hookList = new ArrayList<String>();
if(handler instanceof PlayerDataScript) {
hookList.add("playerscript.disabled");
hookList.add("playerscript.init");
hookList.add("playerscript.tick");
hookList.add("playerscript.interact");
hookList.add("playerscript.damaged");
hookList.add("playerscript.killed");
hookList.add("playerscript.kills");
hookList.add("playerscript.chat");
hookList.add("playerscript.drop");
hookList.add("playerscript.containerOpen");
hookList.add("playerscript.login");
hookList.add("playerscript.logout");
hookList.add("playerscript.chat");
hookList.add("playerscript.damagedentity");
hookList.add("playerscript.keyPressed");
hookList.add("playerscript.mouseClicked");
hookList.add("playerscript.pickUp");
hookList.add("playerscript.rangedLaunched");
hookList.add("playerscript.pickupXP");
hookList.add("playerscript.timer");
hookList.add("playerscript.startItem");
hookList.add("playerscript.usingItem");
hookList.add("playerscript.stopItem");
hookList.add("playerscript.finishItem");
hookList.add("playerscript.fall");
hookList.add("playerscript.playSound");
hookList.add("playerscript.lightning");
hookList.add("playerscript.break");
hookList.add("playerscript.changedDim");
hookList.add("playerscript.respawn");
}
else if(handler instanceof ForgeDataScript){
hookList.add("forgescript.forgeInit");
}
int topXoffset = 0;
int topYoffset = 0;
for(int ta = 0; ta < this.handler.getScripts().size(); ++ta) {
if(ta%15 == 0 && ta > 0) {
if(ta%20 == 0 && ta > 0) {
topYoffset -= 20;
topXoffset -= top.width+260;
topXoffset -= top.width+20*22;
}
this.addTopButton(top = new GuiMenuTopButton(ta + 1, top.xPosition+top.width + topXoffset, top.yPosition + topYoffset, ta + 1 + ""));
topXoffset = 0;
@@ -106,7 +69,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
scriptLimit = ta + 2;
}
if(this.handler.getScripts().size() < 75)
if(this.handler.getScripts().size() < 100)
this.addTopButton(new GuiMenuTopButton(scriptLimit, top.xPosition+top.width, top.yPosition, "+"));
top = this.getTopButton(this.activeTab);
@@ -117,14 +80,54 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
top.active = true;
if(this.activeTab > 0) {
addLabel(new GuiNpcLabel(0, "script.hooks", guiLeft + 4, guiTop + 5));
GuiCustomScroll hooks = new GuiCustomScroll(this, 1);
hooks.setSize(68, 198);
hooks.guiLeft = guiLeft + 4;
hooks.guiTop = guiTop + 14;
hooks.setUnsortedList(hookList);
hooks.selected = getScriptHook(this.handler.getScripts().get(this.activeTab - 1),hookList);
addScroll(hooks);
if(handler instanceof PlayerDataScript) {
List<String> hookList = new ArrayList<String>();
hookList.add("playerscript.disabled");
hookList.add("playerscript.init");
hookList.add("playerscript.tick");
hookList.add("playerscript.interact");
hookList.add("playerscript.damaged");
hookList.add("playerscript.killed");
hookList.add("playerscript.kills");
hookList.add("playerscript.chat");
hookList.add("playerscript.drop");
hookList.add("playerscript.containerOpen");
hookList.add("playerscript.login");
hookList.add("playerscript.logout");
hookList.add("playerscript.chat");
hookList.add("playerscript.damagedentity");
hookList.add("playerscript.keyPressed");
hookList.add("playerscript.mouseClicked");
hookList.add("playerscript.pickUp");
hookList.add("playerscript.rangedLaunched");
hookList.add("playerscript.pickupXP");
hookList.add("playerscript.timer");
hookList.add("playerscript.startItem");
hookList.add("playerscript.usingItem");
hookList.add("playerscript.stopItem");
hookList.add("playerscript.finishItem");
hookList.add("playerscript.fall");
hookList.add("playerscript.playSound");
hookList.add("playerscript.lightning");
hookList.add("playerscript.break");
hookList.add("playerscript.changedDim");
hookList.add("playerscript.respawn");
addLabel(new GuiNpcLabel(0, "script.hooks", guiLeft + 4, guiTop + 5));
GuiCustomScroll hooks = new GuiCustomScroll(this, 1);
hooks.setSize(68, 198);
hooks.guiLeft = guiLeft + 4;
hooks.guiTop = guiTop + 14;
hooks.setUnsortedList(hookList);
hooks.selected = getScriptHook(this.handler.getScripts().get(this.activeTab - 1),hookList);
addScroll(hooks);
}
else if(handler instanceof ForgeDataScript){
addLabel(new GuiNpcLabel(0, "script.hooks", guiLeft + 4, guiTop + 5));
GuiNpcTextField hookField = new GuiNpcTextField(1,this,this.fontRendererObj,guiLeft + 4,guiTop + 14,68,20,"");
hookField.setText(this.handler.getScripts().get(this.activeTab - 1).type);
addTextField(hookField);
}
EventScriptContainer var7 = (EventScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
GuiNpcTextArea left = new GuiNpcTextArea(2, this, this.guiLeft + 72 + yoffset, this.guiTop + yoffset, this.xSize - 180 - yoffset, (int)((double)this.ySize * 0.96D) - yoffset * 2, var7 == null?"":var7.script);
@@ -175,6 +178,13 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
this.handler.getScripts().get(this.activeTab - 1).setType(scroll.getSelected().replace("playerscript.",""));
}
@Override
public void unFocused(GuiNpcTextField textfield) {
if(textfield.id == 1){
this.handler.getScripts().get(this.activeTab - 1).setType(textfield.getText());
}
}
private int getScriptHook(EventScriptContainer eventScriptContainer, List<String> list) {
for(String s : list) {
if (s.replace("playerscript.", "").equals(eventScriptContainer.type)) {
@@ -334,8 +344,6 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
text = text.replace("\r\n", "\n");
text = text.replace("\r", "\n");
container.script = text;
ScriptController.Instance.playerScripts.errored.clear();
}
}
@@ -9,6 +9,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.Client;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.data.PlayerDataScript;
public class GuiScriptPlayers extends GuiScriptInterface {
@@ -28,4 +29,9 @@ public class GuiScriptPlayers extends GuiScriptInterface {
super.save();
Client.sendData(EnumPacketServer.ScriptPlayerSave, script.writeToNBT(new NBTTagCompound()));
}
public void close() {
super.close();
ScriptController.Instance.playerScripts.errored.clear();
}
}