--- a/net/minecraft/tags/TagKey.java
+++ b/net/minecraft/tags/TagKey.java
@@ -41,7 +41,7 @@
     }
 
     public <E> Optional<TagKey<E>> cast(ResourceKey<? extends Registry<E>> p_207648_) {
-        return this.isFor(p_207648_) ? Optional.of(this) : Optional.empty();
+        return this.isFor(p_207648_) ? Optional.of((TagKey<E>)this) : Optional.empty();
     }
 
     @Override
