Files
CustomNPC-Plus/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAdvanced.java
T

167 lines
6.4 KiB
Java
Raw Normal View History

2018-09-13 12:03:28 -04:00
package noppes.npcs.client.gui.mainmenu;
2025-02-02 02:25:21 -05:00
import kamkeel.npcs.network.PacketClient;
2025-02-02 03:28:13 -05:00
import kamkeel.npcs.network.packets.request.jobs.JobGetPacket;
2025-02-02 02:25:21 -05:00
import kamkeel.npcs.network.packets.request.mainmenu.MainmenuAdvancedGetPacket;
import kamkeel.npcs.network.packets.request.mainmenu.MainmenuAdvancedSavePacket;
2025-02-02 16:07:16 -05:00
import kamkeel.npcs.network.packets.request.role.RoleGetPacket;
2018-09-13 12:03:28 -04:00
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.NoppesStringUtils;
import noppes.npcs.client.Client;
import noppes.npcs.client.NoppesUtil;
2023-01-12 21:33:06 -05:00
import noppes.npcs.client.gui.advanced.*;
import noppes.npcs.client.gui.roles.*;
2018-09-13 12:03:28 -04:00
import noppes.npcs.client.gui.util.GuiNPCInterface2;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.IGuiData;
import noppes.npcs.constants.EnumGuiType;
import noppes.npcs.constants.EnumJobType;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.constants.EnumRoleType;
import noppes.npcs.entity.EntityNPCInterface;
public class GuiNpcAdvanced extends GuiNPCInterface2 implements IGuiData
{
private boolean hasChanges = false;
public GuiNpcAdvanced(EntityNPCInterface npc)
{
super(npc, 4);
2025-02-02 02:25:21 -05:00
PacketClient.sendClient(new MainmenuAdvancedGetPacket());
2018-09-13 12:03:28 -04:00
}
2025-02-02 02:25:21 -05:00
2018-09-13 12:03:28 -04:00
@Override
public void initGui(){
super.initGui();
int y = guiTop + 10;
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()));
2018-09-13 12:03:28 -04:00
getButton(3).setEnabled(npc.advanced.role != EnumRoleType.None && npc.advanced.role != EnumRoleType.Postman);
2024-02-29 20:33:29 -05:00
this.addButton(new GuiNpcButton(4, guiLeft + 85 + 160, y += 22, 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()));
2018-09-13 12:03:28 -04:00
getButton(4).setEnabled(npc.advanced.job != EnumJobType.None && npc.advanced.job != EnumJobType.ChunkLoader);
2024-02-29 20:33:29 -05:00
this.addButton(new GuiNpcButton(7, guiLeft + 15, y += 22, 190, 20, "advanced.lines"));
this.addButton(new GuiNpcButton(9, guiLeft + 208, y, 190, 20, "menu.factions"));
2024-02-21 03:02:39 -05:00
2024-02-29 20:33:29 -05:00
this.addButton(new GuiNpcButton(10, guiLeft + 15, y += 22, 190, 20, "dialog.dialogs"));
this.addButton(new GuiNpcButton(11, guiLeft + 208, y, 190, 20, "advanced.sounds"));
this.addButton(new GuiNpcButton(12, guiLeft + 15, y += 22, 190, 20, "advanced.night"));
this.addButton(new GuiNpcButton(13, guiLeft + 208, y, 190, 20, "global.linked"));
this.addButton(new GuiNpcButton(14, guiLeft + 15, y += 22, 190, 20, "menu.tags"));
2024-02-21 03:02:39 -05:00
this.addButton(new GuiNpcButton(15, guiLeft + 208, y, 190, 20, "advanced.marks"));
2018-09-13 12:03:28 -04:00
}
@Override
protected void actionPerformed(GuiButton guibutton) {
GuiNpcButton button = (GuiNpcButton) guibutton;
if (button.id == 3) {
save();
2025-02-02 16:07:16 -05:00
PacketClient.sendClient(new RoleGetPacket());
2018-09-13 12:03:28 -04:00
}
if(button.id == 8){
hasChanges = true;
npc.advanced.setRole(button.getValue());
getButton(3).setEnabled(npc.advanced.role != EnumRoleType.None && npc.advanced.role != EnumRoleType.Postman);
}
if(button.id == 4){
save();
2025-02-02 03:28:13 -05:00
PacketClient.sendClient(new JobGetPacket());
2018-09-13 12:03:28 -04:00
}
if(button.id == 5){
hasChanges = true;
npc.advanced.setJob(button.getValue());
2024-02-21 03:02:39 -05:00
2018-09-13 12:03:28 -04:00
getButton(4).setEnabled(npc.advanced.job != EnumJobType.None && npc.advanced.job != EnumJobType.ChunkLoader);
}
if(button.id == 9){
save();
NoppesUtil.openGUI(player, new GuiNPCFactionSetup(npc));
}
if(button.id == 10){
save();
NoppesUtil.openGUI(player, new GuiNPCDialogNpcOptions(npc,this));
}
if(button.id == 11){
save();
NoppesUtil.openGUI(player, new GuiNPCSoundsMenu(npc));
}
if (button.id == 7) {
save();
NoppesUtil.openGUI(player, new GuiNPCLinesMenu(npc));
}
if(button.id == 12){
save();
NoppesUtil.openGUI(player, new GuiNPCNightSetup(npc));
}
if(button.id == 13){
save();
NoppesUtil.openGUI(player, new GuiNPCAdvancedLinkedNpc(npc));
}
if(button.id == 14){
save();
NoppesUtil.openGUI(player, new GuiNPCTagSetup(npc));
}
2024-02-21 03:02:39 -05:00
if(button.id == 15){
save();
NoppesUtil.openGUI(player, new GuiNPCMarks(npc));
}
2018-09-13 12:03:28 -04:00
}
@Override
public void setGuiData(NBTTagCompound compound) {
if(compound.hasKey("RoleData")){
if(npc.roleInterface != null)
npc.roleInterface.readFromNBT(compound);
2024-02-21 03:02:39 -05:00
2018-09-13 12:03:28 -04:00
if(npc.advanced.role == EnumRoleType.Trader)
NoppesUtil.requestOpenGUI(EnumGuiType.SetupTrader);
else if(npc.advanced.role == EnumRoleType.Follower)
NoppesUtil.requestOpenGUI(EnumGuiType.SetupFollower);
else if(npc.advanced.role == EnumRoleType.Bank)
NoppesUtil.requestOpenGUI(EnumGuiType.SetupBank);
else if(npc.advanced.role == EnumRoleType.Transporter)
displayGuiScreen(new GuiNpcTransporter(npc));
else if(npc.advanced.role == EnumRoleType.Companion)
displayGuiScreen(new GuiNpcCompanion(npc));
}
else if(compound.hasKey("JobData")){
if(npc.jobInterface != null)
npc.jobInterface.readFromNBT(compound);
2024-02-21 03:02:39 -05:00
2018-09-13 12:03:28 -04:00
if(npc.advanced.job == EnumJobType.Bard)
NoppesUtil.openGUI(player, new GuiNpcBard(npc));
else if(npc.advanced.job == EnumJobType.Healer)
NoppesUtil.openGUI(player, new GuiNpcHealer(npc));
else if(npc.advanced.job == EnumJobType.Guard)
NoppesUtil.openGUI(player, new GuiNpcGuard(npc));
else if(npc.advanced.job == EnumJobType.ItemGiver)
NoppesUtil.requestOpenGUI(EnumGuiType.SetupItemGiver);
else if(npc.advanced.job == EnumJobType.Follower)
NoppesUtil.openGUI(player, new GuiNpcFollowerJob(npc));
else if(npc.advanced.job == EnumJobType.Spawner)
NoppesUtil.openGUI(player, new GuiNpcSpawner(npc));
else if(npc.advanced.job == EnumJobType.Conversation)
NoppesUtil.openGUI(player, new GuiNpcConversation(npc));
}
else{
npc.advanced.readToNBT(compound);
initGui();
}
}
2024-02-21 03:02:39 -05:00
2018-09-13 12:03:28 -04:00
@Override
public void save() {
if(hasChanges){
2025-02-02 02:25:21 -05:00
PacketClient.sendClient(new MainmenuAdvancedSavePacket(npc.advanced.writeToNBT(new NBTTagCompound())));
2018-09-13 12:03:28 -04:00
hasChanges = false;
}
}
2024-02-21 03:02:39 -05:00
2018-09-13 12:03:28 -04:00
}