devguydan Posted March 13, 2019 Posted March 13, 2019 (edited) Trying to make sure I understand the lifecycle and best practices properly. The problem is, many tutorials, code examples, and even the docs, use practices that are either definitely outdated or contradict the logic that many people here have put forward. So I'm just going to start putting them here when I see something I think is like that. If anyone can clarify on any given code example, that would be great. I'll try to make the code examples isolated and clear what particular practice or aspect I am asking about. Edited February 10, 2020 by devguydan Outdated Quote I hate signatures, they're too distracting
devguydan Posted March 13, 2019 Author Posted March 13, 2019 First, I often have been seeing this. Where it is recommended to register/create blocks, items and entities in pre-init. Instead of in EventHandlers. I even saw one case where it was said EventHandlers run B4 pre-init, but after debugging, I found that was not the case. What is the current best practice in this regard? Here is an example of this practice /** * Run before anything else. Read your config, create blocks, items, etc, and register them with the GameRegistry */ public void preInit() { // register my Items, Blocks, Entities, etc } Quote I hate signatures, they're too distracting
Laike_Endaril Posted March 13, 2019 Posted March 13, 2019 (edited) Registering stuff in the registry events specifically designed for registering blocks, items, etc. is usually best practice unless you have a good reason to do otherwise (you'll know if you run into that kind of situation). Using the registry events generally puts things in the right execution order "automagically", as well as letting other modders predict when certain things will happen in a general sense even if they've never seen your source or don't even know your mod will be running alongside theirs (eg. if they're altering something fairly global). As for when you create the stuff...you'll get varied answers. I usually try to create whatever I'm going to register directly in the registration call if doing so is feasible. Edit: Righto, I should've posted what Ugdhar did, but I'm half asleep and didn't think of it Edited March 13, 2019 by Laike_Endaril Quote
DavidM Posted March 13, 2019 Posted March 13, 2019 1. As for good tutorials, TGG made a text-based one (personally, I would say this is one of the best tutorials out there as it explains every single concept in great detail (apart from the usage of the common proxy)) : https://github.com/TheGreyGhost/MinecraftByExample/tree/master/src/main/java/minecraftbyexample 2. Forge has an event handling system which makes processes like registering items and blocks easier. Always instantiate and register blocks/items in the corresponding event. Quote Some tips: Spoiler Modder Support: Spoiler 1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code. 2. Always post your code. 3. Never copy and paste code. You won't learn anything from doing that. 4. Quote Programming via Eclipse's hotfixes will get you nowhere 5. Learn to use your IDE, especially the debugger. 6. Quote The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it. Support & Bug Reports: Spoiler 1. Read the EAQ before asking for help. Remember to provide the appropriate log(s). 2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.
devguydan Posted March 13, 2019 Author Posted March 13, 2019 See that’s what I mean. He uses common proxy and he doesn’t use even handlers for registration. Yet every one still recommends him as an example? 1 Quote I hate signatures, they're too distracting
yuckyh Posted March 14, 2019 Posted March 14, 2019 14 hours ago, Ugdhar said: You should handle this problem in that thread Quote
Recommended Posts
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.