Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[1.8.9] Keybinding Game Crash - Works In IDE But Not In Regular Forge Game

Featured Replies

Posted

Hello! After creating a keybinding class, I began testing through the IDE. All functions work perfect when I run the main class in Eclipse and play the temporary forge version of the game, but when I export and run the mod normally, the game crashes whenever a key is pressed.

 

Here is the error message:

The game crashed whilst unexpected error
Error: java.lang.NoSuchMethodError: net.minecraft.client.settings.KeyBinding.isPressed()Z

 

Here is my keyinputhandler class:

import net.minecraft.client.Minecraft;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.EnumChatFormatting;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.InputEvent;

public class KeyInputHandler {
    
    public Events eventsClass;
    
    public KeyInputHandler(Events eClass) {
        
        eventsClass = eClass;
        
    }
    
    @SubscribeEvent
    public void onKeyInput(InputEvent.KeyInputEvent e) {
        
        if (KeyBinds.toggleMsgs.isPressed()) {
        
            eventsClass.showMsgs = !eventsClass.showMsgs;
            if (eventsClass.showMsgs) {
                Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentTranslation(EnumChatFormatting.GREEN + "Messages toggled: " + EnumChatFormatting.GOLD + "ON" + EnumChatFormatting.GREEN + "!"));
            } else {
                Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentTranslation(EnumChatFormatting.GREEN + "Messages toggled: " + EnumChatFormatting.GOLD + "OFF" + EnumChatFormatting.GREEN + "!"));
            }
        
        } else if (KeyBinds.toggleGuild.isPressed()) {
        
            eventsClass.showGuild = !eventsClass.showGuild;
            if (eventsClass.showGuild) {
                Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentTranslation(EnumChatFormatting.GREEN + "Guild chat toggled: " + EnumChatFormatting.GOLD + "ON" + EnumChatFormatting.GREEN + "!"));
            } else {
                Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentTranslation(EnumChatFormatting.GREEN + "Guild chat toggled: " + EnumChatFormatting.GOLD + "OFF" + EnumChatFormatting.GREEN + "!"));
            }
        
        } else if (KeyBinds.toggleParty.isPressed()) {
        
            eventsClass.showParty = !eventsClass.showParty;
            if (eventsClass.showParty) {
                Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentTranslation(EnumChatFormatting.GREEN + "Party chat toggled: " + EnumChatFormatting.GOLD + "ON" + EnumChatFormatting.GREEN + "!"));
            } else {
                Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentTranslation(EnumChatFormatting.GREEN + "Party chat toggled: " + EnumChatFormatting.GOLD + "OFF" + EnumChatFormatting.GREEN + "!"));
            }
        
        } else if (KeyBinds.toggleAutoGG.isPressed()) {
        
            eventsClass.autoGG = !eventsClass.autoGG;
            if (eventsClass.autoGG) {
                Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentTranslation(EnumChatFormatting.GREEN + "Auto GG toggled: " + EnumChatFormatting.GOLD + "ON" + EnumChatFormatting.GREEN + "!"));
            } else {
                Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentTranslation(EnumChatFormatting.GREEN + "Auto GG toggled: " + EnumChatFormatting.GOLD + "OFF" + EnumChatFormatting.GREEN + "!"));
            }
        
        }
        
    }
    
}

 

Any insight would be helpful!

Why are you using 1.8.9? Update, that version is nearly 3 years old.

Please clarify

2 hours ago, Lqgback said:

when I export

 

You need to build your mod using gradle(gradlew build) to create a distributable jar file, you can't export(I assume you mean Eclipse's export feature) it.

In the future please consider using online services such as gist or pastebin to host your code snippets, or at least use the Code(<>) BB tag.

Edited by V0idWa1k3r

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.