Skip to content

Comments

Fix mte traits being treated as duplicate#1690

Merged
TechLord22 merged 2 commits intomasterfrom
tc-fix-mtetrait
Apr 10, 2023
Merged

Fix mte traits being treated as duplicate#1690
TechLord22 merged 2 commits intomasterfrom
tc-fix-mtetrait

Conversation

@TechLord22
Copy link
Member

@TechLord22 TechLord22 commented Apr 9, 2023

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 name and networkId of the trait. Therefore, the mteTraitByNetworkId map in MTE treated each trait as the same, breaking network sync. This PR fixes this.

Additionally, the networkId stored in the trait itself was always zero, due to using the result of map#put to initialize it. This was another problem, since the return value of map#put is 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 name field is now stored as a constant instead of being created each time. The creation of the name has moved to an protected abstract method createName(), while the getter has been made final and 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, to createName().

@TechLord22 TechLord22 merged commit 09447e9 into master Apr 10, 2023
@TechLord22 TechLord22 deleted the tc-fix-mtetrait branch April 10, 2023 02:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: release blocker Must have for next release type: bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Machine Textures do not change when running and Audio for machines does not play

2 participants