From 81c800b36a1a944141d45cb0320accf4a2ecde3e Mon Sep 17 00:00:00 2001 From: Telesphoreo Date: Wed, 8 May 2024 12:09:27 -0500 Subject: [PATCH] figured this one out --- build-data/dev-imports.txt | 3 +- ...t-oversized-components-from-updating.patch | 40 +++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 patches/server/0008-Reject-oversized-components-from-updating.patch diff --git a/build-data/dev-imports.txt b/build-data/dev-imports.txt index 0f8a3f3..3509d64 100644 --- a/build-data/dev-imports.txt +++ b/build-data/dev-imports.txt @@ -11,4 +11,5 @@ minecraft net.minecraft.network.chat.FormattedText minecraft net.minecraft.network.chat.contents.TranslatableContents.java minecraft net.minecraft.network.chat.HoverEvent -minecraft net.minecraft.world.item.KnowledgeBookItem \ No newline at end of file +minecraft net.minecraft.world.item.KnowledgeBookItem +minecraft net.minecraft.network.chat.contents.NbtContents \ No newline at end of file diff --git a/patches/server/0008-Reject-oversized-components-from-updating.patch b/patches/server/0008-Reject-oversized-components-from-updating.patch new file mode 100644 index 0000000..bb7402a --- /dev/null +++ b/patches/server/0008-Reject-oversized-components-from-updating.patch @@ -0,0 +1,40 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Telesphoreo +Date: Wed, 8 May 2024 12:08:31 -0500 +Subject: [PATCH] Reject oversized components from updating + + +diff --git a/src/main/java/net/minecraft/network/chat/ComponentUtils.java b/src/main/java/net/minecraft/network/chat/ComponentUtils.java +index 3365aed2b67ae0e4dd0410f5190ba474f146139b..5dea669ed5da073dcdfe4cbbf5521a622242563b 100644 +--- a/src/main/java/net/minecraft/network/chat/ComponentUtils.java ++++ b/src/main/java/net/minecraft/network/chat/ComponentUtils.java +@@ -1,6 +1,7 @@ + package net.minecraft.network.chat; + + import com.google.common.collect.Lists; ++import com.google.gson.JsonParser; + import com.mojang.brigadier.Message; + import com.mojang.brigadier.exceptions.CommandSyntaxException; + import com.mojang.datafixers.DataFixUtils; +@@ -38,8 +39,9 @@ public class ComponentUtils { + } + + public static MutableComponent updateForEntity(@Nullable CommandSourceStack source, Component text, @Nullable Entity sender, int depth) throws CommandSyntaxException { ++ MutableComponent result; // Scissors + if (depth > 100) { +- return text.copy(); ++ result = text.copy(); // Scissors + } else { + // Paper start - adventure; pass actual vanilla component + if (text instanceof io.papermc.paper.adventure.AdventureComponent adventureComponent) { +@@ -52,8 +54,9 @@ public class ComponentUtils { + mutableComponent.append(updateForEntity(source, component, sender, depth + 1)); + } + +- return mutableComponent.withStyle(resolveStyle(source, text.getStyle(), sender, depth)); ++ result = mutableComponent.withStyle(resolveStyle(source, text.getStyle(), sender, depth)); + } ++ return JsonParser.parseString(result.toString()).toString().length() > 65535 ? Component.empty() : result; // Scissors + } + + private static Style resolveStyle(@Nullable CommandSourceStack source, Style style, @Nullable Entity sender, int depth) throws CommandSyntaxException {