Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Request] @ExpectPlatform fields #11

Open
KP2048 opened this issue Jan 20, 2022 · 5 comments
Open

[Request] @ExpectPlatform fields #11

KP2048 opened this issue Jan 20, 2022 · 5 comments

Comments

@KP2048
Copy link

KP2048 commented Jan 20, 2022

Say I have an abstract class in common module that extends from Block class. But I need to have some different code in fabric vs forge. I would implement that abstract class in both forge and fabric modules. This is fine, but now I have 2 RegistrySuppliers and neither are accessible from common module. What I have been doing to work around this is making a public static but not final RegistrySupplier field in common module, but not assigning a value to it and in forge and fabric modules under a static {} block setting the common field to a registered value.
this works, but it would be much more neat and convenient if I could use something like expectplatform to make sure the field has the correct value. This would also make final fields possible in this situation

@MaxNeedsSnacks MaxNeedsSnacks transferred this issue from architectury/architectury-api Jan 30, 2022
@Juuxel
Copy link
Member

Juuxel commented Jan 30, 2022

This can already be done by making the code in your field initialiser into an @ExpectPlatform method without needing @ExpectPlatform fields.

@KP2048
Copy link
Author

KP2048 commented Jan 30, 2022

But then I’d have to make a separate method for each field…

@shedaniel
Copy link
Member

How would expect platform fields even work?

@KP2048
Copy link
Author

KP2048 commented Jan 30, 2022

Autogenerated Methods with reflection?

@wagyourtail
Copy link

wagyourtail commented Jan 30, 2022

in <clinit> to access the impl's field's value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants