use of net.minecraftforge.fml.util.EnhancedRuntimeException in project MinecraftForge by MinecraftForge.
the class GameData method loadRegistry.
private static <T extends IForgeRegistryEntry<T>> void loadRegistry(final ResourceLocation registryName, final RegistryManager from, final RegistryManager to, final Class<T> regType, boolean freeze) {
ForgeRegistry<T> fromRegistry = from.getRegistry(registryName);
if (fromRegistry == null) {
ForgeRegistry<T> toRegistry = to.getRegistry(registryName);
if (toRegistry == null) {
throw new EnhancedRuntimeException("Could not find registry to load: " + registryName) {
private static final long serialVersionUID = 1L;
@Override
protected void printStackTrace(WrappedPrintStream stream) {
stream.println("Looking For: " + registryName);
stream.println("Found From:");
for (ResourceLocation name : from.registries.keySet()) stream.println(" " + name);
stream.println("Found To:");
for (ResourceLocation name : to.registries.keySet()) stream.println(" " + name);
}
};
}
// We found it in to, so lets trust to's state...
// This happens when connecting to a server that doesn't have this registry.
// Such as a 1.8.0 Forge server with 1.8.8+ Forge.
// We must however, re-fire the callbacks as some internal data may be corrupted {potions}
// TODO: With my rework of how registries add callbacks are done.. I don't think this is necessary.
// fire addCallback for each entry
} else {
ForgeRegistry<T> toRegistry = to.getRegistry(registryName, from);
toRegistry.sync(registryName, fromRegistry);
if (freeze)
toRegistry.isFrozen = true;
}
}
Aggregations