Fix mte traits being treated as duplicate#1690
Merged
TechLord22 merged 2 commits intomasterfrom Apr 10, 2023
Merged
Conversation
ALongStringOfNumbers
approved these changes
Apr 10, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
This PR fixes a bug where MTETraits would all be treated as duplicate. This is because it was stored in the MTE's trait map before initializing the
nameandnetworkIdof the trait. Therefore, themteTraitByNetworkIdmap in MTE treated each trait as the same, breaking network sync. This PR fixes this.Additionally, the
networkIdstored in the trait itself was always zero, due to using the result ofmap#putto initialize it. This was another problem, since the return value ofmap#putis the old value, which is always 0 for unique traits, and is not the new id.This problem is linked to machine animations not working, recipe search sometimes not starting, likely sounds not functioning, and possibly many other issues.
Implementation Details
The MTETrait
namefield is now stored as a constant instead of being created each time. The creation of the name has moved to anprotected abstractmethodcreateName(), while the getter has been madefinaland concrete.Outcome
Fixes MTETraits being treated as duplicates. Closes #1692.
Potential Compatibility Issues
Mods which adopted the new MTETrait system will have to change their override of
getName(), which is now concrete and final, tocreateName().