-
-
Notifications
You must be signed in to change notification settings - Fork 194
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
Make mod’s own use of OnlyIn annotation throw warning or crash in dev #569
Comments
Yes |
As long as we encourage modders to not properly isolate their client-specific code, I think it would be premature to enforce removal of |
What would proper isolation of client-specific code entail? |
if (FMLEnvironment.dist == Dist.CLIENT) {
ModClientClass.doStuff();
} or if (FMLEnvironment.dist.isClient()) {
ModClientClass.doStuff();
} From what I understand, OnlyIn actually has zero effect on mod's own code. No stripping is done. Thus keeping the annotation just causes confusion for new modders as they think it does something instead of writing properly safe code. If a modder is only used for marking what code is clientside for organization, the same goal can be achieved by just doing a comment like |
We already suggest proper isolation of client code. See
|
The docs in Dist require the modder to already know about Dist which then they are already were going to use it properly. Only really strong way to kill off OnlyIn within modder code is to stop allowing it in modder code. otherwise people are just going to keep copying bad code from other mods or bad tutorials and nothing changes. |
As a possible solution to the answer of how people are going to learn about avoiding Also, I'm interested to hear what @Technici4n considers as proper isolation of client-specific code, as well as why he considers us to be currently encouraging against it. |
As far as I know from previous discussions, what Tech is referring to is something like Fabric Loom's split sourcesets, which would enforce the isolation of client-only code. While it's theoretically a good solution in the long term, I personally don't think such measures are needed to go ahead with disallowing |
With #929 released, I believe modders now can define two entry points. One for client and one for normal. So another way of doing properly isolation of client code |
Making @Override
public EnumSet<Phase> handlesClass(Type classType, boolean isEmpty) {
- return isEmpty ? NAY : YAY;
+ return isEmpty || !classType.getInternalName().startsWith("net/minecraft/") ? NAY : YAY;
} I think we should do that in 1.21 and until then crash uses of it in mod code. |
Too many people are still using OnlyIn in their own mod’s code. Time to bring down the hammer
The text was updated successfully, but these errors were encountered: