Started by
Biscuit_Blender
on
Topic category: Help with Minecraft modding (Java Edition)
i'm trying to make a gui that pops up on screen for a few seconds, but the player can just press escape to close it before its supposed to be closed, how can i make it so it can't be closed by a player?
When you are inside of the GUI menu there is a "GUI procedure triggers [Click to expand]" text.
Click on click to expand and there is a trigger triggered when gui is closed.
Click add new one and make it open the same gui when the player closes it.
That's only 1 tick difference so there will be so little period between its opening and closing it might even be seemless.
you can use variables and the wait () ticks block to make it closeable after a amount of time, you can use this to calculate seconds to minecraft ticks (the link is a fork of a codepen project, the original was broken so i made this fork to fix it)
For NeoForge simply edit the gui SCREEN class code and change this.
@Override
public boolean keyPressed(int key, int b, int c) {
if (key == 256) {
this.minecraft.player.closeContainer();
return true;
}
return super.keyPressed(key, b, c);
}
to this
@Override
public boolean keyPressed(int key, int b, int c) {
return super.keyPressed(key, b, c);
}
nvm it's not this.
Do this.
```
@Override
public boolean keyPressed(int key, int scanCode, int modifiers) {
if (key == GLFW.GLFW_KEY_ESCAPE || key == GLFW.GLFW_KEY_E) {
// Swallow these keys so they do nothing
return true;
}
return super.keyPressed(key, scanCode, modifiers);
}
```
abdulhananre hanaziz, people could just remap their open inventory key to something other than E, and they could bypass it