TheAwesomeGem Posted December 24, 2017 Posted December 24, 2017 On the official doc, I see that @ObjectHolder injects values and that if the class has that annotation, all the public static final members do as well. But what does it mean? What if I have a "public static final Block test_block" variable. What will forge inject into it? Will it auto register that block? Quote New Channel: https://www.youtube.com/theawesomegemily'>https://www.youtube.com/theawesomegemily My Group: https://www.youtube.com/officialpixelgem Old Channel: https://www.youtube.com/theawesomegem
jabelar Posted December 24, 2017 Posted December 24, 2017 It doesn't auto-register the block. It actually does the opposite -- you register the block and it will go back and inject an instance to all the fields that match name. Whether you use it depends on your coding style. I don't necessarily name my fields the same as the registry names so have to add the additional matching name, and so I don't find it really provides me a lot of convenience. But some people really like to use it. 1 Quote Check out my tutorials here: http://jabelarminecraft.blogspot.com/
LexManos Posted December 24, 2017 Posted December 24, 2017 Overrides. Quote I do Forge for free, however the servers to run it arn't free, so anything is appreciated. Consider supporting the team on Patreon
TheAwesomeGem Posted December 24, 2017 Author Posted December 24, 2017 52 minutes ago, LexManos said: Overrides. 4 hours ago, jabelar said: It doesn't auto-register the block. It actually does the opposite -- you register the block and it will go back and inject an instance to all the fields that match name. Whether you use it depends on your coding style. I don't necessarily name my fields the same as the registry names so have to add the additional matching name, and so I don't find it really provides me a lot of convenience. But some people really like to use it. Which means if I were to have a public static final Item ItemName from another mod, whenever that mod loads, my variable will get injected it's data? Quote New Channel: https://www.youtube.com/theawesomegemily'>https://www.youtube.com/theawesomegemily My Group: https://www.youtube.com/officialpixelgem Old Channel: https://www.youtube.com/theawesomegem
loordgek Posted December 24, 2017 Posted December 24, 2017 http://mcforge.readthedocs.io/en/latest/concepts/registries/ Quote
TheAwesomeGem Posted December 25, 2017 Author Posted December 25, 2017 11 hours ago, loordgek said: http://mcforge.readthedocs.io/en/latest/concepts/registries/ So what exactly is a domain holder? Does it just hold the resourcelocation? Quote New Channel: https://www.youtube.com/theawesomegemily'>https://www.youtube.com/theawesomegemily My Group: https://www.youtube.com/officialpixelgem Old Channel: https://www.youtube.com/theawesomegem
jabelar Posted December 25, 2017 Posted December 25, 2017 17 hours ago, TheAwesomeGem said: Which means if I were to have a public static final Item ItemName from another mod, whenever that mod loads, my variable will get injected it's data? IYes. I believe that what happens is that each registry event happens across all mods, then all the objectholder annotations for that type of object are processed. So the injection does happen after all mods are registered. In fact if you look at the link the example shows exactly how to do this. You just need the modid in the domain of the annotation. Either the entire class annotation or the individual field annotation can specify the domain. 1 Quote Check out my tutorials here: http://jabelarminecraft.blogspot.com/
TheAwesomeGem Posted December 25, 2017 Author Posted December 25, 2017 16 minutes ago, jabelar said: IYes. I believe that what happens is that each registry event happens across all mods, then all the objectholder annotations for that type of object are processed. So the injection does happen after all mods are registered. In fact if you look at the link the example shows exactly how to do this. You just need the modid in the domain of the annotation. Either the entire class annotation or the individual field annotation can specify the domain. Wow that's actually pretty cool and very handy to modify aspects of other mod without an API. Thanks a lot! Quote New Channel: https://www.youtube.com/theawesomegemily'>https://www.youtube.com/theawesomegemily My Group: https://www.youtube.com/officialpixelgem Old Channel: https://www.youtube.com/theawesomegem
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.