-
Notifications
You must be signed in to change notification settings - Fork 46
Prepend modid to accessor tag #182
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
Conversation
|
Mod ID should not be prepended to accessors |
|
@apple502j , why not? |
|
https://discord.com/channels/507304429255393322/807617700734042122/1246229871810707610 case where prepending modid could have prevented an issue |
That's an edge case caused by bad practice. Really what should be discouraged is non-interface-based accessors. |
because Mixin merges accessors properly unlike other methods.
This looks like a Mixin bug to me, Mixin should be selecting the weakest access modifier when merging accessors |
|
This should probably be brought up in a Fabric Mixin issue since it really shouldn't be preferring private over public accessors. |
I disagree. There was a discussion on discord about this, generally ending around llama saying:
|
|
The conversation in fact didn't end there, and prefixing accessors by mod id is generally not what people do. Given that accessors don't clash with each other, I think rather than recommending every mod do the incredibly annoying thing of prefixing all their accessors, we put a few extra safeguards in Mixin to make sure that accessors can't overwrite other methods, maybe behind the |
|
Jumping in from FabricMC/Mixin#171 The issues described to me look like a bug in mixin not applying visibility correctly when there are multiple visibilities. The prefix doesn't seem to have much to do with it. Some people stated that there are some cases in obfuscated environments where modid may be required to avoid conflicts... but is that the case for unobfuscated environments? Are there examples for either of these cases? I can't think of any. |
fabric doesn't cover those cases. |
this is fair. I'm not trying to imply that it has ended in any way. it's just very spread out through multiple issues, and multiple mediums, so I'm trying to keep everyone up to date. I obviously have an opinion, but please disregard that, I can write whatever I want in my own mixins, regardless of what the small help tag says |
That's not correct. Fabric's fork of mixin is used in fabric loader. Fabric loader is a general purpose mod loader for any java game. It can be used on obfuscated and unobfuscated games. |
I'm sorry I was misleading then. I wasn't implying that fabric mixin doesn't cover those cases. |
|
I've just tested it, looks like accidental overwriting via an accessor is already prevented if you have |
if you don't consider the game crashing to be a problem then I suppose so |
|
Other than with the visibility bug, how do you get a game crash? I think maybe if two mods try to name an accessor the same thing, but for some reason target different fields would really be the only way, right? Something like: //mod 1
@Accessor
public Foo getFoo();
//mod 2
@Accessor("bar")
public Bar getFoo(); |
|
There are two ways to get a game crash (only happens with // mod
@Accessor
Foo getFoo();where the target class adds a getter for Or: // mod 1
@Accessor
Foo getFoo();
// mod 2, not an accessor
public Foo getFoo();in the latter case, mod 2 should have either marked their method as
|
|
I've thought it over for a while and this is my opinion. I agree that edge cases do exist. However the ones we've identified so far are either extremely contrived (like two mods defining accessors with the same name but targeting different fields), easily preventable with existing tooling ( I'm totally fine with mods choosing to prefix their accessors if that works for them. Personally, I use suffixes (e.g. That said, I don’t think mixin or related tooling should try to automatically handle modid prefixes/suffixes UNLESS it can be done in a way that guarantees no breakage or unexpected behavior. (see FabricMC/Mixin#171) |
|
Okay, so from my understanding, these are the conclusions so far:
That being said, I still would prefer my mixins not to conflict with others' mixins at all, even if the solution can be enabled by a simple flag. I try to write for preemptive compatibility and not, "Oh my mod broke because of this, time to make a patch." Also, I probably should not have created #183 after this was closed, but my intention was to bring more attention to the original PR (and it seems as though I have succeeded somewhat). Apologies for that. |
|
Additionally (extra thought that could be completely useless), we somewhat assumed that the conflicts that we found were the only conflicts that could have occurred due to not naming accessors/invokers differently. I haven't been around for a long time, but there might be more common cases that we haven't seen yet (maybe this PR is too early). |
Companion PR to #181 but for accessors
Relevant conversation: https://discord.com/channels/507304429255393322/807617284129423370/1379959874292678760