mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-21 16:12:17 +00:00
Tags can now be added through a new sub gui in the NPC advanced tab.
This commit is contained in:
1 parent
9a6cf94c73
commit
aba24fc93c
7 files changed
+182
-20
No files matched your search
@@ -0,0 +1,117 @@
|
||||
package noppes.npcs.client.gui.advanced;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import noppes.npcs.client.Client;
|
||||
import noppes.npcs.client.gui.SubGuiNpcFactionOptions;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class GuiNPCTagSetup extends GuiNPCInterface2 implements IScrollData,ICustomScrollListener,IGuiData
|
||||
{
|
||||
private GuiCustomScroll scrollTags;
|
||||
private GuiCustomScroll npcTags;
|
||||
private HashMap<String,Integer> data = new HashMap<>();
|
||||
private final ArrayList<String> tagNames = new ArrayList<>();
|
||||
|
||||
public GuiNPCTagSetup(EntityNPCInterface npc)
|
||||
{
|
||||
super(npc);
|
||||
Client.sendData(EnumPacketServer.TagsGet);
|
||||
Client.sendData(EnumPacketServer.NpcTagsGet);
|
||||
}
|
||||
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
if(scrollTags == null){
|
||||
scrollTags = new GuiCustomScroll(this,0);
|
||||
scrollTags.setSize(120, 180);
|
||||
}
|
||||
scrollTags.guiLeft = guiLeft + 50;
|
||||
scrollTags.guiTop = guiTop + 24;
|
||||
this.addScroll(scrollTags);
|
||||
|
||||
if(npcTags == null){
|
||||
npcTags = new GuiCustomScroll(this,1);
|
||||
npcTags.setSize(120, 180);
|
||||
}
|
||||
npcTags.guiLeft = guiLeft + width - 180;
|
||||
npcTags.guiTop = guiTop + 24;
|
||||
npcTags.setList(tagNames);
|
||||
this.addScroll(npcTags);
|
||||
|
||||
addButton(new GuiNpcButton(10, guiLeft + 180, guiTop + 90, 55, 20, ">"));
|
||||
addButton(new GuiNpcButton(11, guiLeft + 180, guiTop + 112, 55, 20, "<"));
|
||||
|
||||
addButton(new GuiNpcButton(12, guiLeft + 180, guiTop + 140, 55, 20, ">>"));
|
||||
addButton(new GuiNpcButton(13, guiLeft + 180, guiTop + 162, 55, 20, "<<"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buttonEvent(GuiButton guibutton) {
|
||||
if (guibutton.id == 10 && scrollTags.hasSelected() && !tagNames.contains(scrollTags.getSelected())) {
|
||||
tagNames.add(scrollTags.getSelected());
|
||||
}
|
||||
if (guibutton.id == 12) {
|
||||
tagNames.clear();
|
||||
tagNames.addAll(data.keySet());
|
||||
}
|
||||
if (guibutton.id == 11 && npcTags.hasSelected()) {
|
||||
tagNames.remove(npcTags.getSelected());
|
||||
}
|
||||
if (guibutton.id == 13) {
|
||||
tagNames.clear();
|
||||
}
|
||||
initGui();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setData(Vector<String> list, HashMap<String, Integer> data)
|
||||
{
|
||||
this.data = data;
|
||||
scrollTags.setList(list);
|
||||
initGui();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGuiData(NBTTagCompound compound) {
|
||||
NBTTagList tagList = compound.getTagList("TagNames",8);
|
||||
tagNames.clear();
|
||||
for (int i = 0; i < tagList.tagCount(); i++) {
|
||||
tagNames.add(tagList.getStringTagAt(i));
|
||||
}
|
||||
}
|
||||
|
||||
public void mouseClicked(int i, int j, int k)
|
||||
{
|
||||
super.mouseClicked(i, j, k);
|
||||
if(k == 0 && scrollTags != null)
|
||||
scrollTags.mouseClicked(i, j, k);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelected(String selected) {
|
||||
scrollTags.setSelected(selected);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) {
|
||||
}
|
||||
|
||||
public void save() {
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
for (String string : this.tagNames) {
|
||||
tagList.appendTag(new NBTTagString(string));
|
||||
}
|
||||
tagCompound.setTag("TagNames",tagList);
|
||||
Client.sendData(EnumPacketServer.TagSet, tagCompound);
|
||||
}
|
||||
}
|
||||
@@ -27,21 +27,24 @@ public class GuiNpcAdvanced extends GuiNPCInterface2 implements IGuiData
|
||||
@Override
|
||||
public void initGui(){
|
||||
super.initGui();
|
||||
this.addButton(new GuiNpcButton(3, guiLeft + 85 + 160, guiTop + 20, 52, 20, "selectServer.edit"));
|
||||
this.addButton(new GuiNpcButton(8, guiLeft + 85, guiTop + 20,155,20, new String[]{"role.none","role.trader","role.follower","role.bank","role.transporter", "role.mailman", NoppesStringUtils.translate("role.companion", "(WIP)")},npc.advanced.role.ordinal()));
|
||||
int y = guiTop + 10;
|
||||
int gap = 21;
|
||||
this.addButton(new GuiNpcButton(3, guiLeft + 85 + 160, y, 52, 20, "selectServer.edit"));
|
||||
this.addButton(new GuiNpcButton(8, guiLeft + 85, y,155,20, new String[]{"role.none","role.trader","role.follower","role.bank","role.transporter", "role.mailman", NoppesStringUtils.translate("role.companion", "(WIP)")},npc.advanced.role.ordinal()));
|
||||
getButton(3).setEnabled(npc.advanced.role != EnumRoleType.None && npc.advanced.role != EnumRoleType.Postman);
|
||||
|
||||
this.addButton(new GuiNpcButton(4, guiLeft + 85 + 160, guiTop + 43, 52, 20, "selectServer.edit"));
|
||||
this.addButton(new GuiNpcButton(5, guiLeft + 85, guiTop + 43,155,20, new String[]{"job.none","job.bard","job.healer","job.guard","job.itemgiver","role.follower", "job.spawner", "job.conversation", "job.chunkloader"},npc.advanced.job.ordinal()));
|
||||
this.addButton(new GuiNpcButton(4, guiLeft + 85 + 160, y += gap, 52, 20, "selectServer.edit"));
|
||||
this.addButton(new GuiNpcButton(5, guiLeft + 85, y,155,20, new String[]{"job.none","job.bard","job.healer","job.guard","job.itemgiver","role.follower", "job.spawner", "job.conversation", "job.chunkloader"},npc.advanced.job.ordinal()));
|
||||
|
||||
getButton(4).setEnabled(npc.advanced.job != EnumJobType.None && npc.advanced.job != EnumJobType.ChunkLoader);
|
||||
|
||||
this.addButton(new GuiNpcButton(7, guiLeft + 85, guiTop + 66, 214, 20, "advanced.lines"));
|
||||
this.addButton(new GuiNpcButton(9, guiLeft + 85, guiTop + 89, 214, 20, "menu.factions"));
|
||||
this.addButton(new GuiNpcButton(10, guiLeft + 85, guiTop + 112, 214, 20, "dialog.dialogs"));
|
||||
this.addButton(new GuiNpcButton(11, guiLeft + 85, guiTop + 135, 214, 20, "advanced.sounds"));
|
||||
this.addButton(new GuiNpcButton(12, guiLeft + 85, guiTop + 158, 214, 20, "advanced.night"));
|
||||
this.addButton(new GuiNpcButton(13, guiLeft + 85, guiTop + 181, 214, 20, "global.linked"));
|
||||
this.addButton(new GuiNpcButton(7, guiLeft + 85, y += gap, 214, 20, "advanced.lines"));
|
||||
this.addButton(new GuiNpcButton(9, guiLeft + 85, y += gap, 214, 20, "menu.factions"));
|
||||
this.addButton(new GuiNpcButton(10, guiLeft + 85, y += gap, 214, 20, "dialog.dialogs"));
|
||||
this.addButton(new GuiNpcButton(11, guiLeft + 85, y += gap, 214, 20, "advanced.sounds"));
|
||||
this.addButton(new GuiNpcButton(12, guiLeft + 85, y += gap, 214, 20, "advanced.night"));
|
||||
this.addButton(new GuiNpcButton(13, guiLeft + 85, y += gap, 214, 20, "global.linked"));
|
||||
this.addButton(new GuiNpcButton(14, guiLeft + 85, y += gap, 214, 20, "menu.tags"));
|
||||
|
||||
}
|
||||
|
||||
@@ -92,6 +95,10 @@ public class GuiNpcAdvanced extends GuiNPCInterface2 implements IGuiData
|
||||
save();
|
||||
NoppesUtil.openGUI(player, new GuiNPCAdvancedLinkedNpc(npc));
|
||||
}
|
||||
if(button.id == 14){
|
||||
save();
|
||||
NoppesUtil.openGUI(player, new GuiNPCTagSetup(npc));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user