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

Use equals comparator when classes share a superclass #4516

Conversation

APickledWalrus
Copy link
Member

Description

This PR allows the method responsible for finding a comparator to return the equals comparator if the two classes share an immediate superclass. One issue caused by the lack of these checks is the weird comparison stuff that goes on with potions such as:

// This is a stupid bandaid to fix comparison issues when converting potion datas
@Nullable
public static PotionEffectType parseByEffectType(PotionEffectType t) {
for (PotionEffectType value : types.values()) {
if (t.equals(value)) {
return value;
}
}
return null;
}

However, I was wondering if it should compare if the classes share a common superclass at any point, not just the first level.


Target Minecraft Versions: Any
Requirements: None
Related Issues: #4183 (needs this PR)

@APickledWalrus APickledWalrus added the bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. label Jan 18, 2022
@APickledWalrus
Copy link
Member Author

It would likely be better to register a PotionEffectType-PotionEffectType in this case, like other types do.

I will close this PR.

@APickledWalrus APickledWalrus deleted the fix/superclass-comparisons branch January 20, 2022 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue that needs to be fixed. Alternatively, a PR fixing an issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants