HarryTechRevs / MinecraftModding1.13

The code for Harry Talks' Minecraft Modding Tutorials for MC 1.14 and 1.13
15 stars 9 forks source link

dont use static initializers #1

Open loordgek opened 5 years ago

loordgek commented 5 years ago

What: Not using static initialisers.

Why: Using static initialisers does not allow you to control when your objects are created or the order in which your objects are created. Consequences: Using static initialisers prevents other mods from overriding your objects, prevents forge from being able to dynamically load/unload mods and can cause weird, unreproducible crashes.

How: Use the @ObjectHolder annotation if you need static references to your objects and create & register your objects in the appropriate registry event. (Note: before registry events Modders created and registered their items in preInit. This practice became out of date in 1.7 with the introduction of registry events, and is no longer possible in 1.13).

source: https://gist.github.com/Cadiboo/fbea89dc95ebbdc58d118f5350b7ba93#recommended-forge-conventions

loordgek commented 5 years ago

and the same goes for 1.12