minecolonies icon indicating copy to clipboard operation
minecolonies copied to clipboard

Fix building names in research unlocks

Open Thodor12 opened this issue 1 month ago • 4 comments

Closes #11328

Changes proposed in this pull request

  • The building names in the research unlocks no longer use separated translation keys, instead opting to grab them directly through the ResearchEffect instance.
  • To achieve this I've started utilizing the ModResearchEffects appropriately, by introducing new registry entries, and dynamically constructing an IResearchEffect based on the registry type.
    • I've consolidated the ModResearchEffect and ModResearchEffectInitializer, simliar to other registries.
  • Repurposed the "effect": true field to define the effect type, with fallback code that if the value is still true, it will refer the "global" effect type (for datapacks)
  • Building effect types simply refer to the building ID, which will then be used in the getName() method.
  • Modified the IResearchEffect to return Components in favor of TranslatableContents, so each effect can independently choose how they go about constructing the name.
  • Modified the CITIZENCAP research effect to get it's own IResearchEffect instance, to cope with the special condition of being based on the citizen limit configuration. This way we can remove the technical debt in the window code with that explicit condition over there, this way it's a little more dynamic.
  • Datagenned the research files anew, to update them to the new JSON structure

Testing

  • [X] Yes I tested this before submitting it.
  • [ ] I also did a multiplayer test.

Review please

Thodor12 avatar Nov 05 '25 22:11 Thodor12

This breaks all research datapacks right?

No, there's fallback logic, if "effect": true is still detected it always generates a GlobalResearchEffect

Thodor12 avatar Nov 09 '25 09:11 Thodor12

I feel like a new effect type for this is overkill. Can't we just in the data define an optional "translationkey"? That we then load for "Unlocks %s" ? If not present, we go for the default key atm.

The problem is with GlobalResearchEffect there's no possible way to add other translation fields into the TranslatableContents, it only ever takes the original 4 arguments. The entire logic behind the class is different.

At least this thing was already a registry and made it so it could support multiple implementations, we just never made use of it until now.

Thodor12 avatar Nov 09 '25 10:11 Thodor12

Will this still support third-party buildings from other mods?

armele avatar Nov 09 '25 12:11 armele

Will this still support third-party buildings from other mods?

Yes, the translation string can't be modified, so it'll always say "Unlocks %s", but it'll always cope with whatever the current building name is.

Thodor12 avatar Nov 09 '25 12:11 Thodor12