Scripted Items Display Errors & Fix Console Scroll Wheel and Scroll Bar

This commit is contained in:
Kam committed 2025-02-09 04:02:16 -05:00
1 parent 4202cb7271
commit eeb6b2ea8b
8 files changed
+198 -40

No files matched your search

@@ -20,7 +20,7 @@ import java.util.*;
import java.util.Map.Entry;
public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallback, IGuiData, ITextChangeListener, ICustomScrollListener, IJTextAreaListener, ITextfieldListener {
private int activeTab = 0;
protected int activeTab = 0;
public IScriptHandler handler;
public Map<String, List<String>> languages = new HashMap();
private int scriptLimit = 1;
@@ -113,7 +113,8 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
this.addScroll(scroll);
} else {
GuiNpcTextArea var8 = new GuiNpcTextArea(2, this, this.guiLeft + 4 + yoffset, this.guiTop + 6 + yoffset, this.xSize - 160 - yoffset, (int)((float)this.ySize * 0.92F) - yoffset * 2, this.getConsoleText());
var8.enabled = false;
var8.canEdit = false;
var8.setFocused(true);
this.addTextField(var8);
int var9 = this.guiLeft + this.xSize - 150;
this.addButton(new GuiNpcButton(100, var9, this.guiTop + 125, 60, 20, "gui.copy"));
@@ -159,7 +160,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
}
private String getConsoleText() {
protected String getConsoleText() {
Map<Long, String> map = this.handler.getConsoleText();
StringBuilder builder = new StringBuilder();
Iterator var3 = map.entrySet().iterator();
@@ -1,15 +1,26 @@
package noppes.npcs.client.gui.script;
import kamkeel.npcs.network.packets.request.script.ItemScriptPacket;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.request.script.item.ItemScriptErrorPacket;
import kamkeel.npcs.network.packets.request.script.item.ItemScriptPacket;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.CustomItems;
import noppes.npcs.NBTTags;
import noppes.npcs.NoppesStringUtils;
import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.scripted.item.ScriptCustomItem;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
public class GuiScriptItem extends GuiScriptInterface {
private ScriptCustomItem item;
public static Map<Long, String> consoleText = new HashMap<>();
public GuiScriptItem() {
hookList.add("init");
@@ -26,17 +37,47 @@ public class GuiScriptItem extends GuiScriptInterface {
hookList.add("finishItem");
this.handler = this.item = new ScriptCustomItem(new ItemStack(CustomItems.scripted_item));
ItemScriptErrorPacket.Get();
ItemScriptPacket.Get();
}
public void setGuiData(NBTTagCompound compound) {
this.item.setMCNbt(compound);
this.item.loadScriptData();
super.setGuiData(compound);
if(compound.hasKey("ItemScriptConsole")){
consoleText = NBTTags.GetLongStringMap(compound.getTagList("ItemScriptConsole", 10));
initGui();
}
else {
this.item.setMCNbt(compound);
this.item.loadScriptData();
super.setGuiData(compound);
}
}
public void save() {
super.save();
ItemScriptPacket.Save(this.item.getMCNbt());
}
protected String getConsoleText() {
Map<Long, String> map = consoleText;
StringBuilder builder = new StringBuilder();
Iterator var3 = map.entrySet().iterator();
while(var3.hasNext()) {
Map.Entry<Long, String> entry = (Map.Entry)var3.next();
builder.insert(0, new Date((Long)entry.getKey()) + (String)entry.getValue() + "\n");
}
return builder.toString();
}
public void confirmClicked(boolean flag, int i) {
if(i == 102) {
if (activeTab <= 0){
consoleText = new HashMap<>();
ItemScriptErrorPacket.Clear();
}
}
super.confirmClicked(flag, i);
}
}