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

130 lines
4.2 KiB
Java
Raw Normal View History

2018-09-13 12:03:28 -04:00
package noppes.npcs.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiYesNo;
import net.minecraft.client.gui.GuiYesNoCallback;
import net.minecraft.entity.Entity;
import net.minecraft.util.StatCollector;
import noppes.npcs.client.Client;
import noppes.npcs.client.NoppesUtil;
2023-01-12 21:33:06 -05:00
import noppes.npcs.client.gui.util.*;
2018-09-13 12:03:28 -04:00
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.entity.EntityNPCInterface;
2023-01-12 21:33:06 -05:00
import java.util.HashMap;
import java.util.Vector;
2018-09-13 12:03:28 -04:00
public class GuiNpcRemoteEditor extends GuiNPCInterface implements IScrollData, GuiYesNoCallback{
2024-02-19 19:14:51 -05:00
2018-09-13 12:03:28 -04:00
private GuiCustomScroll scroll;
private HashMap<String, Integer> data = new HashMap<String, Integer>();
public GuiNpcRemoteEditor() {
super();
xSize = 256;
setBackground("menubg.png");
Client.sendData(EnumPacketServer.RemoteNpcsGet);
2024-03-11 16:10:23 -04:00
Client.sendData(EnumPacketServer.RemoteFreezeGet);
2018-09-13 12:03:28 -04:00
}
public void initGui()
{
super.initGui();
if(scroll == null){
2023-11-06 19:19:17 -05:00
scroll = new GuiCustomScroll(this,0, 0);
2018-09-13 12:03:28 -04:00
scroll.setSize(165, 208);
}
scroll.guiLeft = guiLeft + 4;
scroll.guiTop = guiTop + 4;
addScroll(scroll);
2024-02-19 19:14:51 -05:00
2018-09-13 12:03:28 -04:00
String title = StatCollector.translateToLocal("remote.title");
int x = (xSize - this.fontRendererObj.getStringWidth(title)) / 2;
2024-02-19 19:14:51 -05:00
2018-09-13 12:03:28 -04:00
this.addLabel(new GuiNpcLabel(0, title, guiLeft + x, guiTop - 8));
this.addButton(new GuiNpcButton(0, guiLeft + 170, guiTop + 6,82,20, "selectServer.edit"));
this.addButton(new GuiNpcButton(1, guiLeft + 170, guiTop + 28,82,20, "selectWorld.deleteButton"));
this.addButton(new GuiNpcButton(2, guiLeft + 170, guiTop + 50,82,20, "remote.reset"));
this.addButton(new GuiNpcButton(3, guiLeft + 170, guiTop + 132,82,20, "remote.freeze"));
2018-09-13 12:03:28 -04:00
this.addButton(new GuiNpcButton(4, guiLeft + 170, guiTop + 72,82,20, "remote.tp"));
this.addButton(new GuiNpcButton(5, guiLeft + 170, guiTop + 110,82,20, "remote.resetall"));
this.addButton(new GuiNpcButton(6, guiLeft + 170, guiTop + 165,82,20, "menu.global"));
2018-09-13 12:03:28 -04:00
}
@Override
public void confirmClicked(boolean flag, int i){
if(flag){
Client.sendData(EnumPacketServer.RemoteDelete,data.get(scroll.getSelected()));
}
NoppesUtil.openGUI(player, this);
}
protected void actionPerformed(GuiButton guibutton)
{
int id = guibutton.id;
if(id == 3){
Client.sendData(EnumPacketServer.RemoteFreeze);
}
if(id == 5){
for(int ids : data.values()){
Client.sendData(EnumPacketServer.RemoteReset, ids);
Entity entity = player.worldObj.getEntityByID(ids);
if(entity != null && entity instanceof EntityNPCInterface)
((EntityNPCInterface)entity).reset();
}
}
if(id == 6){
2023-04-02 21:12:56 -05:00
NoppesUtil.setLastNpc(null);
2024-02-19 19:14:51 -05:00
Client.sendData(EnumPacketServer.RemoteGlobalMenu);
}
2024-02-19 19:14:51 -05:00
2018-09-13 12:03:28 -04:00
if(!data.containsKey(scroll.getSelected()))
return;
2024-02-19 19:14:51 -05:00
2018-09-13 12:03:28 -04:00
if(id == 0){
Client.sendData(EnumPacketServer.RemoteMainMenu,data.get(scroll.getSelected()));
}
if(id == 1){
GuiYesNo guiyesno = new GuiYesNo(this, "Confirm", StatCollector.translateToLocal("gui.delete"), 0);
displayGuiScreen(guiyesno);
}
if(id == 2){
Client.sendData(EnumPacketServer.RemoteReset,data.get(scroll.getSelected()));
Entity entity = player.worldObj.getEntityByID(data.get(scroll.getSelected()));
if(entity != null && entity instanceof EntityNPCInterface)
((EntityNPCInterface)entity).reset();
}
if(id == 4){
Client.sendData(EnumPacketServer.RemoteTpToNpc,data.get(scroll.getSelected()));
close();
}
}
2024-02-19 19:14:51 -05:00
2018-09-13 12:03:28 -04:00
@Override
public void mouseClicked(int i, int j, int k)
{
super.mouseClicked(i, j, k);
scroll.mouseClicked(i, j, k);
}
@Override
public void keyTyped(char c, int i)
{
if (i == 1 || isInventoryKey(i))
{
close();
}
}
@Override
public void save() {
// TODO Auto-generated method stub
2024-02-19 19:14:51 -05:00
2018-09-13 12:03:28 -04:00
}
@Override
public void setData(Vector<String> list, HashMap<String, Integer> data) {
scroll.setList(list);
this.data = data;
}
@Override
public void setSelected(String selected) {
getButton(3).setDisplayText(selected);
}
}