From b2fa32800c08a94b42e3d624b381234feb94c686 Mon Sep 17 00:00:00 2001 From: Telesphoreo Date: Mon, 9 May 2022 23:45:38 -0500 Subject: [PATCH] Backport patches from 1.17.1 --- ...en-more-resource-location-validation.patch | 4 +- ...Account-for-items-inside-containers.patch} | 0 ...-tag-size-a-constant-add-a-method-fo.patch | 30 --------- ...ehicle-collision-checks-to-3-and-di.patch} | 0 ...-tag-size-a-constant-add-a-method-fo.patch | 63 +++++++++++++++++++ 5 files changed, 65 insertions(+), 32 deletions(-) rename patches/server/{0029-Account-for-items-inside-containers.patch => 0028-Account-for-items-inside-containers.patch} (100%) delete mode 100644 patches/server/0028-Make-the-maximum-tag-size-a-constant-add-a-method-fo.patch rename patches/server/{0030-Limit-amount-of-vehicle-collision-checks-to-3-and-di.patch => 0029-Limit-amount-of-vehicle-collision-checks-to-3-and-di.patch} (100%) create mode 100644 patches/server/0030-Make-the-maximum-tag-size-a-constant-add-a-method-fo.patch diff --git a/patches/server/0014-Even-more-resource-location-validation.patch b/patches/server/0014-Even-more-resource-location-validation.patch index d184b80..d0789f7 100644 --- a/patches/server/0014-Even-more-resource-location-validation.patch +++ b/patches/server/0014-Even-more-resource-location-validation.patch @@ -40,10 +40,10 @@ index 79abd84696ef099f6b12ddeaa6e398f18c53316a..7070b64c0c66b5c9d09bf7764ce506f4 @Nullable diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java -index b1ae9b0d8b229e2a6797a173cb11ecc0f43e2592..0919fa26ecd974385ed44e50c96439e9019deed7 100644 +index e3227a806d9e19923783122ea94ae19e7dbe71da..473dba5213f6aed7573e970119f4b6ad0e4f6367 100644 --- a/src/main/java/net/minecraft/world/entity/Mob.java +++ b/src/main/java/net/minecraft/world/entity/Mob.java -@@ -573,7 +573,7 @@ public abstract class Mob extends LivingEntity { +@@ -572,7 +572,7 @@ public abstract class Mob extends LivingEntity { this.setLeftHanded(nbt.getBoolean("LeftHanded")); if (nbt.contains("DeathLootTable", 8)) { diff --git a/patches/server/0029-Account-for-items-inside-containers.patch b/patches/server/0028-Account-for-items-inside-containers.patch similarity index 100% rename from patches/server/0029-Account-for-items-inside-containers.patch rename to patches/server/0028-Account-for-items-inside-containers.patch diff --git a/patches/server/0028-Make-the-maximum-tag-size-a-constant-add-a-method-fo.patch b/patches/server/0028-Make-the-maximum-tag-size-a-constant-add-a-method-fo.patch deleted file mode 100644 index d910b8d..0000000 --- a/patches/server/0028-Make-the-maximum-tag-size-a-constant-add-a-method-fo.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Business Goose -Date: Sun, 1 May 2022 01:19:36 +0100 -Subject: [PATCH] Make the maximum tag size a constant & add a method for - getting tag size - - -diff --git a/src/main/java/com/github/atlasmediagroup/scissors/NbtUtility.java b/src/main/java/com/github/atlasmediagroup/scissors/NbtUtility.java -index 058203440fd071ce5edbe18391ea60f0a5fbee3a..dc09fe007247e832aacc323ddeb3541cfb447069 100644 ---- a/src/main/java/com/github/atlasmediagroup/scissors/NbtUtility.java -+++ b/src/main/java/com/github/atlasmediagroup/scissors/NbtUtility.java -@@ -7,11 +7,17 @@ import java.nio.charset.StandardCharsets; - - public class NbtUtility - { -+ public static final long MAXIMUM_SIZE = (256 * 1024); -+ -+ public static long getTagSize(@Nullable CompoundTag tag) { -+ if(tag == null) return 0; -+ return tag.toString().getBytes(StandardCharsets.UTF_8).length; -+ } - - public static boolean isTooLarge(@Nullable CompoundTag tag) - { - if (tag == null) return false; -- return tag.toString().getBytes(StandardCharsets.UTF_8).length > (256 * 1024); -+ return getTagSize(tag) > MAXIMUM_SIZE; - } - - public static class Item diff --git a/patches/server/0030-Limit-amount-of-vehicle-collision-checks-to-3-and-di.patch b/patches/server/0029-Limit-amount-of-vehicle-collision-checks-to-3-and-di.patch similarity index 100% rename from patches/server/0030-Limit-amount-of-vehicle-collision-checks-to-3-and-di.patch rename to patches/server/0029-Limit-amount-of-vehicle-collision-checks-to-3-and-di.patch diff --git a/patches/server/0030-Make-the-maximum-tag-size-a-constant-add-a-method-fo.patch b/patches/server/0030-Make-the-maximum-tag-size-a-constant-add-a-method-fo.patch new file mode 100644 index 0000000..6e720be --- /dev/null +++ b/patches/server/0030-Make-the-maximum-tag-size-a-constant-add-a-method-fo.patch @@ -0,0 +1,63 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Business Goose +Date: Sun, 1 May 2022 01:19:36 +0100 +Subject: [PATCH] Make the maximum tag size a constant & add a method for + getting tag size + + +diff --git a/src/main/java/com/github/atlasmediagroup/scissors/NbtUtility.java b/src/main/java/com/github/atlasmediagroup/scissors/NbtUtility.java +index 058203440fd071ce5edbe18391ea60f0a5fbee3a..978cb98c81195640fb3704d2077148f2be0dca36 100644 +--- a/src/main/java/com/github/atlasmediagroup/scissors/NbtUtility.java ++++ b/src/main/java/com/github/atlasmediagroup/scissors/NbtUtility.java +@@ -1,17 +1,49 @@ + package com.github.atlasmediagroup.scissors; + +-import net.minecraft.nbt.CompoundTag; ++import com.google.common.base.Strings; ++import com.google.common.collect.Lists; ++import net.minecraft.nbt.*; + + import javax.annotation.Nullable; + import java.nio.charset.StandardCharsets; ++import java.util.Collections; ++import java.util.List; + + public class NbtUtility + { ++ public static final long MAXIMUM_SIZE = (256 * 1024); ++ ++ public static long getTagSize(@Nullable Tag tag, int depth) { ++ if(depth > 512) return 0; ++ if(tag == null) return 0; ++ ++ long size = 0; ++ ++ if(tag.getType() == CompoundTag.TYPE) { ++ CompoundTag compoundTag = (CompoundTag) tag; ++ for(String key : compoundTag.getAllKeys()) { ++ size += getTagSize(compoundTag.get(key), depth + 1); ++ } ++ } else if(tag.getType() == ListTag.TYPE) { ++ ListTag listTag = (ListTag) tag; ++ for (Tag tag1 : listTag) { ++ size += getTagSize(tag1, depth + 1); ++ } ++ } else { ++ size += tag.getAsString().getBytes(StandardCharsets.UTF_8).length; ++ } ++ ++ return size; ++ } ++ ++ public static long getTagSize(@Nullable CompoundTag tag) { ++ return getTagSize(tag, 0); ++ } + + public static boolean isTooLarge(@Nullable CompoundTag tag) + { + if (tag == null) return false; +- return tag.toString().getBytes(StandardCharsets.UTF_8).length > (256 * 1024); ++ return getTagSize(tag) > MAXIMUM_SIZE; + } + + public static class Item