Jump to content

Close GuiScreen


bkvaluemeal

Recommended Posts

I made a gui and it works, but I can only close it using the escape key. How can I set this to the 'E' key?

 

Look at the GuiContainer class.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

I made a gui and it works, but I can only close it using the escape key. How can I set this to the 'E' key?

 

Look at the GuiContainer class.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

Your Gui can extend GuiScreen and your block can implement ITileEntityProvider if you don't want a container. This also means that you don't need to pass a Container to the server in your GuiHandler. I know this works because my mod currently already does this. As for closing the currently opened Gui, just use:

mc.displayGuiScreen((GuiScreen)null);

if calling this from a gui window, or:

Minecraft.getMinecraft().displayGuiScreen((GuiScreen)null);

from anywhere else in the client code.

 

If you want to close it with the E key, then you'll have you use a KeyHandler. There are plenty of tutorials about them. Be aware that if you register a KeyBinding using the same key as one that Minecraft already uses, it'll override it and make it not function normally anymore. This means that if you bind the above code to the E key, opening your inventory won't work anymore

...unless you use this little trick that I figured out myself:

Minecraft.getMinecraft().gameSettings.keyBindJump = KeysHandler.jump;

In this case, I have my own KeyBinding (KeysHandler.jump) using the space key. By binding Minecraft's normal keybind to mine, both it and my mod can use the key however they needs to.

width=336 height=83http://img836.imageshack.us/img836/1237/cooltext624963071.png[/img]

I make games, minecraft mods/plugins, and some graphic art.

 

Current Project: LoECraft - An industrial minecraft server with its own modpack and custom launcher.

Link to comment
Share on other sites

Your Gui can extend GuiScreen and your block can implement ITileEntityProvider if you don't want a container. This also means that you don't need to pass a Container to the server in your GuiHandler. I know this works because my mod currently already does this. As for closing the currently opened Gui, just use:

mc.displayGuiScreen((GuiScreen)null);

if calling this from a gui window, or:

Minecraft.getMinecraft().displayGuiScreen((GuiScreen)null);

from anywhere else in the client code.

 

If you want to close it with the E key, then you'll have you use a KeyHandler. There are plenty of tutorials about them. Be aware that if you register a KeyBinding using the same key as one that Minecraft already uses, it'll override it and make it not function normally anymore. This means that if you bind the above code to the E key, opening your inventory won't work anymore

...unless you use this little trick that I figured out myself:

Minecraft.getMinecraft().gameSettings.keyBindJump = KeysHandler.jump;

In this case, I have my own KeyBinding (KeysHandler.jump) using the space key. By binding Minecraft's normal keybind to mine, both it and my mod can use the key however they needs to.

width=336 height=83http://img836.imageshack.us/img836/1237/cooltext624963071.png[/img]

I make games, minecraft mods/plugins, and some graphic art.

 

Current Project: LoECraft - An industrial minecraft server with its own modpack and custom launcher.

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



×
×
  • Create New...

Important Information

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