--- a/net/minecraft/resources/ResourceKey.java
+++ b/net/minecraft/resources/ResourceKey.java
@@ -8,28 +8,30 @@
 import net.minecraft.core.Registry;
 
 public class ResourceKey<T> {
-    private static final Map<String, ResourceKey<?>> VALUES = Collections.synchronizedMap(Maps.newIdentityHashMap());
+
+    private static final Map<String, ResourceKey<?>> VALUES = Collections.synchronizedMap(Maps.newHashMap()); // CraftBukkit - SPIGOT-6973: remove costly intern
     private final ResourceLocation registryName;
     private final ResourceLocation location;
 
     public static <T> Codec<ResourceKey<T>> codec(ResourceKey<? extends Registry<T>> registry) {
-        return ResourceLocation.CODEC.xmap((id) -> {
-            return create(registry, id);
+        return ResourceLocation.CODEC.xmap((minecraftkey) -> {
+            return ResourceKey.create(registry, minecraftkey);
         }, ResourceKey::location);
     }
 
     public static <T> ResourceKey<T> create(ResourceKey<? extends Registry<T>> registry, ResourceLocation value) {
-        return create(registry.location, value);
+        return ResourceKey.create(registry.location, value);
     }
 
     public static <T> ResourceKey<Registry<T>> createRegistryKey(ResourceLocation registry) {
-        return create(Registry.ROOT_REGISTRY_NAME, registry);
+        return ResourceKey.create(Registry.ROOT_REGISTRY_NAME, registry);
     }
 
     private static <T> ResourceKey<T> create(ResourceLocation registry, ResourceLocation value) {
-        String string = (registry + ":" + value).intern();
-        return VALUES.computeIfAbsent(string, (id) -> {
-            return new ResourceKey(registry, value);
+        String s = (registry + ":" + value); // CraftBukkit - SPIGOT-6973: remove costly intern
+
+        return (ResourceKey) ResourceKey.VALUES.computeIfAbsent(s, (s1) -> {
+            return new ResourceKey<>(registry, value);
         });
     }
 
@@ -38,7 +40,6 @@
         this.location = value;
     }
 
-    @Override
     public String toString() {
         return "ResourceKey[" + this.registryName + " / " + this.location + "]";
     }
@@ -48,7 +49,7 @@
     }
 
     public <E> Optional<ResourceKey<E>> cast(ResourceKey<? extends Registry<E>> registryRef) {
-        return this.isFor(registryRef) ? Optional.of(this) : Optional.empty();
+        return this.isFor(registryRef) ? (Optional) Optional.of(this) : Optional.empty(); // CraftBukkit - decompile error
     }
 
     public ResourceLocation location() {
