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

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 by devguydan
Outdated

I hate signatures, they're too distracting

  • Author

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
}

 

I hate signatures, they're too distracting

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 :P

Edited by Laike_Endaril

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.

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.

 

 

  • Author

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?

I hate signatures, they're too distracting

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.