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.

Featured Replies

Posted

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?

 

 

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.

  • 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 :)

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

Named registry were introduced in 1.7.

1.6.4 only use numerical id. The preferred method was Configuration#getItem.

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

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.