Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

 

 

Guest
This topic is now closed to further replies.

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.