Hey,
i am new to minecraft modding and to this forum and have to get used to a lot of things.
I was trying to make a custom GUI that is opened when I press a key.
In my ClientEvents file I want to read the Key input and start the GUI
@SubscribeEvent
public void onKeyInput(final KeyboardKeyPressedEvent event) {
if(event.getKeyCode() == 75) {
Minecraft.getInstance().displayGuiScreen(new DiceScreen());
}
But when i press "k", (supposed to be the Key with number 75) nothing happens.
This is my Screen class if needed:
@OnlyIn(Dist.CLIENT)
public class DiceScreen extends Screen {
private static final ResourceLocation BACKGROUND_TEXTURE = new ResourceLocation(DnD.MOD_ID,
"textures/gui/DiceScreen");
public DiceScreen() {
super(new TranslationTextComponent("jeldriks_dnd_mod.dice_screen"));
this.height = 81;
this.width = 175;
}
@Override
public void render(MatrixStack matrixStack, int mouseX, int mouseY, final float partialTicks) {
this.renderBackground(matrixStack);
super.render(matrixStack, mouseX, mouseY, partialTicks);
this.renderComponentHoverEffect(matrixStack, null, mouseX, mouseY);
}
@Override
public void renderBackground(MatrixStack matrixStack) {
super.renderBackground(matrixStack);
this.font.drawString(matrixStack, "Choose your dice to roll!", 8.0f, 6.0f, 4210752); // posx posy color
RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f);
this.minecraft.getTextureManager().bindTexture(BACKGROUND_TEXTURE);
int x = (this.width) / 2;
int y = (this.height) / 2;
this.blit(matrixStack, x, y, 0, 0, this.width, this.height);
}
}