Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.12] Mouse cursor disappearing in custom GUI


Stenbergcsgo
 Share

Recommended Posts

I created a simple gui, based on the sign gui:

package com.mta.utzonmod.client.gui;

import java.io.IOException;

import org.lwjgl.input.Keyboard;

import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.ChatAllowedCharacters;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class signInputGui extends GuiScreen {
	
	private GuiButton doneBtn;
	
	private int updateCounter;
	
	private int editLine;
	
	public String playerInput;
	
	public void initGui() {
		this.buttonList.clear();
		Keyboard.enableRepeatEvents(true);
		this.doneBtn = this.addButton(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 120, I18n.format("gui.done")));	
	}
	
	public void onGuiClosed() {
		Keyboard.enableRepeatEvents(false);
	}
	
	public void updateScreen() {
		++this.updateCounter;
	}
	
	protected void actionPerformed(GuiButton button) throws IOException {
		if(button.enabled) {
			if(button.id == 0) {
				this.mc.displayGuiScreen((GuiScreen)null);
			}
		}
	}
	
	public final ITextComponent[] signText = new ITextComponent[] {new TextComponentString(""), new TextComponentString(""), new TextComponentString(""), new TextComponentString("")};
	
//	protected void keyTyped(char typedChar, int keyCode) throws IOException {
//		if(keyCode == 200) {
//			this.editLine = this.editLine - 1 & 3;
//		}
//		
//		if (keyCode == 208 || keyCode == 28 || keyCode == 156) {
//			this.editLine = this.editLine + 1 & 3;
//		}
//		
//		for (int i = 0; i < 4; ++i)
//        {
//            playerInput = ITextComponent.Serializer.componentToJson(this.signText[i]);
//        }
//		
//		if (keyCode == 14 && !playerInput.isEmpty()) {
//			playerInput = playerInput.substring(0, playerInput.length() - 1);
//		}
//		
//		if (ChatAllowedCharacters.isAllowedCharacter(typedChar) && this.fontRenderer.getStringWidth(playerInput + typedChar) <= 90) {
//			playerInput = playerInput + typedChar;
//		}
//		
//		if (keyCode == 1) {
//			this.actionPerformed(this.doneBtn);
//		}	
//	}
	
	public void drawScreen(int mouseX, int mouseY, float partialTicks) {
		this.drawDefaultBackground();
		this.drawCenteredString(this.fontRenderer, I18n.format("sign.edit"),this.width / 2, 40, 16777215);
		GlStateManager.color(1.0F,  1.0F,  1.0F, 1.0F);
		GlStateManager.pushMatrix();
		GlStateManager.translate((float)(this.width / 2), 0.0F, 50.0F);
		
        GlStateManager.scale(-93.75F, -93.75F, -93.75F);
        GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);
		
		GlStateManager.popMatrix();
		super.drawScreen(mouseX, mouseY, partialTicks);
	}
}

 

But for some reason when I open the GUI, my cursor disappears completely. Am I missing a function, or where am I going wrong?

Link to comment
Share on other sites

I'm not sure if this will help you, but you can at least try. I've had this problem myself too, and I'm not quite sure what fixed it, but I think it might be the way that you do the drawScreen(). Try this:

1. Backup that entire class in case I mess everything up by letting you do the next 3 steps :P

2. Let your class extend the GuiContainer class

3. Fix any errors that step 2 causes

4. remove this part:

public void drawScreen(int mouseX, int mouseY, float partialTicks) {
	this.drawDefaultBackground();
	this.drawCenteredString(this.fontRenderer, I18n.format("sign.edit"),this.width / 2, 40, 16777215);
	GlStateManager.color(1.0F,  1.0F,  1.0F, 1.0F);
	GlStateManager.pushMatrix();
	GlStateManager.translate((float)(this.width / 2), 0.0F, 50.0F);
	
	GlStateManager.scale(-93.75F, -93.75F, -93.75F);
	GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);
	
	GlStateManager.popMatrix();
	super.drawScreen(mouseX, mouseY, partialTicks);
}

5. add this to the class:

@Override
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
	//Whatever you want to draw goes here	
}

I hope this was helpful,

Lenardjee

Link to comment
Share on other sites

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

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.