Capture a vanilla freeze - will be used when FML connects to vanilla servers, soon

This commit is contained in:
cpw committed 2016-04-02 14:16:17 -04:00
1 parent efcb9ee570
commit 404995122a
4 files changed
+29 -1

No files matched your search

@@ -244,6 +244,11 @@ public class GameData
return (ObjectIntIdentityMap<IBlockState>)getMain().iBlockRegistry.getSlaveMap(BLOCKSTATE_TO_ID, ObjectIntIdentityMap.class);
}
public static void vanillaSnapshot()
{
PersistentRegistryManager.freezeVanilla();
}
//Lets us clear the map so we can rebuild it.
static class ClearableObjectIntIdentityMap<I> extends ObjectIntIdentityMap<I>
{
@@ -12,7 +12,7 @@ import net.minecraft.util.ResourceLocation;
*
* @param <V> The top level type for the registry
*/
@SuppressWarnings("WeakerAccess")
@SuppressWarnings({"WeakerAccess", "unused"})
public interface IForgeRegistry<V extends IForgeRegistryEntry<V>> extends Iterable<V>
{
public Class<V> getRegistrySuperType();
@@ -388,6 +388,19 @@ public class PersistentRegistryManager
forAllRegistries(PersistentRegistry.FROZEN, ValidateRegistryFunction.OPERATION);
}
public static void freezeVanilla()
{
FMLLog.fine("Creating vanilla freeze snapshot");
for (Map.Entry<ResourceLocation, FMLControlledNamespacedRegistry<?>> r : PersistentRegistry.ACTIVE.registries.entrySet())
{
// This has to be performed prior to invoking the method so the compiler can precompute the type bounds for the method
final Class<? extends IForgeRegistryEntry> registrySuperType = PersistentRegistry.ACTIVE.getRegistrySuperType(r.getKey());
loadRegistry(r.getKey(), PersistentRegistry.ACTIVE, PersistentRegistry.VANILLA, registrySuperType);
}
forAllRegistries(PersistentRegistry.VANILLA, ValidateRegistryFunction.OPERATION);
FMLLog.fine("Vanilla freeze snapshot created");
}
public static List<String> processIdRematches(Iterable<FMLMissingMappingsEvent.MissingMapping> missedMappings, boolean isLocalWorld, Map<ResourceLocation, Integer> missingBlocks, Map<ResourceLocation, Integer> missingItems, Map<ResourceLocation, Integer[]> remapBlocks, Map<ResourceLocation, Integer[]> remapItems)
{
List<String> failed = Lists.newArrayList();