Jump to content

Recommended Posts

Posted

Hey guys,

 

I'm pretty confused by the new registry system. All the tutorials and example mods I could find still do it the old way. Even the ones that claim to be 1.12 still often use GameRegistry.register(), wich doesn't exist anymore (or am I blind?). Does anyone know a good tutorial or example mod that explains the new system?

 

Thanks

Posted
51 minutes ago, Kombat Kitten said:

Even the ones that claim to be 1.12 still often use GameRegistry.register(), wich doesn't exist anymore (or am I blind?).

It's private.

Please link any 1.12 tutorials that are still doing it that way so that we can inform them that they're either doing it wrong or falsely claiming to be a 1.12 tutorial.

 

The new way feels oddly roundabout to me, but there are certain advantages to it (namely that the game can do a full rebuild of blocks and items while the game is running, should it need to).

 

Essentially you need to subscribe to the RegistryEvent.Register<T> events (and you'll put the type of object you want to register where the T is, e.g. RegistryEvent.Register<Block>) and call event.getRegistry().register(...) on all of your things. Note that you will have to register item forms of your blocks yourself if you want your blocks to exist as items (i.e. pickup-able).

 

You will also need to subscribe to the ModelRegistryEvent in order to register item models (though you still call ModelLoader.setCustomModelResourceLocation(...))

 

If you would like, I have set up two classes that I call my Easy Registry. It is essentially a wrapper around these things the way GameRegistry used to wrap around vanilla and forge internals.

 

https://github.com/Draco18s/ReasonableRealism/blob/1.12.1/src/main/java/com/draco18s/hardlib/EasyRegistry.java

https://github.com/Draco18s/ReasonableRealism/blob/1.12.1/src/main/java/com/draco18s/hardlib/client/ClientEasyRegistry.java

Note that the EasyRegistry classes are effectively both event handler (for the aforementioned events) and the proxy classes for my library:

https://github.com/Draco18s/ReasonableRealism/blob/1.12.1/src/main/java/com/draco18s/hardlib/HardLib.java#L44

 

You do not need to clone all of HardLib to make this work, you can re-point the references to your own library or main mod class, although there are some helpful interfaces you might want (that handle things like custom IStateMappers and so on).  Usage is very simple and easy.

 

It is also advised that you use @ObjectHolder annotations on your block/item fields (which I am not currently doing) in order to allow other mods to override your own (the "Substitution Alias" system wrought 1.12), see Lex's comments here:

 

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.

Posted

Bad tutorials is a thing we do our best to fight against, letting their authors know about the problems so they can be fixed. No worries if you can't find them again, it just would have been helpful. :)

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.

Posted
1 hour ago, Kokkie said:

Kombat Kitten you can look at your browser history (if it is safe to look at right now ( ͡° ͜ʖ ͡°))

Haha it is... though I've visited a few hundred websites today (learning to mod = using the internet, as you might know).

 

Further I have some problems with registering my texture. This is the code I have now:

https://github.com/KombatKitten/Collision/tree/Forums-Question/src

 

Does anyone know what I'm doing wrong?

Posted

Not related to your problem, but:

https://github.com/KombatKitten/Collision/blob/Forums-Question/src/main/java/com/github/KombatKitten/dimensionalMagic/CommonProxy.java#L43-L44

You shouldn't do this. You should set the unlocalized name to the registry name so that your mod ID appears in the unlocalized name (this avoids conflicts with two mods naming their item the same thing).

 

Post your log file.

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.

Posted
12 hours ago, Draco18s said:

Not related to your problem, but:

https://github.com/KombatKitten/Collision/blob/Forums-Question/src/main/java/com/github/KombatKitten/dimensionalMagic/CommonProxy.java#L43-L44

You shouldn't do this. You should set the unlocalized name to the registry name so that your mod ID appears in the unlocalized name (this avoids conflicts with two mods naming their item the same thing).

 

Post your log file.

like this?
        SIMPLEBLOCKI.setRegistryName(Reference.MODID, "simpleblock");
        SIMPLEBLOCKI.setUnlocalizedName(SIMPLEBLOCKI.getRegistryName().toString());

I changed unlocalized name of the block too.

 

console output (if that's what you mean): https://pastebin.com/G1Ha0F2T

 

 

Posted
5 hours ago, Kombat Kitten said:

like this?
        SIMPLEBLOCKI.setRegistryName(Reference.MODID, "simpleblock");
        SIMPLEBLOCKI.setUnlocalizedName(SIMPLEBLOCKI.getRegistryName().toString());

I changed unlocalized name of the block too.

Yep.

5 hours ago, Kombat Kitten said:

console output (if that's what you mean): https://pastebin.com/G1Ha0F2T

Huh, I don't see anything in there.

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.

Posted
1 minute ago, Kombat Kitten said:

you mean it's empty?

No, I mean I don't see any errors being logged.

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.

Posted

@Choonster Can we get your eyes on this? You seem to be more adept than anyone in finding issues with item model problems.

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.

Posted

@Mod.EventBusSubscriber registers the Class with the event bus, so only static @SubscribeEvent methods will be called. Your RegistryEvent.Register handlers in CommonProxy and ClientProxy are non-static, so they will never be called.

 

There's no need to handle Block/Item registration in your proxies, do it in common classes (e.g. DMBlocks/DMItems).

 

There's no reason to have a common proxy class, since proxies are for sided code. Common code belongs in your @Mod class or other common classes.

 

Always annotate override methods with @Override so you get a compilation error if they don't actually override/implement a super method.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
9 minutes ago, Choonster said:

@Mod.EventBusSubscriber registers the Class with the event bus, so only static @SubscribeEvent methods will be called. Your RegistryEvent.Register handlers in CommonProxy and ClientProxy are non-static, so they will never be called.

Ah ha. I still have trouble spotting this even though I know to look for it.

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.

Posted
58 minutes ago, Choonster said:

@Mod.EventBusSubscriber registers the Class with the event bus, so only static @SubscribeEvent methods will be called. Your RegistryEvent.Register handlers in CommonProxy and ClientProxy are non-static, so they will never be called.

Yeah, I already changed them to static because I got an error. Now the error is gone but the block and the item are still using the basic textures (the item is acquirable through /give and the creative tab and the block is placable). I have pushed all the changes to GitHub.

Btw, the display name of the block/item is still equal to the unlocalized name, even though I have set up a .lang file. Maybe this could have something to do with de model not loading? Something could be wrong with the registering of the block and item.

Posted
9 minutes ago, Kombat Kitten said:

Btw, the display name of the block/item is still equal to the unlocalized name, even though I have set up a .lang file. Maybe this could have something to do with de model not loading? Something could be wrong with the registering of the block and item.

https://github.com/KombatKitten/Collision/tree/Forums-Question/src/main/resources/assets/dimensional_magic/lang

Your langfile is incorrectly named. It should be en_us.lang (all lower case).

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.

Posted
On 17-9-2017 at 7:02 PM, Choonster said:

@Mod.EventBusSubscriber registers the Class with the event bus, so only static @SubscribeEvent methods will be called. Your RegistryEvent.Register handlers in CommonProxy and ClientProxy are non-static, so they will never be called.

 

I changed them to static, but it's still not working. I don't think the problem is in the java code so could you take a look at the .json files? I might have made a mistake there

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.