Use linked collections to stabilize order when adding new registry entries.

This commit is contained in:
LexManos 2020-11-10 11:13:38 -08:00
parent 8c68731838
commit 9bbfbd5479
1 changed files with 8 additions and 2 deletions

View File

@ -680,6 +680,9 @@ public class GameData
for (ResourceLocation s : missingRegs) for (ResourceLocation s : missingRegs)
text.append(s).append("\n"); text.append(s).append("\n");
LOGGER.warn(REGISTRIES, header);
LOGGER.warn(REGISTRIES, text.toString());
} }
} }
@ -692,7 +695,7 @@ public class GameData
{ {
final Class<? extends IForgeRegistryEntry> clazz = RegistryManager.ACTIVE.getSuperType(key); final Class<? extends IForgeRegistryEntry> clazz = RegistryManager.ACTIVE.getSuperType(key);
remaps.put(key, Maps.newLinkedHashMap()); remaps.put(key, Maps.newLinkedHashMap());
missing.put(key, Maps.newHashMap()); missing.put(key, Maps.newLinkedHashMap());
loadPersistentDataToStagingRegistry(RegistryManager.ACTIVE, STAGING, remaps.get(key), missing.get(key), key, value, clazz); loadPersistentDataToStagingRegistry(RegistryManager.ACTIVE, STAGING, remaps.get(key), missing.get(key), key, value, clazz);
}); });
@ -769,6 +772,9 @@ public class GameData
entries.stream().sorted((o1, o2) -> o1.compareNamespaced(o2)).forEach(rl -> buf.append(" ").append(rl).append("\n")); entries.stream().sorted((o1, o2) -> o1.compareNamespaced(o2)).forEach(rl -> buf.append(" ").append(rl).append("\n"));
buf.append("\n"); buf.append("\n");
}); });
LOGGER.warn(REGISTRIES, header);
LOGGER.warn(REGISTRIES, buf.toString());
} }
if (!defaulted.isEmpty()) if (!defaulted.isEmpty())
@ -861,7 +867,7 @@ public class GameData
{ {
ForgeRegistry<T> frozen = RegistryManager.FROZEN.getRegistry(name); ForgeRegistry<T> frozen = RegistryManager.FROZEN.getRegistry(name);
ForgeRegistry<T> newRegistry = STAGING.getRegistry(name, RegistryManager.FROZEN); ForgeRegistry<T> newRegistry = STAGING.getRegistry(name, RegistryManager.FROZEN);
Map<ResourceLocation, Integer> _new = Maps.newHashMap(); Map<ResourceLocation, Integer> _new = Maps.newLinkedHashMap();
frozen.getKeys().stream().filter(key -> !newRegistry.containsKey(key)).forEach(key -> _new.put(key, frozen.getID(key))); frozen.getKeys().stream().filter(key -> !newRegistry.containsKey(key)).forEach(key -> _new.put(key, frozen.getID(key)));
newRegistry.loadIds(_new, frozen.getOverrideOwners(), Maps.newLinkedHashMap(), remaps, frozen, name); newRegistry.loadIds(_new, frozen.getOverrideOwners(), Maps.newLinkedHashMap(), remaps, frozen, name);
} }