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

Data Packs forget they are enabled, or get loaded in the wrong order #9938

Open
petrolpark opened this issue Apr 25, 2024 · 0 comments
Open
Labels
Triage This request requires the active attention of the Triage Team. Requires labelling or reviews.

Comments

@petrolpark
Copy link

petrolpark commented Apr 25, 2024

Minecraft Version: 1.20.1

Forge Version: 47.2.4

Steps to Reproduce:

  1. Register a data pack source with AddPackFindersEvent but don't turn it on by default.
  2. Create a world, and save and exit.
  3. Re-enter the world, and enable the data pack with the /datapack command.
  4. Exit the world, then re-enter.
  5. The data pack is not enabled.

Description of issue:

During runtime it seems that the list of data packs is stored in order in a PackRepository. But the list is also stored in duplicate in PrimaryLevelData -> LevelSettings -> WorldDataConfiguration -> DataPackConfig. This is what gets stored in level.dat. Unfortunately, these two storages are desynced. Whenever there is a reload, the idea is that the ordered list of datapacks in the world's PackRepository gets copied to the DataPackConfig, but that does not occur due to an error in this method:

public LevelSettings withDataConfiguration(WorldDataConfiguration pDataConfiguration) {
      return new LevelSettings(this.levelName, this.gameType, this.hardcore, this.difficulty, this.allowCommands, this.gameRules, dataConfiguration, this.lifecycle);
   }

As you can see, the world's LevelSettings gets passed a WorldDataConfiguration (which, checking at runtime, does indeed contain the correct order of data packs), but this value is completely unused because the field passed to the constructor is the object field dataConfiguration rather than the argument pDataConfiguration. I am assuming that pDataConfiguration was the thing that was meant to be passed on, because all of the other object fields are preceded by the this..

The result is that if you change the list of datapacks during runtime, they are correctly ordered while the level is open, but it is the old list which gets saved, so when you re-open the world next time it has reverted to whatever datapacks the world was originally created with.

Fix:

Simply changing dataConfiguration to pDataConfiguration fixes this. I've done it myself with a Mixin for my mod and it seems to work fine.

@petrolpark petrolpark added the Triage This request requires the active attention of the Triage Team. Requires labelling or reviews. label Apr 25, 2024
@petrolpark petrolpark changed the title Data Packs get forget they are enabled, or get loaded in the wrong order Data Packs forget they are enabled, or get loaded in the wrong order Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Triage This request requires the active attention of the Triage Team. Requires labelling or reviews.
Projects
None yet
Development

No branches or pull requests

1 participant