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

Hello I have an Problem with my GUI when I open them with

Minecraft.getMinecraft().displayGuiScreen(guiBuilder);
//OR
player.openGui(...)

The Mouse Cursor is not visible if I hover over my buttons it works clicking it works too but the Cursor is still invisible if I go out of Minecraft and go back the Cursor works fine.

 

My Gui:

import com.google.gson.Gson;
import de.ricosw.data.GuiButtonClick;
import de.ricosw.hhmod.HHMod;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.io.IOException;
import java.util.HashMap;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.network.PacketBuffer;
import net.minecraftforge.fml.common.network.internal.FMLProxyPacket;

/**
 *
 * @author Rico 
 */
public class GuiBuilder extends GuiScreen {

    private HHMod mod;
    private HashMap<GuiButton, Integer> guiButtons;
    
    private int guiId = -1;

    public GuiBuilder(HHMod mod, int guiId, HashMap<GuiButton, Integer> guiButtons) {
        this.mod = mod;
        this.guiId = guiId;
        this.guiButtons = guiButtons;
    }

    @Override
    public void drawScreen(int mouseX, int mouseY, float partialTicks) {
        this.drawDefaultBackground(); 
        super.drawScreen(mouseX, mouseY, partialTicks);
    }

    @Override
    public void initGui() {
        for (GuiButton buttons : guiButtons.keySet()) {
            System.out.println(buttons);
            this.buttonList.add(buttons);
        }
        super.initGui();
    }

    @Override
    protected void actionPerformed(GuiButton button) throws IOException {
        if (guiButtons.containsKey(button)) {
            
            //...
        }
    }

    @Override
    public void updateScreen() {
        super.updateScreen();
    }
}

 

Edit:

I opening the Gui in ClientCustomPacketEvent

Edited by ricosw
changed game version

  • Author

Update:

I have changed the Cursor I mean the image and it shows me it.

But If I set an windows cursor on mac and linux will it be the windows cursor any ideas? 

  • 7 months later...
  • Author

#push

Version: 1.12.2

Mouse Cursor is invisible

 

I'm opening the gui at the ClientCustomPacketEvent

any ideas? 

 

 

public class ClientPacketHandler extends ServerPacketHandler {

    private TestMod testMod;

    public ClientPacketHandler(TestMod testMod) {
        this.testMod = testMod;
    }
    
    @SubscribeEvent
    public void onClientPacket(ClientCustomPacketEvent event) throws IOException {
        channelName = event.getPacket().channel();
        System.out.println("Message on channel " + channelName);
        if(channelName.equals("TESTMOD")) {
            System.out.println("target: " + event.getPacket().getTarget().name()); // TARGET IS CLIENT
            System.out.println("Client recived packet from server");
            ProcessPacketClientSide.processPacketOnClient(testMod, event.getPacket().payload(), event.getPacket().getTarget());
        }
    }

}

 

public class ProcessPacketClientSide {

    public ProcessPacketClientSide() {
    }

    @SideOnly(Side.CLIENT)
    public static void processPacketOnClient(TestMod testMod, ByteBuf parBB, Side parSide) {
        try {
            if (parSide != Side.CLIENT) {
                System.out.println("ERROR! ProcessPacketClientSide");
                return;
            }
            
            

            System.out.println("Received ProcessPacketClientSide on Client Side");
            ByteBufInputStream bbis = new ByteBufInputStream(parBB);
            String data = bbis.readLine();

            /* DOING HERE MY GUI STUFF */
            
            Minecraft.getMinecraft().player.openGui(testMod, gui.getGuiId(), Minecraft.getMinecraft().player.world, 0, 0, 0);
            // ON GUI OPEN THE MOUSE CURSOR IS NOT VISIBLE BUT I CAN HOVER BUTTONS AND CLICK THEM
          
          
            /*Minecraft.getMinecraft().setIngameNotInFocus();
            Minecraft.getMinecraft().inGameHasFocus = false;
            Minecraft.getMinecraft().displayGuiScreen(guiBuilder);
            Minecraft.getMinecraft().currentScreen.allowUserInput = true;*/
            //Mouse.setGrabbed(false);
            //Minecraft.getMinecraft().mouseHelper.ungrabMouseCursor();
            //Mouse.setGrabbed(false);

        } catch (IOException ex) {
            Logger.getLogger(ProcessPacketClientSide.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

}

 

  • 3 months later...
  • 2 months later...

Ive encountered the same problem today. Not sure why this is not working.

 

When i saved the ui to open and called .openGui() from a clientTickListener it worked.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

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.