Posted June 1, 201411 yr Since my last post in a way stalled, I decided to start a new one for the error I was now getting. Basically when I try to execute GameData.itemRegistry.getObjectByName(String) I seem to be getting an error with the itemRegistry; Here is the error: itemRegistry cannot be resolved or is not a field Any idea what could be causing this?
June 1, 201411 yr From my understanding, you're trying to register a item, and then get it's object for some popuse, however, what you should do is: public static Item item = new YourItem(2000); GameRegistry.registerItem(item); Where YourItem is a class that extends Item, or extends another class that extends Item, and 2000 is the id; This way you keep the reference to your object, and can later refer to it, without using "GameData.itemRegistry.getObjectByName(String)" (Which I had never heard of). Besides, this is basic Java logic, if you need a object for later use, keep it in a variable.
June 1, 201411 yr Author From my understanding, you're trying to register a item, and then get it's object for some popuse, however, what you should do is: public static Item item = new YourItem(2000); GameRegistry.registerItem(item); Where YourItem is a class that extends Item, or extends another class that extends Item, and 2000 is the id; This way you keep the reference to your object, and can later refer to it, without using "GameData.itemRegistry.getObjectByName(String)" (Which I had never heard of). Besides, this is basic Java logic, if you need a object for later use, keep it in a variable. This isnt registering a single item, it is going to be used to read names from a config file (rather complicated, see my old post). The error means exactly what it says: The field you are referring to does not exist. Use GameRegistry.getItemRegistry Cheers ill test it and report back
June 1, 201411 yr From my understanding, you're trying to register a item, and then get it's object for some popuse, however, what you should do is: public static Item item = new YourItem(2000); GameRegistry.registerItem(item); Where YourItem is a class that extends Item, or extends another class that extends Item, and 2000 is the id; This way you keep the reference to your object, and can later refer to it, without using "GameData.itemRegistry.getObjectByName(String)" (Which I had never heard of). Besides, this is basic Java logic, if you need a object for later use, keep it in a variable. This isnt registering a single item, it is going to be used to read names from a config file (rather complicated, see my old post). Still you could, probably use a List and a for loop; And I'm not gonna search for your old post, if you want, send a link...
June 1, 201411 yr Named registry were introduced in 1.7. 1.6.4 only use numerical id. The preferred method was Configuration#getItem.
June 2, 201411 yr Author Named registry were introduced in 1.7. 1.6.4 only use numerical id. The preferred method was Configuration#getItem. Ah rats Meh ill use numerical ids for now I guess. Is the method just Configuration#getItem() or does it need any extra? Thanks.
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.