Jump to content

[1.12] Can not register to a locked registry


Chuckinator

Recommended Posts

I have the error above. It says the error is on line 72 which says

Public void init (FMLInitializationEvent e){

registerItems ();

}

The registerItems method is made with this code 

Public void registerItems (RegistryEvent.Register <Item> event){

       event.getRegistry ().register (new Item ().setRegistryName ("testmod", "testitem"));

        event.getRegistry ().register (new ItemSword (Item.ToolMaterial.DIAMOND).setRegistryName ("flashmod", "flash_sword"));

Link to comment
Share on other sites

public void registerItems(RegistryEvent.Register<Item>event)

You wrote the type and parameter name in the same word twice in different classes. This will never work. Also, you need to store the items in variables, you can't just do create new objects and be done with it. If you ever want to check if the player is holding your sword, for example, you can't because you don't have it stored in a variable.

Link to comment
Share on other sites

I do know java. I had commented that part out in main and moved to init.

14 minutes ago, That_Martin_Guy said:

public void registerItems(RegistryEvent.Register<Item>event)

You wrote the type and parameter name in the same word twice in different classes. This will never work. Also, you need to store the items in variables, you can't just do create new objects and be done with it. If you ever want to check if the player is holding your sword, for example, you can't because you don't have it stored in a variable.

How do I do that?

Link to comment
Share on other sites

27 minutes ago, Chuckinator said:
Quote

Also, you need to store the items in variables, you can't just do create new objects and be done with it.

How do I do that?

 

6 minutes ago, Chuckinator said:

I KNOW FRICKIN JAVA.

That doesn't look like you know java, and people don't want to waste their time teaching people basic java concepts, so please try to explain exactly what you are struggling with, rather than just complaining that people are judging you. The more information you give, the more we can help.

Link to comment
Share on other sites

30 minutes ago, Chuckinator said:

I KNOW FRICKIN JAVA. I HAVE BEEN DOING FOR YEARS

No you don't, not when you ask questions like "how do I make a variable?"

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

4 minutes ago, That_Martin_Guy said:

Imports can be static. Also, let's not go out of our way to call out this guy on every mistake he makes. Whether he's new to java or not, we should not get abusive.

Sorry, didn't look well enough... And please don't talk about abusive... Sorry that was just.. Something...

Classes: 94

Lines of code: 12173

Other files: 206

Github repo: https://github.com/KokkieBeer/DeGeweldigeMod

Link to comment
Share on other sites

Ah, now I see that variable. Your code is all over the place as far as I can tell from these files, and it's a bit hard to find them.

 

All you should have to do, besides the things we've already told you about, is pass the variable into event#getRegistry#register.

 

Also, not directly related, but don't use Item#registerItems. This is minecraft code to be used on minecraft items only. Do not call this method yourself. You should not even import it.

 

Also also, correct me if I'm wrong, but you don't need/should use GameRegistry#ObjectHolder. It just makes the code look ugly AFAIK (again, could be wrong).

Link to comment
Share on other sites

1 hour ago, That_Martin_Guy said:

Also also, correct me if I'm wrong, but you don't need/should use GameRegistry#ObjectHolder. It just makes the code look ugly AFAIK (again, could be wrong).

I think using @ObjectHolder is the intended way of using registries, and seeing that every test mod using registries uses them @ObjectHolder, it would make sense to use it as well. Also, the docs say this is the recommended way.

Edited by larsgerrits
  • Like 1

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

2 hours ago, That_Martin_Guy said:

Ah, now I see that variable. Your code is all over the place as far as I can tell from these files, and it's a bit hard to find them.

 

All you should have to do, besides the things we've already told you about, is pass the variable into event#getRegistry#register.

 

Also, not directly related, but don't use Item#registerItems. This is minecraft code to be used on minecraft items only. Do not call this method yourself. You should not even import it.

 

Also also, correct me if I'm wrong, but you don't need/should use GameRegistry#ObjectHolder. It just makes the code look ugly AFAIK (again, could be wrong).

Whats with the hastags?

And I dont know what passing a variable through is?

Link to comment
Share on other sites

9 minutes ago, Chuckinator said:

Whats with the hastags?

It means a field/method etc. is static.

 

10 minutes ago, Chuckinator said:

And I dont know what passing a variable through is?

You need to call

2 hours ago, That_Martin_Guy said:

event#getRegistry#register

using the variable as a parameter.

Classes: 94

Lines of code: 12173

Other files: 206

Github repo: https://github.com/KokkieBeer/DeGeweldigeMod

Link to comment
Share on other sites

20 minutes ago, Kokkie said:

It means a field/method etc. is static

No, no it does not. It means the exact opposite. 

  • Like 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

RegisterEvent.Register#getRegistry() is a method. You need to call it like a method.

Edited by larsgerrits

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

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