Jump to content

Recommended Posts

Posted

I made my own keybindings and registered them, they worked fine, but when I opened the "controls" screen to edit keybindings, the game crashes

 

Am i doing anything wrong?

 

Crash log

 

  Reveal hidden contents

 

 

Code

package com.williameze.minegicka3;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.KeyBinding;

import org.lwjgl.input.Keyboard;

import com.williameze.minegicka3.main.Element;

import cpw.mods.fml.client.registry.ClientRegistry;

public class ModKeybinding extends KeyBinding
{
    public Element element;

    public static Map<Element, ModKeybinding> elementToKeyMap = new HashMap();
    public static ModKeybinding keyWater = new ModKeybinding("Water", Keyboard.KEY_Y, Element.Water);
    public static ModKeybinding keyLife = new ModKeybinding("Life", Keyboard.KEY_U, Element.Life);
    public static ModKeybinding keyShield = new ModKeybinding("Shield", Keyboard.KEY_I, Element.Shield);
    public static ModKeybinding keyCold = new ModKeybinding("Cold", Keyboard.KEY_O, Element.Cold);
    public static ModKeybinding keyLightning = new ModKeybinding("Lightning", Keyboard.KEY_H, Element.Lightning);
    public static ModKeybinding keyArcane = new ModKeybinding("Arcane", Keyboard.KEY_J, Element.Arcane);
    public static ModKeybinding keyEarth = new ModKeybinding("Earth", Keyboard.KEY_K, Element.Earth);
    public static ModKeybinding keyFire = new ModKeybinding("Fire", Keyboard.KEY_L, Element.Fire);
    public static List<ModKeybinding> elementKeys = Arrays.asList(keyWater, keyLife, keyShield, keyCold, keyLightning, keyArcane, keyEarth,
    keyFire);

    public static KeyBinding keyArea = new KeyBinding("Area Cast", Keyboard.KEY_F, "key.categories." + ModBase.MODID);
    public static KeyBinding keyClear = new KeyBinding("Clear Queued", Keyboard.KEY_V, "key.categories." + ModBase.MODID);
    public static KeyBinding keyMagick = new KeyBinding("Cast Magick", Keyboard.KEY_R, "key.categories." + ModBase.MODID);

    public static void load()
    {
for (ModKeybinding k : elementKeys)
{
    ClientRegistry.registerKeyBinding(k);
}
ClientRegistry.registerKeyBinding(keyArea);
ClientRegistry.registerKeyBinding(keyClear);
ClientRegistry.registerKeyBinding(keyMagick);
    }
    
    public ModKeybinding(String description, int id, String s)
    {
super(description, id, s);
    }

    public ModKeybinding(String description, int id, Element e)
    {
this(description, id, "key.categories." + ModBase.MODID);
element = e;
elementToKeyMap.put(e, this);
    }
}

Posted

You have a null pointer exception occurring in GuiListExtended for whatever reason:

Caused by: java.lang.NullPointerException
   at net.minecraft.client.gui.GuiListExtended.func_148181_b(GuiListExtended.java:70) ~[GuiListExtended.class:?]
   at net.minecraft.client.gui.GuiControls.mouseMovedOrUp(GuiControls.java:111) ~[GuiControls.class:?]
   at net.minecraft.client.gui.GuiScreen.handleMouseInput(GuiScreen.java:349) ~[GuiScreen.class:?]
   at net.minecraft.client.gui.GuiSlot.drawScreen(GuiSlot.java:314) ~[GuiSlot.class:?]
   at net.minecraft.client.gui.GuiControls.drawScreen(GuiControls.java:148) ~[GuiControls.class:?]
   at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1143) ~[EntityRenderer.class:?]

I don't have MC code open at the moment, so I need ask, is GuiListExtended your class, or a vanilla class? If it's your class, we'll need to see the code for it; if not, then whatever you are doing to access func_148181_b is causing a null pointer.

Posted

Something in your environment is registering a keybinding that's null.

Check the load order of your calls.

 

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

  • 2 months later...
  • 6 months later...
Posted
  On 5/18/2014 at 1:40 PM, WilliamLe said:

I made my own keybindings and registered them, they worked fine, but when I opened the "controls" screen to edit keybindings, the game crashes

 

Am i doing anything wrong?

 

Crash log

 

  Reveal hidden contents

 

 

Code

package com.williameze.minegicka3;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.KeyBinding;

import org.lwjgl.input.Keyboard;

import com.williameze.minegicka3.main.Element;

import cpw.mods.fml.client.registry.ClientRegistry;

public class ModKeybinding extends KeyBinding
{
    public Element element;

    public static Map<Element, ModKeybinding> elementToKeyMap = new HashMap();
    public static ModKeybinding keyWater = new ModKeybinding("Water", Keyboard.KEY_Y, Element.Water);
    public static ModKeybinding keyLife = new ModKeybinding("Life", Keyboard.KEY_U, Element.Life);
    public static ModKeybinding keyShield = new ModKeybinding("Shield", Keyboard.KEY_I, Element.Shield);
    public static ModKeybinding keyCold = new ModKeybinding("Cold", Keyboard.KEY_O, Element.Cold);
    public static ModKeybinding keyLightning = new ModKeybinding("Lightning", Keyboard.KEY_H, Element.Lightning);
    public static ModKeybinding keyArcane = new ModKeybinding("Arcane", Keyboard.KEY_J, Element.Arcane);
    public static ModKeybinding keyEarth = new ModKeybinding("Earth", Keyboard.KEY_K, Element.Earth);
    public static ModKeybinding keyFire = new ModKeybinding("Fire", Keyboard.KEY_L, Element.Fire);
    public static List<ModKeybinding> elementKeys = Arrays.asList(keyWater, keyLife, keyShield, keyCold, keyLightning, keyArcane, keyEarth,
    keyFire);

    public static KeyBinding keyArea = new KeyBinding("Area Cast", Keyboard.KEY_F, "key.categories." + ModBase.MODID);
    public static KeyBinding keyClear = new KeyBinding("Clear Queued", Keyboard.KEY_V, "key.categories." + ModBase.MODID);
    public static KeyBinding keyMagick = new KeyBinding("Cast Magick", Keyboard.KEY_R, "key.categories." + ModBase.MODID);

    public static void load()
    {
for (ModKeybinding k : elementKeys)
{
    ClientRegistry.registerKeyBinding(k);
}
ClientRegistry.registerKeyBinding(keyArea);
ClientRegistry.registerKeyBinding(keyClear);
ClientRegistry.registerKeyBinding(keyMagick);
    }
    
    public ModKeybinding(String description, int id, String s)
    {
super(description, id, s);
    }

    public ModKeybinding(String description, int id, Element e)
    {
this(description, id, "key.categories." + ModBase.MODID);
element = e;
elementToKeyMap.put(e, this);
    }
}

 

Can I ask why you are making your own class extending KeyBinding? Why not just use new KeyBinding(name, key, category)?

Romejanic

 

Creator of Witch Hats, Explosive Chickens and Battlefield!

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.

Announcements



×
×
  • Create New...

Important Information

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