neoforged / MDK

The Mod Developer Kit - this is where you start if you want to develop a new mod
https://github.com/NeoForgeMDKs
185 stars 59 forks source link

Comment about the constructor being the first code run is wrong #78

Open ChiefArug opened 3 months ago

ChiefArug commented 3 months ago

https://github.com/neoforged/MDK/blob/7e54020d1a2777d3ebffc0e1d224632aa2b5ae9d/src/main/java/com/example/examplemod/ExampleMod.java#L70 This is technically wrong because static stuff (the <clinit> method) is run before the constructor. In the MDK that is the MODID, LOGGER and all the DeferredThing fields being filled. It doesn't change the result much but its still technically wrong :nerd_face:. (also this isn't counting coremodding stuff, but I feel like that can generally be considered a separate part of your mod as sharing anything between them is a major recipe for classloading disaster)

Some parentheses could be added for clarification, like

// The constructor for the mod class is the first code that is run when your mod is loaded (after static blocks and fields are executed)