--- a/net/minecraft/network/chat/contents/TranslatableContents.java
+++ b/net/minecraft/network/chat/contents/TranslatableContents.java
@@ -56,7 +_,7 @@
     private List<FormattedText> decomposedParts = ImmutableList.of();
     private static final Pattern FORMAT_PATTERN = Pattern.compile("%(?:(\\d+)\\$)?([A-Za-z%]|$)");
 
-    private static DataResult<Object> filterAllowedArguments(@Nullable Object input) {
+    public static DataResult<Object> filterAllowedArguments(@Nullable Object input) {
         return !isAllowedPrimitiveArgument(input) ? DataResult.error(() -> "This value needs to be parsed as component") : DataResult.success(input);
     }
 
@@ -181,6 +_,16 @@
 
     @Override
     public <T> Optional<T> visit(FormattedText.ContentConsumer<T> contentConsumer) {
+        // Paper start - Count visited parts
+        try {
+            return this.visit(new TranslatableContentConsumer<>(contentConsumer));
+        } catch (IllegalArgumentException ignored) {
+            return contentConsumer.accept("...");
+        }
+    }
+
+    private <T> Optional<T> visit(TranslatableContentConsumer<T> contentConsumer) {
+        // Paper end - Count visited parts
         this.decompose();
 
         for (FormattedText formattedText : this.decomposedParts) {
@@ -192,6 +_,27 @@
 
         return Optional.empty();
     }
+
+    // Paper start - Count visited parts
+    private static final class TranslatableContentConsumer<T> implements FormattedText.ContentConsumer<T> {
+        private static final IllegalArgumentException NESTED_TOO_LONG = new IllegalArgumentException("Too long");
+
+        private final FormattedText.ContentConsumer<T> visitor;
+        private int visited;
+
+        private TranslatableContentConsumer(final FormattedText.ContentConsumer<T> visitor) {
+            this.visitor = visitor;
+        }
+
+        @Override
+        public Optional<T> accept(final String asString) {
+            if (this.visited++ > 32) {
+                throw NESTED_TOO_LONG;
+            }
+            return this.visitor.accept(asString);
+        }
+    }
+    // Paper end - Count visited parts
 
     @Override
     public MutableComponent resolve(@Nullable CommandSourceStack nbtPathPattern, @Nullable Entity entity, int recursionDepth) throws CommandSyntaxException {
