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

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


Lqgback
 Share

Recommended Posts

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!

Link to comment
Share on other sites

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

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.