Jump to content

[1.12.2] Mouse Cursor not visible/showing


ricosw

Recommended Posts

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
Link to comment
Share on other sites

  • 7 months later...

#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);
        }
    }

}

 

Link to comment
Share on other sites

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

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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