Fixed a potential crash. Closes #1692

This commit is contained in:
Adubbz 2020-10-12 21:14:20 +11:00
parent f45020028b
commit ddd3cb683f
1 changed files with 4 additions and 1 deletions

View File

@ -18,6 +18,8 @@ import net.minecraft.world.biome.Biome;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.ForgeRegistry;
import javax.annotation.Nullable;
public class BiomeUtil
{
public static RegistryKey<Biome> createKey(Biome biome)
@ -86,8 +88,9 @@ public class BiomeUtil
return getBiome(id) != null;
}
@Nullable
public static RegistryKey<Biome> getClientKey(Biome biome)
{
return Minecraft.getInstance().level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).getResourceKey(biome).get();
return Minecraft.getInstance().level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).getResourceKey(biome).orElse(null);
}
}