-
Bug
-
Resolution: Invalid
-
None
-
1.19.4, 1.20 Pre-release 7
-
None
-
Confirmed
-
(Unassigned)
The bug
If a new data storage file (.dat file under the data directory) is added, it can usually be loaded successfully while the world is opened.
However, if the file was failed to be loaded previously after the world was opened, it cannot be loaded until the world is reopened.
How to reproduce
- Open a world
- Run
/data get storage mc-263058: a
- Move the attached data storage file under the data directory
- Run
/data get storage mc-263058: a
→
Found no elements matching a
If step 2 is skipped, the command in step 4 will succeed.
Code analysis
@Nullable public <T extends SavedData> T get(Function<CompoundTag, T> load, String key) { SavedData data = this.cache.get(key); if (data == null && !this.cache.containsKey(key)) { data = this.readSavedData(load, key); this.cache.put(key, data); } return (T)data; }
DimensionDataStorage#get attempts to read saved data when the value corresponding to the given key in the cache is null and the cache does not contain the key. Here, DimensionDataStorage#readSavedData returns null if the read fails, but this result is also cached. Once this happens, it no longer meets the latter condition, and the saved data of the key cannot be read until the world is reopened.