I managed to find a solution. Instead of the above method i do this:
private static final ResourceLocation MOLTEN_METAL_TEXTURE = new ResourceLocation("textures/block/lava_still.png");
private static final RenderType RENDER_TYPE = RenderType.getEntitySolid(MOLTEN_METAL_TEXTURE);
DimensionTypes are dynamic since they are now data driven. This means that the associated data can only be accessed whenever a world is loaded. You can get access to this through MinecraftServer#registryAccess which gives you an instance of DynamicRegistries. There is a convenient method there for grabbing the registry called DynamicRegistries#dimensionTypes. Registry is an instance of Iterable on the value.