Jump to content

[1.7.10] Opening gui from another gui


Solace7

Recommended Posts

I've made an item that has a GUI, and at the press of a button I want it to open another GUI. The only differences between where it works and where it doesnt is that one is being opened from a TileEntity and the other is opened from an ItemStack.

 

Here is an example of where its been done before

 

 

public class GuiDialingDevice extends BaseGui {
    public static final int CONTAINER_SIZE = 175, CONTAINER_WIDTH = 256;
    TileDialingDevice dial;
    TileController controller;
    GuiButton buttonDial;

    public GuiDialingDevice(TileDialingDevice d, EntityPlayer p) {
        super(new ContainerDialingDevice(d, p.inventory), CONTAINER_SIZE);
        texture = new ResourceLocation("enhancedportals", "textures/gui/dialling_device.png");
        xSize = CONTAINER_WIDTH;
        dial = d;
        controller = dial.getPortalController();
        name = "gui.dialDevice";
        setHidePlayerInventory();
    }

    @Override
    public void initGui() {
        super.initGui();

        buttonDial = new GuiButton(1, guiLeft + xSize - 147, guiTop + ySize - 27, 140, 20, Localization.get("gui.terminate"));
        buttonDial.enabled = controller.isPortalActive();
        buttonList.add(new GuiButton(0, guiLeft + 7, guiTop + ySize - 27, 100, 20, Localization.get("gui.manualEntry")));
        buttonList.add(buttonDial);

        addElement(new ElementScrollDiallingDevice(this, dial, 7, 28));
        addTab(new TabTip(this, "dialling"));
    }
    
@Override
    protected void actionPerformed(GuiButton button) {
        if (button.id == 0) // Manual Entry
        {
            EnhancedPortals.packetPipeline.sendToServer(new PacketRequestGui(dial, GuiHandler.ADDRESS_BOOK_B)); // Open DialingManual
        } else if (button.id == 1) // Terminate
            if (controller.isPortalActive()) {
                NBTTagCompound tag = new NBTTagCompound();
                tag.setBoolean("terminate", true);
                EnhancedPortals.packetPipeline.sendToServer(new PacketGuiData(tag));
            }
    }

 

 

 

Here is what I've done and tried to replicate

 

 

public class GuiAddressBook extends BaseGui
{

    public static final int CONTAINER_SIZE = 175, CONTAINER_WIDTH = 256;
    GuiButton buttonAddressBookEntry;

    public GuiAddressBook(EntityPlayer player)
    {
        super(new ContainerAddressBook(player.inventory), CONTAINER_SIZE);
        texture = new ResourceLocation("enhancedportals", "textures/gui/address_book.png");
        xSize = CONTAINER_WIDTH;
        name = "gui.addressBook";
        setHidePlayerInventory();
    }

    @Override
    public void initGui() {
        super.initGui();
        buttonAddressBookEntry = new GuiButton(0, guiLeft + 78, guiTop + ySize - 27, 100, 20, Localization.get("gui.addressEntry"));
        buttonList.add(buttonAddressBookEntry);

        //addElement(new ElementScrollAddressBook(this, addressBook, 7, 28));

    }

    @Override
    protected void actionPerformed(GuiButton button)
    {
        if (button.id == 0)
        {
            EnhancedPortals.packetPipeline.sendToServer(new PacketRequestGui(GuiHandler.ADDRESS_BOOK_B));
        }
    }

 

 

My GuiHandler, and PacketRequestGui

 

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.