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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Pretty sure you get that error because ShapelessRecipe is only for recipes that are crafted using a grid, and don't need to be arranged in a certain way. You have to use AbstractCookingRecipe for any recipe that uses the [smeltable item - fuel item - result item] combination. But I don't think you really need to be messing with code here for recipes. You should just be able to copy what the minecraft\recipes\iron_ingot_from_smelting_raw_iron.json does and replace the ingredient item and your result item:   { "type": "minecraft:smelting", "category": "misc", "cookingtime": 200, "experience": 0.7, "group": "iron_ingot", "ingredient": { "item": "minecraft:raw_iron" }, "result": "minecraft:iron_ingot" } or just add the block to the logs_that_burn_tag since the Minecraft recipe for charcoal uses that: { "type": "minecraft:smelting", "category": "misc", "cookingtime": 200, "experience": 0.15, "ingredient": { "tag": "minecraft:logs_that_burn" }, "result": "minecraft:charcoal" }
    • If you don't want an item to have a recipe then simply don't create the .json file for it in the `your_mod/recipes/` directory.
    • This feels like a really basic question, but my mind is just drawing a blank right now. Trying to get the ResourceLocation of an Item to use with ImageWidget#sprite, so if there is a better way of doing this, do let me know.
    • I created a modpack to play with friends but it crashes saying The game crashed whilst rendering overlay Error: java.lang.NullPointerException: Cannot invoke "me.codexadrian.tempad.TempadClientConfig.renderBlur()" because the return value of "me.codexadrian.tempad.TempadClient.getClientConfig()" is null. What do I do?
×
×
  • Create New...

Important Information

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