From 4c0a4b880479ba5016deb14b665b6ddc59b566c9 Mon Sep 17 00:00:00 2001 From: Telesphoreo Date: Tue, 19 Apr 2022 18:49:48 -0500 Subject: [PATCH] I'm committing this right now. I don't know if it works but it compiles --- ...-a-show_entity-hover-event-s-UUID-is.patch | 8 +- ...tTables-causing-problems-when-appli.patch} | 2 +- ...3-Fixes-the-Blank-SkullOwner-exploit.patch | 31 --- ...aused-by-invalid-entities-in-beehive.patch | 32 --- ...air-bundle-items-in-CraftMetaBundle.patch} | 0 patches/server/0005-fix-this-patch.patch | 19 ++ ...if-items-are-air-before-calling-set.patch} | 4 +- ...Removes-useless-spammy-error-logging.patch | 29 -- ...ooks-causing-log-spam-when-invalid-.patch} | 2 +- ...rown-when-trying-to-remove-minecart-.patch | 25 -- ...te-BlockState-and-SoundEvent-values.patch} | 6 +- ...eLocation-validation-and-log-spam-f.patch} | 4 +- ...d-items-in-HoverEvent-and-ItemFrame.patch} | 10 +- ... 0011-Change-version-fetcher-to-AMG.patch} | 0 ...en-more-resource-location-validation.patch | 54 ---- ...UIDs-during-the-CompoundTag-GamePro.patch} | 8 +- ...s-with-invalid-namespaces-from-bein.patch} | 6 +- ...ry-player-data-in-the-nbt-component.patch} | 10 +- ...oit-related-to-out-of-bounds-Axolotl.patch | 28 -- ...015-Limit-ListTags-to-1024-elements.patch} | 4 +- ...ates-before-attempting-to-get-block-.patch | 44 ---- ...atch => 0016-Fix-lectern-quick-move.patch} | 0 ...lling-potion-effects-and-certain-po.patch} | 2 +- ...-handling-of-invalid-JSON-components.patch | 199 -------------- .../0019-block-server-side-chunkbans.patch | 162 ------------ ...t-oversized-components-from-updating.patch | 37 --- ...-entities-from-being-spawned-by-spaw.patch | 95 ------- patches/server/0028-Reset-large-tags.patch | 249 ------------------ 28 files changed, 52 insertions(+), 1018 deletions(-) rename patches/server/{0005-Fixes-invalid-LootTables-causing-problems-when-appli.patch => 0003-Fixes-invalid-LootTables-causing-problems-when-appli.patch} (97%) delete mode 100644 patches/server/0003-Fixes-the-Blank-SkullOwner-exploit.patch delete mode 100644 patches/server/0004-Fixes-log-spam-caused-by-invalid-entities-in-beehive.patch rename patches/server/{0007-Ignore-null-air-bundle-items-in-CraftMetaBundle.patch => 0004-Ignore-null-air-bundle-items-in-CraftMetaBundle.patch} (100%) create mode 100644 patches/server/0005-fix-this-patch.patch rename patches/server/{0009-ItemEntity-Check-if-items-are-air-before-calling-set.patch => 0006-ItemEntity-Check-if-items-are-air-before-calling-set.patch} (84%) delete mode 100644 patches/server/0006-Removes-useless-spammy-error-logging.patch rename patches/server/{0010-Fixes-Knowledge-Books-causing-log-spam-when-invalid-.patch => 0007-Fixes-Knowledge-Books-causing-log-spam-when-invalid-.patch} (96%) delete mode 100644 patches/server/0008-Ignore-errors-thrown-when-trying-to-remove-minecart-.patch rename patches/server/{0011-Validate-BlockState-and-SoundEvent-values.patch => 0008-Validate-BlockState-and-SoundEvent-values.patch} (88%) rename patches/server/{0013-Even-more-ResourceLocation-validation-and-log-spam-f.patch => 0009-Even-more-ResourceLocation-validation-and-log-spam-f.patch} (95%) rename patches/server/{0016-Do-not-log-invalid-items-in-HoverEvent-and-ItemFrame.patch => 0010-Do-not-log-invalid-items-in-HoverEvent-and-ItemFrame.patch} (84%) rename patches/server/{0017-Change-version-fetcher-to-AMG.patch => 0011-Change-version-fetcher-to-AMG.patch} (100%) delete mode 100644 patches/server/0012-Even-more-resource-location-validation.patch rename patches/server/{0021-Validate-String-UUIDs-during-the-CompoundTag-GamePro.patch => 0012-Validate-String-UUIDs-during-the-CompoundTag-GamePro.patch} (82%) rename patches/server/{0022-Prevent-attributes-with-invalid-namespaces-from-bein.patch => 0013-Prevent-attributes-with-invalid-namespaces-from-bein.patch} (87%) rename patches/server/{0024-Don-t-query-player-data-in-the-nbt-component.patch => 0014-Don-t-query-player-data-in-the-nbt-component.patch} (81%) delete mode 100644 patches/server/0014-Fixes-crash-exploit-related-to-out-of-bounds-Axolotl.patch rename patches/server/{0025-Limit-ListTags-to-1024-elements.patch => 0015-Limit-ListTags-to-1024-elements.patch} (81%) delete mode 100644 patches/server/0015-Validate-coordinates-before-attempting-to-get-block-.patch rename patches/server/{0026-Fix-lectern-quick-move.patch => 0016-Fix-lectern-quick-move.patch} (100%) rename patches/server/{0027-Fixes-creative-killing-potion-effects-and-certain-po.patch => 0017-Fixes-creative-killing-potion-effects-and-certain-po.patch} (96%) delete mode 100644 patches/server/0018-Better-handling-of-invalid-JSON-components.patch delete mode 100644 patches/server/0019-block-server-side-chunkbans.patch delete mode 100644 patches/server/0020-Reject-oversized-components-from-updating.patch delete mode 100644 patches/server/0023-Prevent-abusable-entities-from-being-spawned-by-spaw.patch delete mode 100644 patches/server/0028-Reset-large-tags.patch diff --git a/patches/server/0002-Return-null-when-a-show_entity-hover-event-s-UUID-is.patch b/patches/server/0002-Return-null-when-a-show_entity-hover-event-s-UUID-is.patch index 648f093..7536a91 100644 --- a/patches/server/0002-Return-null-when-a-show_entity-hover-event-s-UUID-is.patch +++ b/patches/server/0002-Return-null-when-a-show_entity-hover-event-s-UUID-is.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Return null when a show_entity hover event's UUID isn't valid diff --git a/src/main/java/net/minecraft/network/chat/HoverEvent.java b/src/main/java/net/minecraft/network/chat/HoverEvent.java -index fda8aad4a394cf331f3421ec07ffe0d605c8da4e..c5711b3d120699ec78f81e9b6ee80d0764552e94 100644 +index b31ff9d237f593e58b42b453632aa2c2af74f986..67feb4e688d049e9f74f0deabb1ec583336a29be 100644 --- a/src/main/java/net/minecraft/network/chat/HoverEvent.java +++ b/src/main/java/net/minecraft/network/chat/HoverEvent.java -@@ -175,7 +175,14 @@ public class HoverEvent { +@@ -174,7 +174,14 @@ public class HoverEvent { } else { JsonObject jsonObject = json.getAsJsonObject(); EntityType entityType = Registry.ENTITY_TYPE.get(new ResourceLocation(GsonHelper.getAsString(jsonObject, "type"))); @@ -24,7 +24,7 @@ index fda8aad4a394cf331f3421ec07ffe0d605c8da4e..c5711b3d120699ec78f81e9b6ee80d07 Component component = Component.Serializer.fromJson(jsonObject.get("name")); return new HoverEvent.EntityTooltipInfo(entityType, uUID, component); } -@@ -187,7 +194,14 @@ public class HoverEvent { +@@ -186,7 +193,14 @@ public class HoverEvent { CompoundTag compoundTag = TagParser.parseTag(text.getString()); Component component = Component.Serializer.fromJson(compoundTag.getString("name")); EntityType entityType = Registry.ENTITY_TYPE.get(new ResourceLocation(compoundTag.getString("type"))); @@ -38,5 +38,5 @@ index fda8aad4a394cf331f3421ec07ffe0d605c8da4e..c5711b3d120699ec78f81e9b6ee80d07 + } + // Scissors end return new HoverEvent.EntityTooltipInfo(entityType, uUID, component); - } catch (CommandSyntaxException | JsonSyntaxException var5) { + } catch (Exception var5) { return null; diff --git a/patches/server/0005-Fixes-invalid-LootTables-causing-problems-when-appli.patch b/patches/server/0003-Fixes-invalid-LootTables-causing-problems-when-appli.patch similarity index 97% rename from patches/server/0005-Fixes-invalid-LootTables-causing-problems-when-appli.patch rename to patches/server/0003-Fixes-invalid-LootTables-causing-problems-when-appli.patch index cda5af4..2e36c47 100644 --- a/patches/server/0005-Fixes-invalid-LootTables-causing-problems-when-appli.patch +++ b/patches/server/0003-Fixes-invalid-LootTables-causing-problems-when-appli.patch @@ -32,7 +32,7 @@ index 94dc68182ec5f6dc1294ad15523427836228086a..07075cea760562c901d4469a7f88271c @Override diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java -index f57864ce919ef4721cfb5913c636fe8903ce4cc1..d80c7be5b153db4046d0b11c0116c6aa860ea48c 100644 +index 8a07d5d25086d7544757bb86181fbe2b5e743d29..ef50d9747f2a027e356b05ad8d94ffb2fd4a423e 100644 --- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java +++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java @@ -219,7 +219,7 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme diff --git a/patches/server/0003-Fixes-the-Blank-SkullOwner-exploit.patch b/patches/server/0003-Fixes-the-Blank-SkullOwner-exploit.patch deleted file mode 100644 index 457e1f8..0000000 --- a/patches/server/0003-Fixes-the-Blank-SkullOwner-exploit.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Video -Date: Sun, 13 Mar 2022 03:01:29 -0600 -Subject: [PATCH] Fixes the Blank SkullOwner exploit - - -diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java -index 7cacc61fed0c610845c67894d1cc68e44f5e46fe..4186b9558cbf6799e8491443b9ed5a2c9063ab7c 100644 ---- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java -+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java -@@ -6,6 +6,9 @@ import java.util.Map; - import java.util.UUID; - import com.destroystokyo.paper.profile.CraftPlayerProfile; - import com.destroystokyo.paper.profile.PlayerProfile; -+// Scissors start -+import org.apache.commons.lang3.StringUtils; -+// Scissors end - import org.bukkit.Bukkit; - import org.bukkit.Material; - import org.bukkit.OfflinePlayer; -@@ -47,7 +50,9 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta { - - if (tag.contains(SKULL_OWNER.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) { - this.setProfile(NbtUtils.readGameProfile(tag.getCompound(SKULL_OWNER.NBT))); -- } else if (tag.contains(SKULL_OWNER.NBT, CraftMagicNumbers.NBT.TAG_STRING) && !tag.getString(SKULL_OWNER.NBT).isEmpty()) { -+ // Scissors start -+ } else if (tag.contains(SKULL_OWNER.NBT, CraftMagicNumbers.NBT.TAG_STRING) && !StringUtils.isBlank(tag.getString(SKULL_OWNER.NBT))) { -+ // Scissors end - this.setProfile(new GameProfile(null, tag.getString(SKULL_OWNER.NBT))); - } - } diff --git a/patches/server/0004-Fixes-log-spam-caused-by-invalid-entities-in-beehive.patch b/patches/server/0004-Fixes-log-spam-caused-by-invalid-entities-in-beehive.patch deleted file mode 100644 index 9ac4ef6..0000000 --- a/patches/server/0004-Fixes-log-spam-caused-by-invalid-entities-in-beehive.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Video -Date: Sun, 13 Mar 2022 06:10:22 -0600 -Subject: [PATCH] Fixes log spam caused by invalid entities in beehives - - -diff --git a/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java -index 8484e80a70129fb0358d56efab6fd54798b54e6e..90fce5d2178672608f3ae97277cafe740a9ebead 100644 ---- a/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java -+++ b/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java -@@ -11,6 +11,7 @@ import net.minecraft.nbt.CompoundTag; - import net.minecraft.nbt.ListTag; - import net.minecraft.nbt.NbtUtils; - import net.minecraft.network.protocol.game.DebugPackets; -+import net.minecraft.resources.ResourceLocation; - import net.minecraft.sounds.SoundEvents; - import net.minecraft.sounds.SoundSource; - import net.minecraft.tags.BlockTags; -@@ -351,6 +352,13 @@ public class BeehiveBlockEntity extends BlockEntity { - - for (int i = 0; i < nbttaglist.size(); ++i) { - CompoundTag nbttagcompound1 = nbttaglist.getCompound(i); -+ -+ // Scissors start - Do not allow invalid entities from being used for bees -+ if (!nbttagcompound1.contains("id") || !ResourceLocation.isValidResourceLocation(nbttagcompound1.getString("id")) || EntityType.byString(nbttagcompound1.getString("id")).isEmpty()) { -+ continue; -+ } -+ // Scissor end -+ - BeehiveBlockEntity.BeeData tileentitybeehive_hivebee = new BeehiveBlockEntity.BeeData(nbttagcompound1.getCompound("EntityData"), nbttagcompound1.getInt("TicksInHive"), nbttagcompound1.getInt("MinOccupationTicks")); - - this.stored.add(tileentitybeehive_hivebee); diff --git a/patches/server/0007-Ignore-null-air-bundle-items-in-CraftMetaBundle.patch b/patches/server/0004-Ignore-null-air-bundle-items-in-CraftMetaBundle.patch similarity index 100% rename from patches/server/0007-Ignore-null-air-bundle-items-in-CraftMetaBundle.patch rename to patches/server/0004-Ignore-null-air-bundle-items-in-CraftMetaBundle.patch diff --git a/patches/server/0005-fix-this-patch.patch b/patches/server/0005-fix-this-patch.patch new file mode 100644 index 0000000..e274192 --- /dev/null +++ b/patches/server/0005-fix-this-patch.patch @@ -0,0 +1,19 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Telesphoreo +Date: Tue, 19 Apr 2022 18:27:04 -0500 +Subject: [PATCH] fix this patch + + +diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java +index ef50d9747f2a027e356b05ad8d94ffb2fd4a423e..574afb19e43ec5b17ae2fbee7db36e3164fe0a0b 100644 +--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java ++++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java +@@ -192,7 +192,7 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme + @Override + public void remove(Entity.RemovalReason reason) { + if (!this.level.isClientSide && reason.shouldDestroy()) { +- Containers.dropContents(this.level, (Entity) this, (Container) this); ++ Containers.dropContents(this.level, this, this); + } + + super.remove(reason); diff --git a/patches/server/0009-ItemEntity-Check-if-items-are-air-before-calling-set.patch b/patches/server/0006-ItemEntity-Check-if-items-are-air-before-calling-set.patch similarity index 84% rename from patches/server/0009-ItemEntity-Check-if-items-are-air-before-calling-set.patch rename to patches/server/0006-ItemEntity-Check-if-items-are-air-before-calling-set.patch index 48337b0..1572642 100644 --- a/patches/server/0009-ItemEntity-Check-if-items-are-air-before-calling-set.patch +++ b/patches/server/0006-ItemEntity-Check-if-items-are-air-before-calling-set.patch @@ -5,10 +5,10 @@ Subject: [PATCH] ItemEntity - Check if items are air before calling setItem diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java -index 063f3e4c67e6716c9a03dbe4b72eafd32e4f0d53..03b8cc0ae12f17cf3a1c57958cf10ca23750b92a 100644 +index f7d29950644a5cf12da0d31246d9f5fcbcc201bb..45866c9905cc607c58c398e675fe879e6e249398 100644 --- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java -@@ -377,11 +377,14 @@ public class ItemEntity extends Entity { +@@ -378,11 +378,14 @@ public class ItemEntity extends Entity { CompoundTag nbttagcompound1 = nbt.getCompound("Item"); diff --git a/patches/server/0006-Removes-useless-spammy-error-logging.patch b/patches/server/0006-Removes-useless-spammy-error-logging.patch deleted file mode 100644 index 191fe46..0000000 --- a/patches/server/0006-Removes-useless-spammy-error-logging.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Video -Date: Sun, 13 Mar 2022 07:47:20 -0600 -Subject: [PATCH] Removes useless spammy error logging - - -diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java -index c88ab49f60857d5687facc8523f9edc4d652c81b..2e3220cbbea5f6cb9acb7f8fbaf2ff8f91b09234 100644 ---- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java -+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java -@@ -1758,7 +1758,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { - try { - blockParser = blockParser.parse(false); - } catch (com.mojang.brigadier.exceptions.CommandSyntaxException e) { -- e.printStackTrace(); -+ // Scissors - Don't log errors thrown by Brigadier when an error is thrown - return null; - } - -@@ -1782,8 +1782,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { - resource = CraftNamespacedKey.fromMinecraft(key); - } - } catch (IllegalArgumentException ex) { -- org.bukkit.Bukkit.getLogger().warning("Namespaced resource does not validate: " + key.toString()); -- ex.printStackTrace(); -+ // Scissors - Don't log errors thrown by invalid namespaces when an error is thrown - } - - return resource; diff --git a/patches/server/0010-Fixes-Knowledge-Books-causing-log-spam-when-invalid-.patch b/patches/server/0007-Fixes-Knowledge-Books-causing-log-spam-when-invalid-.patch similarity index 96% rename from patches/server/0010-Fixes-Knowledge-Books-causing-log-spam-when-invalid-.patch rename to patches/server/0007-Fixes-Knowledge-Books-causing-log-spam-when-invalid-.patch index b3cb721..626498f 100644 --- a/patches/server/0010-Fixes-Knowledge-Books-causing-log-spam-when-invalid-.patch +++ b/patches/server/0007-Fixes-Knowledge-Books-causing-log-spam-when-invalid-.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Fixes Knowledge Books causing log spam when invalid data is diff --git a/src/main/java/net/minecraft/world/item/KnowledgeBookItem.java b/src/main/java/net/minecraft/world/item/KnowledgeBookItem.java -index bb5319afd112f1013445e29e9fcad137d4c581f9..1cd62752e675b91fdcc21733509c95d5bd97625a 100644 +index b79f4ce38a42e4dba8ebdfc97dadc531b7245c7a..9c49be7c53a1f2a8c203341b8ded9cd222d0c178 100644 --- a/src/main/java/net/minecraft/world/item/KnowledgeBookItem.java +++ b/src/main/java/net/minecraft/world/item/KnowledgeBookItem.java @@ -40,9 +40,9 @@ public class KnowledgeBookItem extends Item { diff --git a/patches/server/0008-Ignore-errors-thrown-when-trying-to-remove-minecart-.patch b/patches/server/0008-Ignore-errors-thrown-when-trying-to-remove-minecart-.patch deleted file mode 100644 index 6d27963..0000000 --- a/patches/server/0008-Ignore-errors-thrown-when-trying-to-remove-minecart-.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Video -Date: Sun, 13 Mar 2022 08:14:44 -0600 -Subject: [PATCH] Ignore errors thrown when trying to remove minecart entities - with content in them - - -diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java -index d80c7be5b153db4046d0b11c0116c6aa860ea48c..dfbae9ca58722c0aeb6cb9888643016d4cb36f63 100644 ---- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java -+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java -@@ -192,7 +192,12 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme - @Override - public void remove(Entity.RemovalReason reason) { - if (!this.level.isClientSide && reason.shouldDestroy()) { -- Containers.dropContents(this.level, this, this); -+ // Scissors start - Ignore errors thrown when trying to remove minecart entities with content in them -+ try { -+ Containers.dropContents(this.level, this, this); -+ } catch (Exception ignored) { -+ } -+ // Scissors end - } - - super.remove(reason); diff --git a/patches/server/0011-Validate-BlockState-and-SoundEvent-values.patch b/patches/server/0008-Validate-BlockState-and-SoundEvent-values.patch similarity index 88% rename from patches/server/0011-Validate-BlockState-and-SoundEvent-values.patch rename to patches/server/0008-Validate-BlockState-and-SoundEvent-values.patch index f3f29c3..0bfdd7e 100644 --- a/patches/server/0011-Validate-BlockState-and-SoundEvent-values.patch +++ b/patches/server/0008-Validate-BlockState-and-SoundEvent-values.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Validate BlockState and SoundEvent values diff --git a/src/main/java/net/minecraft/nbt/NbtUtils.java b/src/main/java/net/minecraft/nbt/NbtUtils.java -index dca8853944832e8fc5a291aa6b46d84b24181ea7..24f009fa3b84323b4c43e0ed15c224d16a7ede81 100644 +index 9865f9352ecac8175070187c2f67fedddb588864..fe87de42bc099ce41038f7f49ded9a12898e32eb 100644 --- a/src/main/java/net/minecraft/nbt/NbtUtils.java +++ b/src/main/java/net/minecraft/nbt/NbtUtils.java @@ -230,7 +230,7 @@ public final class NbtUtils { @@ -18,10 +18,10 @@ index dca8853944832e8fc5a291aa6b46d84b24181ea7..24f009fa3b84323b4c43e0ed15c224d1 if (compound.contains("Properties", 10)) { CompoundTag compoundTag = compound.getCompound("Properties"); diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java -index 52e4948fd1657fa1776ac6b0142e8c21e7567976..a811b97021e2eed6efc592bc33602a270feb75a0 100644 +index 53d0024daf6963ac4dab575666b0d6a74a39a958..ce13ba13c30428558391defbb09a49429dd10422 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java +++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java -@@ -536,7 +536,7 @@ public abstract class AbstractArrow extends Projectile { +@@ -549,7 +549,7 @@ public abstract class AbstractArrow extends Projectile { this.setCritArrow(nbt.getBoolean("crit")); this.setPierceLevel(nbt.getByte("PierceLevel")); if (nbt.contains("SoundEvent", 8)) { diff --git a/patches/server/0013-Even-more-ResourceLocation-validation-and-log-spam-f.patch b/patches/server/0009-Even-more-ResourceLocation-validation-and-log-spam-f.patch similarity index 95% rename from patches/server/0013-Even-more-ResourceLocation-validation-and-log-spam-f.patch rename to patches/server/0009-Even-more-ResourceLocation-validation-and-log-spam-f.patch index 86bb16e..6823b48 100644 --- a/patches/server/0013-Even-more-ResourceLocation-validation-and-log-spam-f.patch +++ b/patches/server/0009-Even-more-ResourceLocation-validation-and-log-spam-f.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Even more ResourceLocation validation and log spam fixes diff --git a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java -index 02172fdcf587904258387d309938fb379a300524..3c60094119a2b51d5fbab6c559c43293913f6204 100644 +index 7e1885d9cc568a544e934cede32bff05c20b567a..2481c50d8eb58a003e30e2d957b877bce5123a3a 100644 --- a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java +++ b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java @@ -420,7 +420,7 @@ public class AreaEffectCloud extends Entity { @@ -60,7 +60,7 @@ index 0dd0ce9a9b3253e87eda12354249ec2fd2a33cf2..b6920f9432ca1736afbe775186fbbcf1 @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java -index 5a43e420f14fa52d71d41ff3694a179e7a1a5be3..488ccdeb867dcd3aaae4bce77da8b7a11d07eddc 100644 +index cf0be5ef01bddaabbfd11f54b2dacd68c68ad16a..b4b86d7448e6659b1d4e034ffcddd7be77dd977f 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java @@ -67,8 +67,14 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob { diff --git a/patches/server/0016-Do-not-log-invalid-items-in-HoverEvent-and-ItemFrame.patch b/patches/server/0010-Do-not-log-invalid-items-in-HoverEvent-and-ItemFrame.patch similarity index 84% rename from patches/server/0016-Do-not-log-invalid-items-in-HoverEvent-and-ItemFrame.patch rename to patches/server/0010-Do-not-log-invalid-items-in-HoverEvent-and-ItemFrame.patch index 64daf92..a44f444 100644 --- a/patches/server/0016-Do-not-log-invalid-items-in-HoverEvent-and-ItemFrame.patch +++ b/patches/server/0010-Do-not-log-invalid-items-in-HoverEvent-and-ItemFrame.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Do not log invalid items in HoverEvent and ItemFrame diff --git a/src/main/java/net/minecraft/network/chat/HoverEvent.java b/src/main/java/net/minecraft/network/chat/HoverEvent.java -index c5711b3d120699ec78f81e9b6ee80d0764552e94..9c1341803cf892f7f3af11381bd56bc95f31fad0 100644 +index 67feb4e688d049e9f74f0deabb1ec583336a29be..63dbbc0f027ab66d183f81d6a8e0f9e0b85ea562 100644 --- a/src/main/java/net/minecraft/network/chat/HoverEvent.java +++ b/src/main/java/net/minecraft/network/chat/HoverEvent.java -@@ -315,7 +315,7 @@ public class HoverEvent { +@@ -314,7 +314,7 @@ public class HoverEvent { CompoundTag compoundTag = TagParser.parseTag(string); return new HoverEvent.ItemStackInfo(item, i, compoundTag); } catch (CommandSyntaxException var6) { @@ -17,7 +17,7 @@ index c5711b3d120699ec78f81e9b6ee80d0764552e94..9c1341803cf892f7f3af11381bd56bc9 } } -@@ -329,7 +329,7 @@ public class HoverEvent { +@@ -328,7 +328,7 @@ public class HoverEvent { CompoundTag compoundTag = TagParser.parseTag(text.getString()); return new HoverEvent.ItemStackInfo(ItemStack.of(compoundTag)); } catch (CommandSyntaxException var2) { @@ -27,10 +27,10 @@ index c5711b3d120699ec78f81e9b6ee80d0764552e94..9c1341803cf892f7f3af11381bd56bc9 } } diff --git a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java -index b829efdb40051a41b3bf1cabb8bf7d7c952797b5..a0f20bd54f713afe17c9b5fea9fdee6c59b6e219 100644 +index f134a2e68d50fba021b19fac4c75fb35d0e252c6..5e79ce09bf8ba48eb7f5dfdcf1511a2964c3281d 100644 --- a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java +++ b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java -@@ -388,7 +388,7 @@ public class ItemFrame extends HangingEntity { +@@ -396,7 +396,7 @@ public class ItemFrame extends HangingEntity { ItemStack itemstack = ItemStack.of(nbttagcompound1); if (itemstack.isEmpty()) { diff --git a/patches/server/0017-Change-version-fetcher-to-AMG.patch b/patches/server/0011-Change-version-fetcher-to-AMG.patch similarity index 100% rename from patches/server/0017-Change-version-fetcher-to-AMG.patch rename to patches/server/0011-Change-version-fetcher-to-AMG.patch diff --git a/patches/server/0012-Even-more-resource-location-validation.patch b/patches/server/0012-Even-more-resource-location-validation.patch deleted file mode 100644 index 2514c2a..0000000 --- a/patches/server/0012-Even-more-resource-location-validation.patch +++ /dev/null @@ -1,54 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Video -Date: Mon, 14 Mar 2022 00:49:35 -0600 -Subject: [PATCH] Even more resource location validation - - -diff --git a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java -index 4733f74ff028c03a60b73280caf9e4d1e2f0ca30..02172fdcf587904258387d309938fb379a300524 100644 ---- a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java -+++ b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java -@@ -143,7 +143,7 @@ public class AreaEffectCloud extends Entity { - } - - public void setType(String string) { -- this.setPotion(Registry.POTION.get(new ResourceLocation(string))); -+ this.setPotion(Registry.POTION.get(ResourceLocation.tryParse(string))); // Scissors - Validate resource locations - } - // CraftBukkit end - -diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java -index 1c446dba5de89698397041ee38a2e1a00bec8a56..93799eda06c7b699580251f80b641c47643f3615 100644 ---- a/src/main/java/net/minecraft/world/entity/EntityType.java -+++ b/src/main/java/net/minecraft/world/entity/EntityType.java -@@ -513,7 +513,7 @@ public class EntityType implements EntityTypeTest { - }), (entity) -> { - entity.load(nbt); - }, () -> { -- EntityType.LOGGER.warn("Skipping Entity with id {}", nbt.getString("id")); -+ // Scissors - Don't log invalid entities - }); - } - -@@ -537,7 +537,7 @@ public class EntityType implements EntityTypeTest { - } - - public static Optional> by(CompoundTag nbt) { -- return Registry.ENTITY_TYPE.getOptional(new ResourceLocation(nbt.getString("id"))); -+ return Registry.ENTITY_TYPE.getOptional(ResourceLocation.tryParse(nbt.getString("id"))); // Scissors - Validate resource locations - } - - @Nullable -diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java -index 8837fc04a67a656d0e780965ac113d3b28e2369f..11427668a0af28cf638df3574357f696f49af13d 100644 ---- a/src/main/java/net/minecraft/world/entity/Mob.java -+++ b/src/main/java/net/minecraft/world/entity/Mob.java -@@ -570,7 +570,7 @@ public abstract class Mob extends LivingEntity { - - this.setLeftHanded(nbt.getBoolean("LeftHanded")); - if (nbt.contains("DeathLootTable", 8)) { -- this.lootTable = new ResourceLocation(nbt.getString("DeathLootTable")); -+ this.lootTable = ResourceLocation.tryParse(nbt.getString("DeathLootTable")); // Scissors - Validate resource locations - this.lootTableSeed = nbt.getLong("DeathLootTableSeed"); - } - diff --git a/patches/server/0021-Validate-String-UUIDs-during-the-CompoundTag-GamePro.patch b/patches/server/0012-Validate-String-UUIDs-during-the-CompoundTag-GamePro.patch similarity index 82% rename from patches/server/0021-Validate-String-UUIDs-during-the-CompoundTag-GamePro.patch rename to patches/server/0012-Validate-String-UUIDs-during-the-CompoundTag-GamePro.patch index 2e9fb58..bc41f2c 100644 --- a/patches/server/0021-Validate-String-UUIDs-during-the-CompoundTag-GamePro.patch +++ b/patches/server/0012-Validate-String-UUIDs-during-the-CompoundTag-GamePro.patch @@ -6,11 +6,11 @@ Subject: [PATCH] Validate String UUIDs during the CompoundTag -> GameProfile diff --git a/src/main/java/net/minecraft/nbt/NbtUtils.java b/src/main/java/net/minecraft/nbt/NbtUtils.java -index 24f009fa3b84323b4c43e0ed15c224d16a7ede81..1d1876c78f82ce36d45320e4575c79fdc284ce0e 100644 +index fe87de42bc099ce41038f7f49ded9a12898e32eb..07fc1fefcea853ac0aa355312d8c718dc3a4ddd7 100644 --- a/src/main/java/net/minecraft/nbt/NbtUtils.java +++ b/src/main/java/net/minecraft/nbt/NbtUtils.java -@@ -78,7 +78,12 @@ public final class NbtUtils { - +@@ -77,7 +77,12 @@ public final class NbtUtils { + } // Paper start - support string UUID's if (compound.contains("Id", 8)) { - uUID = UUID.fromString(compound.getString("Id")); @@ -22,4 +22,4 @@ index 24f009fa3b84323b4c43e0ed15c224d16a7ede81..1d1876c78f82ce36d45320e4575c79fd + // Scissors end } // Paper end - if (compound.hasUUID("Id")) { + diff --git a/patches/server/0022-Prevent-attributes-with-invalid-namespaces-from-bein.patch b/patches/server/0013-Prevent-attributes-with-invalid-namespaces-from-bein.patch similarity index 87% rename from patches/server/0022-Prevent-attributes-with-invalid-namespaces-from-bein.patch rename to patches/server/0013-Prevent-attributes-with-invalid-namespaces-from-bein.patch index 0ba7328..6ff33a4 100644 --- a/patches/server/0022-Prevent-attributes-with-invalid-namespaces-from-bein.patch +++ b/patches/server/0013-Prevent-attributes-with-invalid-namespaces-from-bein.patch @@ -6,17 +6,17 @@ Subject: [PATCH] Prevent attributes with invalid namespaces from being applied diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java -index 2e3220cbbea5f6cb9acb7f8fbaf2ff8f91b09234..8018709dfce483a9000ada93cf47812fd49458a8 100644 +index 1fe46049cc33c24db04fbfcde36ab275c03177bf..a6d600ef4a90f54123ea53273bc83f1462f8e9f7 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java -@@ -45,6 +45,7 @@ import net.minecraft.nbt.NbtIo; +@@ -46,6 +46,7 @@ import net.minecraft.nbt.NbtIo; import net.minecraft.nbt.StringTag; import net.minecraft.nbt.Tag; import net.minecraft.network.chat.TextComponent; +import net.minecraft.resources.ResourceLocation; // Scissors import net.minecraft.world.item.BlockItem; - import org.apache.commons.codec.binary.Base64; import org.apache.commons.lang.Validate; + import org.apache.commons.lang3.EnumUtils; @@ -481,7 +482,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { AttributeModifier attribMod = CraftAttributeInstance.convert(nmsModifier); diff --git a/patches/server/0024-Don-t-query-player-data-in-the-nbt-component.patch b/patches/server/0014-Don-t-query-player-data-in-the-nbt-component.patch similarity index 81% rename from patches/server/0024-Don-t-query-player-data-in-the-nbt-component.patch rename to patches/server/0014-Don-t-query-player-data-in-the-nbt-component.patch index b8147e2..196bc1f 100644 --- a/patches/server/0024-Don-t-query-player-data-in-the-nbt-component.patch +++ b/patches/server/0014-Don-t-query-player-data-in-the-nbt-component.patch @@ -5,18 +5,18 @@ Subject: [PATCH] Don't query player data in the `nbt` component diff --git a/src/main/java/net/minecraft/network/chat/NbtComponent.java b/src/main/java/net/minecraft/network/chat/NbtComponent.java -index f5f2ec1192303bc55a64dce3e0457e4531a35ba7..62613d9fccd74fe16512fe1fe703dc6db0166b28 100644 +index 8e658eeb4edc83db72c187baa52b7ada7b848af8..e3dc56de3f91e03b1543257f72448a734d914ed7 100644 --- a/src/main/java/net/minecraft/network/chat/NbtComponent.java +++ b/src/main/java/net/minecraft/network/chat/NbtComponent.java -@@ -22,6 +22,7 @@ import net.minecraft.nbt.Tag; +@@ -23,6 +23,7 @@ import net.minecraft.nbt.Tag; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.block.entity.BlockEntity; - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; -@@ -218,7 +219,7 @@ public abstract class NbtComponent extends BaseComponent implements ContextAware + import org.slf4j.Logger; + +@@ -217,7 +218,7 @@ public abstract class NbtComponent extends BaseComponent implements ContextAware protected Stream getData(CommandSourceStack source) throws CommandSyntaxException { if (this.compiledSelector != null) { List list = this.compiledSelector.findEntities(source); diff --git a/patches/server/0014-Fixes-crash-exploit-related-to-out-of-bounds-Axolotl.patch b/patches/server/0014-Fixes-crash-exploit-related-to-out-of-bounds-Axolotl.patch deleted file mode 100644 index bba6256..0000000 --- a/patches/server/0014-Fixes-crash-exploit-related-to-out-of-bounds-Axolotl.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Video -Date: Sun, 20 Mar 2022 04:39:09 -0600 -Subject: [PATCH] Fixes crash exploit related to out of bounds Axolotl variants - - -diff --git a/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java b/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java -index 2b8725087fd3bfeca7162bda2783fdacd13a8390..802c9c87df190dce09f9e703cedcb06874c58389 100644 ---- a/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java -+++ b/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java -@@ -118,7 +118,7 @@ public class Axolotl extends Animal implements LerpingModel, Bucketable { - @Override - public void readAdditionalSaveData(CompoundTag nbt) { - super.readAdditionalSaveData(nbt); -- this.setVariant(Axolotl.Variant.BY_ID[nbt.getInt("Variant")]); -+ this.setVariant(Axolotl.Variant.BY_ID[Math.min(Math.abs(nbt.getInt("Variant")), 4)]); // Scissors - Fixes out of bounds Axolotl variant exploit - this.setFromBucket(nbt.getBoolean("FromBucket")); - } - -@@ -361,7 +361,7 @@ public class Axolotl extends Animal implements LerpingModel, Bucketable { - @Override - public void loadFromBucketTag(CompoundTag nbt) { - Bucketable.loadDefaultDataFromBucketTag(this, nbt); -- this.setVariant(Axolotl.Variant.BY_ID[nbt.getInt("Variant")]); -+ this.setVariant(Axolotl.Variant.BY_ID[Math.min(Math.abs(nbt.getInt("Variant")), 4)]); // Scissors - Fix out-of-bounds Axolotl variant exploit - if (nbt.contains("Age")) { - this.setAge(nbt.getInt("Age")); - } diff --git a/patches/server/0025-Limit-ListTags-to-1024-elements.patch b/patches/server/0015-Limit-ListTags-to-1024-elements.patch similarity index 81% rename from patches/server/0025-Limit-ListTags-to-1024-elements.patch rename to patches/server/0015-Limit-ListTags-to-1024-elements.patch index cfd7ac7..a22d29d 100644 --- a/patches/server/0025-Limit-ListTags-to-1024-elements.patch +++ b/patches/server/0015-Limit-ListTags-to-1024-elements.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Limit ListTags to 1024 elements diff --git a/src/main/java/net/minecraft/nbt/ListTag.java b/src/main/java/net/minecraft/nbt/ListTag.java -index 88bac72edf19c578902f49d20353989ed4d96f8f..6963f2720fcc9888f62f5a1382dd96d82f598ac8 100644 +index ea68b26e506e48d8238b7ee4266e61b211d52bd2..10d3a1b31233f884823ee9a4bb27d70eac3914df 100644 --- a/src/main/java/net/minecraft/nbt/ListTag.java +++ b/src/main/java/net/minecraft/nbt/ListTag.java -@@ -34,6 +34,7 @@ public class ListTag extends CollectionTag { +@@ -33,6 +33,7 @@ public class ListTag extends CollectionTag { list.add(tagType.load(dataInput, i + 1, nbtAccounter)); } diff --git a/patches/server/0015-Validate-coordinates-before-attempting-to-get-block-.patch b/patches/server/0015-Validate-coordinates-before-attempting-to-get-block-.patch deleted file mode 100644 index f6a7776..0000000 --- a/patches/server/0015-Validate-coordinates-before-attempting-to-get-block-.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Video -Date: Sun, 20 Mar 2022 07:46:37 -0600 -Subject: [PATCH] Validate coordinates before attempting to get block entities - when handling Creative Inventory packets - - -diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 621ec8e8a197323da6b423fee57c816ac9d7c875..83333ae9c8e8c1edc6e7f02468bd8dc7e44bb66e 100644 ---- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -2933,20 +2933,24 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser - if (this.player.gameMode.isCreative()) { - boolean flag = packet.getSlotNum() < 0; - ItemStack itemstack = packet.getItem(); -- CompoundTag nbttagcompound = itemstack.getTagElement("BlockEntityTag"); - -+ CompoundTag nbttagcompound = itemstack.getTagElement("BlockEntityTag"); - if (!itemstack.isEmpty() && nbttagcompound != null && nbttagcompound.contains("x") && nbttagcompound.contains("y") && nbttagcompound.contains("z") && this.player.getBukkitEntity().hasPermission("minecraft.nbt.copy")) { // Spigot - BlockPos blockposition = new BlockPos(nbttagcompound.getInt("x"), nbttagcompound.getInt("y"), nbttagcompound.getInt("z")); -- BlockEntity tileentity = this.player.level.getBlockEntity(blockposition); -+ // Scissors start - Validate coordinates and whether or not the player can reach them -+ if (Level.isInSpawnableBounds(blockposition) && !isOutsideOfReach(blockposition.getX(), blockposition.getY(), blockposition.getZ())) { -+ BlockEntity tileentity = this.player.level.getBlockEntity(blockposition); - -- if (tileentity != null) { -- CompoundTag nbttagcompound1 = tileentity.save(new CompoundTag()); -+ if (tileentity != null) { -+ CompoundTag nbttagcompound1 = tileentity.save(new CompoundTag()); - -- nbttagcompound1.remove("x"); -- nbttagcompound1.remove("y"); -- nbttagcompound1.remove("z"); -- itemstack.addTagElement("BlockEntityTag", (Tag) nbttagcompound1); -+ nbttagcompound1.remove("x"); -+ nbttagcompound1.remove("y"); -+ nbttagcompound1.remove("z"); -+ itemstack.addTagElement("BlockEntityTag", (Tag) nbttagcompound1); -+ } - } -+ // Scissors end - } - - boolean flag1 = packet.getSlotNum() >= 1 && packet.getSlotNum() <= 45; diff --git a/patches/server/0026-Fix-lectern-quick-move.patch b/patches/server/0016-Fix-lectern-quick-move.patch similarity index 100% rename from patches/server/0026-Fix-lectern-quick-move.patch rename to patches/server/0016-Fix-lectern-quick-move.patch diff --git a/patches/server/0027-Fixes-creative-killing-potion-effects-and-certain-po.patch b/patches/server/0017-Fixes-creative-killing-potion-effects-and-certain-po.patch similarity index 96% rename from patches/server/0027-Fixes-creative-killing-potion-effects-and-certain-po.patch rename to patches/server/0017-Fixes-creative-killing-potion-effects-and-certain-po.patch index 7ddbe0b..3fd2690 100644 --- a/patches/server/0027-Fixes-creative-killing-potion-effects-and-certain-po.patch +++ b/patches/server/0017-Fixes-creative-killing-potion-effects-and-certain-po.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Fixes creative-killing potion effects and certain potion diff --git a/src/main/java/net/minecraft/world/effect/MobEffect.java b/src/main/java/net/minecraft/world/effect/MobEffect.java -index 79e036d79dec2ec4404baf02c23ba5ccad20cdce..506be74453c6ecc52f05a48b1d95f82175fa6159 100644 +index 8bbb9bdcf95989f1737714655f6f6a269d46d7f2..3f5df0a365ddafe4277988767f8366536b928dab 100644 --- a/src/main/java/net/minecraft/world/effect/MobEffect.java +++ b/src/main/java/net/minecraft/world/effect/MobEffect.java @@ -47,6 +47,7 @@ public class MobEffect { diff --git a/patches/server/0018-Better-handling-of-invalid-JSON-components.patch b/patches/server/0018-Better-handling-of-invalid-JSON-components.patch deleted file mode 100644 index 2c59825..0000000 --- a/patches/server/0018-Better-handling-of-invalid-JSON-components.patch +++ /dev/null @@ -1,199 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Video -Date: Mon, 28 Mar 2022 13:19:43 -0600 -Subject: [PATCH] Better handling of invalid JSON components - - -diff --git a/src/main/java/net/minecraft/network/chat/Component.java b/src/main/java/net/minecraft/network/chat/Component.java -index 5ba1636bbb938373e43c1f3ac561368fc9cffd43..6978d14c6bd90ffb640e39e8666430d95d5ef45c 100644 ---- a/src/main/java/net/minecraft/network/chat/Component.java -+++ b/src/main/java/net/minecraft/network/chat/Component.java -@@ -24,6 +24,8 @@ import java.util.List; - import java.util.Map.Entry; - import java.util.Optional; - import javax.annotation.Nullable; -+ -+import net.minecraft.ChatFormatting; - import net.minecraft.Util; - import net.minecraft.resources.ResourceLocation; - import net.minecraft.util.FormattedCharSequence; -@@ -427,6 +429,26 @@ public interface Component extends Message, FormattedText, Iterable { - return Component.Serializer.GSON.toJsonTree(text); - } - -+ // Scissors start -+ @Nullable -+ public static MutableComponent fromJsonSafe(String json) { -+ try { -+ return fromJson(json); -+ } catch (Exception ex) { -+ return new TextComponent("** Invalid JSON Component **").withStyle(ChatFormatting.RED); -+ } -+ } -+ -+ @Nullable -+ public static MutableComponent fromJsonSafe(JsonElement json) { -+ try { -+ return fromJson(json); -+ } catch (Exception ex) { -+ return new TextComponent("** Invalid JSON Component **").withStyle(ChatFormatting.RED); -+ } -+ } -+ // Scissors end -+ - @Nullable - public static MutableComponent fromJson(String json) { - return (MutableComponent) GsonHelper.fromJson(Component.Serializer.GSON, json, MutableComponent.class, false); -diff --git a/src/main/java/net/minecraft/network/chat/HoverEvent.java b/src/main/java/net/minecraft/network/chat/HoverEvent.java -index 9c1341803cf892f7f3af11381bd56bc95f31fad0..c4394812326bccd70d64b4bd45eb1bb7b53b0905 100644 ---- a/src/main/java/net/minecraft/network/chat/HoverEvent.java -+++ b/src/main/java/net/minecraft/network/chat/HoverEvent.java -@@ -80,7 +80,7 @@ public class HoverEvent { - if (jsonElement != null) { - return action.deserialize(jsonElement); - } else { -- Component component = Component.Serializer.fromJson(json.get("value")); -+ Component component = Component.Serializer.fromJsonSafe(json.get("value")); // Scissors - Use safer method for getting Components from JSON - return component != null ? action.deserializeFromLegacy(component) : null; - } - } -@@ -95,7 +95,7 @@ public class HoverEvent { - } - - public static class Action { -- public static final HoverEvent.Action SHOW_TEXT = new HoverEvent.Action<>("show_text", true, Component.Serializer::fromJson, Component.Serializer::toJsonTree, Function.identity()); -+ public static final HoverEvent.Action SHOW_TEXT = new HoverEvent.Action<>("show_text", true, Component.Serializer::fromJsonSafe, Component.Serializer::toJsonTree, Function.identity()); // Scissors - Use safer method for getting Components from JSON - public static final HoverEvent.Action SHOW_ITEM = new HoverEvent.Action<>("show_item", true, HoverEvent.ItemStackInfo::create, HoverEvent.ItemStackInfo::serialize, HoverEvent.ItemStackInfo::create); - public static final HoverEvent.Action SHOW_ENTITY = new HoverEvent.Action<>("show_entity", true, HoverEvent.EntityTooltipInfo::create, HoverEvent.EntityTooltipInfo::serialize, HoverEvent.EntityTooltipInfo::create); - private static final Map> LOOKUP = Stream.of(SHOW_TEXT, SHOW_ITEM, SHOW_ENTITY).collect(ImmutableMap.toImmutableMap(HoverEvent.Action::getName, (action) -> { -@@ -183,7 +183,7 @@ public class HoverEvent { - return null; - } - // Scissors end -- Component component = Component.Serializer.fromJson(jsonObject.get("name")); -+ Component component = Component.Serializer.fromJsonSafe(jsonObject.get("name")); // Scissors - Use safer method for getting Components from JSON - return new HoverEvent.EntityTooltipInfo(entityType, uUID, component); - } - } -@@ -192,7 +192,7 @@ public class HoverEvent { - public static HoverEvent.EntityTooltipInfo create(Component text) { - try { - CompoundTag compoundTag = TagParser.parseTag(text.getString()); -- Component component = Component.Serializer.fromJson(compoundTag.getString("name")); -+ Component component = Component.Serializer.fromJsonSafe(compoundTag.getString("name")); // Scissors - Use safer method for getting Components from JSON - EntityType entityType = Registry.ENTITY_TYPE.get(new ResourceLocation(compoundTag.getString("type"))); - // Scissors start - UUID uUID; -diff --git a/src/main/java/net/minecraft/network/chat/NbtComponent.java b/src/main/java/net/minecraft/network/chat/NbtComponent.java -index ae9fef071388bc6b10d34a0126c9dd1ac77eb9e7..f5f2ec1192303bc55a64dce3e0457e4531a35ba7 100644 ---- a/src/main/java/net/minecraft/network/chat/NbtComponent.java -+++ b/src/main/java/net/minecraft/network/chat/NbtComponent.java -@@ -77,13 +77,14 @@ public abstract class NbtComponent extends BaseComponent implements ContextAware - if (this.interpreting) { - Component component = DataFixUtils.orElse(ComponentUtils.updateForEntity(source, this.separator, sender, depth), ComponentUtils.DEFAULT_NO_STYLE_SEPARATOR); - return stream.flatMap((text) -> { -+ // Scissors start - Use safer method for getting Components from JSON - try { -- MutableComponent mutableComponent = Component.Serializer.fromJson(text); -+ MutableComponent mutableComponent = Component.Serializer.fromJsonSafe(text); - return Stream.of(ComponentUtils.updateForEntity(source, mutableComponent, sender, depth)); - } catch (Exception var5) { -- LOGGER.warn("Failed to parse component: {}", text, var5); - return Stream.of(); - } -+ // Scissors end - }).reduce((accumulator, current) -> { - return accumulator.append(component).append(current); - }).orElseGet(() -> { -@@ -94,7 +95,7 @@ public abstract class NbtComponent extends BaseComponent implements ContextAware - return stream.map((string) -> { - return new TextComponent(string); - }).reduce((accumulator, current) -> { -- return accumulator.append(text).append(current); -+ return (TextComponent) accumulator.append(text).append(current); - }).orElseGet(() -> { - return new TextComponent(""); - }); -diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index b7c4700fd5db14c77e7ee78311dd77a754d9d41c..07f04c1708b118ace3ed73ae2bf88c29b1c80ad2 100644 ---- a/src/main/java/net/minecraft/world/entity/Entity.java -+++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -2202,12 +2202,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n - this.setRot(this.getYRot(), this.getXRot()); - if (nbt.contains("CustomName", 8)) { - String s = nbt.getString("CustomName"); -- -- try { -- this.setCustomName(Component.Serializer.fromJson(s)); -- } catch (Exception exception) { -- Entity.LOGGER.warn("Failed to parse entity custom name {}", s, exception); -- } -+ this.setCustomName(Component.Serializer.fromJsonSafe(s)); // Scissors - Use safer method for getting Components from JSON - } - - this.setCustomNameVisible(nbt.getBoolean("CustomNameVisible")); -diff --git a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java -index 3281448bf37da8a1b4b7b44f10f4b2438b4a4f29..8038e3a10b563321df1e8cedd26b256078ce745a 100644 ---- a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java -+++ b/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java -@@ -405,7 +405,7 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider { - this.levels = nbt.getInt("Levels"); // SPIGOT-5053, use where available - // CraftBukkit end - if (nbt.contains("CustomName", 8)) { -- this.name = Component.Serializer.fromJson(nbt.getString("CustomName")); -+ this.name = Component.Serializer.fromJsonSafe(nbt.getString("CustomName")); // Scissors - Use safer method for getting Components from JSON - } - - this.lockKey = LockCode.fromTag(nbt); -diff --git a/src/main/java/net/minecraft/world/level/block/entity/EnchantmentTableBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/EnchantmentTableBlockEntity.java -index 40ac65501a0213b43964fd68eb155d4358fb7fd4..9cfc44472e841e1a2cd7de2a1284afdde05a7989 100644 ---- a/src/main/java/net/minecraft/world/level/block/entity/EnchantmentTableBlockEntity.java -+++ b/src/main/java/net/minecraft/world/level/block/entity/EnchantmentTableBlockEntity.java -@@ -44,7 +44,7 @@ public class EnchantmentTableBlockEntity extends BlockEntity implements Nameable - public void load(CompoundTag nbt) { - super.load(nbt); - if (nbt.contains("CustomName", 8)) { -- this.name = Component.Serializer.fromJson(nbt.getString("CustomName")); -+ this.name = Component.Serializer.fromJsonSafe(nbt.getString("CustomName")); // Scissors - Use safer method for getting Components from JSON - } - - } -diff --git a/src/main/java/net/minecraft/world/scores/ScoreboardSaveData.java b/src/main/java/net/minecraft/world/scores/ScoreboardSaveData.java -index 2153e7035535990b5307b85d8bc3dab50c0a3ae8..5f11f9b77684bd91b4cfe77cd415ed42bd9bc21a 100644 ---- a/src/main/java/net/minecraft/world/scores/ScoreboardSaveData.java -+++ b/src/main/java/net/minecraft/world/scores/ScoreboardSaveData.java -@@ -39,7 +39,7 @@ public class ScoreboardSaveData extends SavedData { - } - - PlayerTeam playerTeam = this.scoreboard.addPlayerTeam(string); -- Component component = Component.Serializer.fromJson(compoundTag.getString("DisplayName")); -+ Component component = Component.Serializer.fromJsonSafe(compoundTag.getString("DisplayName")); // Scissors - Use safer method for getting Components from JSON - if (component != null) { - playerTeam.setDisplayName(component); - } -@@ -57,14 +57,14 @@ public class ScoreboardSaveData extends SavedData { - } - - if (compoundTag.contains("MemberNamePrefix", 8)) { -- Component component2 = Component.Serializer.fromJson(compoundTag.getString("MemberNamePrefix")); -+ Component component2 = Component.Serializer.fromJsonSafe(compoundTag.getString("MemberNamePrefix")); // Scissors - Use safer method for getting Components from JSON - if (component2 != null) { - playerTeam.setPlayerPrefix(component2); - } - } - - if (compoundTag.contains("MemberNameSuffix", 8)) { -- Component component3 = Component.Serializer.fromJson(compoundTag.getString("MemberNameSuffix")); -+ Component component3 = Component.Serializer.fromJsonSafe(compoundTag.getString("MemberNameSuffix")); // Scissors - Use safer method for getting Components from JSON - if (component3 != null) { - playerTeam.setPlayerSuffix(component3); - } -@@ -123,7 +123,7 @@ public class ScoreboardSaveData extends SavedData { - string = string.substring(0, 16); - } - -- Component component = Component.Serializer.fromJson(compoundTag.getString("DisplayName")); -+ Component component = Component.Serializer.fromJsonSafe(compoundTag.getString("DisplayName")); // Scissors - Use safer method for getting Components from JSON - ObjectiveCriteria.RenderType renderType = ObjectiveCriteria.RenderType.byId(compoundTag.getString("RenderType")); - this.scoreboard.addObjective(string, objectiveCriteria, component, renderType); - }); diff --git a/patches/server/0019-block-server-side-chunkbans.patch b/patches/server/0019-block-server-side-chunkbans.patch deleted file mode 100644 index ce6afad..0000000 --- a/patches/server/0019-block-server-side-chunkbans.patch +++ /dev/null @@ -1,162 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: ayunami2000 -Date: Mon, 28 Mar 2022 17:02:21 -0400 -Subject: [PATCH] block server-side chunkbans - - -diff --git a/src/main/java/net/minecraft/network/PacketEncoder.java b/src/main/java/net/minecraft/network/PacketEncoder.java -index b039a32b805fc02033fa862a1c40c4a51639e69a..1d407ebea9ff2932f93b7d6842b0e2a4e801b48c 100644 ---- a/src/main/java/net/minecraft/network/PacketEncoder.java -+++ b/src/main/java/net/minecraft/network/PacketEncoder.java -@@ -4,9 +4,17 @@ import io.netty.buffer.ByteBuf; - import io.netty.channel.ChannelHandlerContext; - import io.netty.handler.codec.MessageToByteEncoder; - import io.papermc.paper.adventure.PaperAdventure; // Paper -+ - import java.io.IOException; -+ -+import net.minecraft.nbt.CompoundTag; - import net.minecraft.network.protocol.Packet; - import net.minecraft.network.protocol.PacketFlow; -+import net.minecraft.network.protocol.game.*; -+import net.minecraft.network.syncher.SynchedEntityData; -+import net.minecraft.server.MinecraftServer; -+import net.minecraft.world.item.ItemStack; -+import net.minecraft.world.level.chunk.LevelChunk; - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; - import org.apache.logging.log4j.Marker; -@@ -44,27 +52,93 @@ public class PacketEncoder extends MessageToByteEncoder> { - packet.write(friendlyByteBuf); - int j = friendlyByteBuf.writerIndex() - i; - if (j > 8388608) { -- throw new IllegalArgumentException("Packet too big (is " + j + ", should be less than 8388608): " + packet); -+ // Scissors start -+ noKicking(friendlyByteBuf, packet, integer, channelHandlerContext); -+ //throw new IllegalArgumentException("Packet too big (is " + j + ", should be less than 8388608): " + packet); -+ // Scissors end - } - } catch (Throwable var9) { -+ // Scissors start -+ noKicking(friendlyByteBuf, packet, integer, channelHandlerContext); -+ /* - LOGGER.error("Packet encoding of packet ID {} threw (skippable? {})", integer, packet.isSkippable(), var9); // Paper - WHAT WAS IT? WHO DID THIS TO YOU? WHAT DID YOU SEE? - if (packet.isSkippable()) { - throw new SkipPacketException(var9); - } else { - throw var9; - } -+ */ -+ // Scissors end - } - - // Paper start - int packetLength = friendlyByteBuf.readableBytes(); - if (packetLength > MAX_PACKET_SIZE) { -- throw new PacketTooLargeException(packet, packetLength); -+ // Scissors start -+ friendlyByteBuf.clear(); -+ noKicking(friendlyByteBuf, packet, integer, channelHandlerContext); -+ packetLength = friendlyByteBuf.readableBytes(); -+ if (packetLength > MAX_PACKET_SIZE) { -+ friendlyByteBuf.clear(); -+ //throw new PacketTooLargeException(packet, packetLength); -+ } -+ //throw new PacketTooLargeException(packet, packetLength); -+ // Scissors end - } - // Paper end - } - } - } - -+ // Scissors start -+ private static void noKicking(FriendlyByteBuf friendlyByteBuf, Packet packet, Integer integer, ChannelHandlerContext channelHandlerContext) { -+ // no kicking!! -+ friendlyByteBuf.clear(); -+ friendlyByteBuf.writeVarInt(integer); -+ friendlyByteBuf.adventure$locale = channelHandlerContext.channel().attr(PaperAdventure.LOCALE_ATTRIBUTE).get(); // Paper -+ boolean didIt = true; -+ if (packet instanceof ClientboundBlockEntityDataPacket blockEntityDataPacket) { -+ packet = new ClientboundBlockEntityDataPacket(blockEntityDataPacket.getPos(), blockEntityDataPacket.getType(), new CompoundTag()); -+ } else if (packet instanceof ClientboundLevelChunkPacket chunkPacket) { -+ chunkPacket.clearNbt(); -+ } else if (packet instanceof ClientboundSetEntityDataPacket entityDataPacket) { -+ friendlyByteBuf.writeVarInt(entityDataPacket.getId()); -+ friendlyByteBuf.writeByte(255); -+ didIt = false;//prevent default packet writing -+ } else if (packet instanceof ClientboundContainerSetContentPacket containerSetContentPacket) { -+ containerSetContentPacket.clearNbt(); -+ } else if (packet instanceof ClientboundSetEquipmentPacket setEquipmentPacket) { -+ friendlyByteBuf.writeVarInt(setEquipmentPacket.getEntity()); -+ didIt = false;//prevent default -+ } else if (packet instanceof ClientboundContainerSetSlotPacket containerSetSlotPacket) { -+ //i really would rather cancel this packet entirely buuut idk how sOOOOoooo -+ friendlyByteBuf.writeByte(containerSetSlotPacket.getContainerId()); -+ friendlyByteBuf.writeVarInt(containerSetSlotPacket.getStateId()); -+ friendlyByteBuf.writeShort(containerSetSlotPacket.getSlot()); -+ friendlyByteBuf.writeItem(ItemStack.EMPTY); -+ didIt = false;//prevent default -+ } else if (packet instanceof ClientboundMapItemDataPacket mapItemDataPacket) { -+ packet = new ClientboundMapItemDataPacket(mapItemDataPacket.getMapId(),mapItemDataPacket.getScale(),mapItemDataPacket.isLocked(),null,null); -+ } else { -+ didIt = false; -+ LOGGER.info(packet.getClass().getName() + " overflowed/errored and was not caught!!"); -+ } -+ if (didIt) { -+ try { -+ int i = friendlyByteBuf.writerIndex(); -+ packet.write(friendlyByteBuf); -+ int j = friendlyByteBuf.writerIndex() - i; -+ if (j > 8388608) { -+ friendlyByteBuf.clear(); -+ //throw new IllegalArgumentException("Packet too big (is " + j + ", should be less than 8388608): " + packet); -+ } -+ } catch (Throwable var69) { -+ friendlyByteBuf.clear(); -+ } -+ } -+ } -+ // Scissors end -+ - // Paper start - private static int MAX_PACKET_SIZE = 2097152; - -diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java -index dbd8b9b09b82c1b75e8be9dc7416d9f0863c8c87..f71f68d1482f7e0481a95533e42e8ee5089f15ff 100644 ---- a/src/main/java/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java -+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java -@@ -10,7 +10,14 @@ public class ClientboundContainerSetContentPacket implements Packet items; -- private final ItemStack carriedItem; -+ private ItemStack carriedItem; // Scissors - removed "final" -+ -+ // Scissors start -+ public void clearNbt(){ -+ this.items.clear(); -+ this.carriedItem = ItemStack.EMPTY; -+ } -+ // Scissors end - - public ClientboundContainerSetContentPacket(int syncId, int revision, NonNullList contents, ItemStack cursorStack) { - this.containerId = syncId; -diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacket.java -index 60d72e488bc77cd913328be400ca374a873b4561..89c385c5ec88c8b51f9e118b65f3b9c2a58c7d9b 100644 ---- a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacket.java -+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacket.java -@@ -50,6 +50,13 @@ public class ClientboundLevelChunkPacket implements Packet -Date: Mon, 28 Mar 2022 16:49:17 -0600 -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 8f4c83837d0b01a3dbca2607ea718c371db48ef4..fe2717679f84fbef1b8ff1f9a3c3bf0fba8965f1 100644 ---- a/src/main/java/net/minecraft/network/chat/ComponentUtils.java -+++ b/src/main/java/net/minecraft/network/chat/ComponentUtils.java -@@ -37,8 +37,11 @@ public class ComponentUtils { - } - - public static MutableComponent updateForEntity(@Nullable CommandSourceStack source, Component text, @Nullable Entity sender, int depth) throws CommandSyntaxException { -+ // Scissors start - Reject oversized components -+ MutableComponent result; -+ - if (depth > 100) { -- return text.copy(); -+ result = text.copy(); - } else { - MutableComponent mutableComponent = text instanceof ContextAwareComponent ? ((ContextAwareComponent)text).resolve(source, sender, depth + 1) : text.plainCopy(); - -@@ -46,8 +49,12 @@ 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)); - } -+ -+ // Would the resulting component exceed 65535 bytes when encoded as a string? -+ return Component.Serializer.toJson(result).length() > 65535 ? new TextComponent("") : result; -+ // Scissors end - } - - private static Style resolveStyle(@Nullable CommandSourceStack source, Style style, @Nullable Entity sender, int depth) throws CommandSyntaxException { diff --git a/patches/server/0023-Prevent-abusable-entities-from-being-spawned-by-spaw.patch b/patches/server/0023-Prevent-abusable-entities-from-being-spawned-by-spaw.patch deleted file mode 100644 index b93ca69..0000000 --- a/patches/server/0023-Prevent-abusable-entities-from-being-spawned-by-spaw.patch +++ /dev/null @@ -1,95 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Business Goose -Date: Mon, 4 Apr 2022 00:16:54 +0100 -Subject: [PATCH] Prevent abusable entities from being spawned by spawners - - -diff --git a/src/main/java/net/minecraft/world/level/BaseSpawner.java b/src/main/java/net/minecraft/world/level/BaseSpawner.java -index 569cef8fcb1e3e1e8b66dad4fa9b956b44542bf1..f844e0b1e44f0b45b1febadf02d7b37d3099fbdb 100644 ---- a/src/main/java/net/minecraft/world/level/BaseSpawner.java -+++ b/src/main/java/net/minecraft/world/level/BaseSpawner.java -@@ -19,7 +19,9 @@ import net.minecraft.util.StringUtil; - import net.minecraft.util.random.WeightedRandomList; - import net.minecraft.world.entity.Entity; - import net.minecraft.world.entity.EntityType; -+import net.minecraft.world.entity.LivingEntity; - import net.minecraft.world.entity.Mob; -+import net.minecraft.world.entity.MobCategory; - import net.minecraft.world.entity.MobSpawnType; - import net.minecraft.world.entity.SpawnGroupData; - import net.minecraft.world.entity.SpawnPlacements; -@@ -31,6 +33,7 @@ public abstract class BaseSpawner { - - private static final Logger LOGGER = LogManager.getLogger(); - private static final int EVENT_SPAWN = 1; -+ public static List whitelistedCategories = List.of(MobCategory.CREATURE, MobCategory.MONSTER, MobCategory.WATER_CREATURE, MobCategory.UNDERGROUND_WATER_CREATURE, MobCategory.AMBIENT); // Scissors - public static WeightedRandomList EMPTY_POTENTIALS = WeightedRandomList.create(); // Paper - private->public - public int spawnDelay = 20; - public WeightedRandomList spawnPotentials; -@@ -64,6 +67,13 @@ public abstract class BaseSpawner { - public ResourceLocation getEntityId(@Nullable Level world, BlockPos pos) { - String s = this.nextSpawnData.getTag().getString("id"); - -+ // Scissors start -+ Optional> entityType = EntityType.byString(s); -+ if (entityType.isPresent() && !whitelistedCategories.contains(entityType.get().getCategory())) { -+ return null; -+ } -+ // Scissors end -+ - try { - return StringUtil.isNullOrEmpty(s) ? null : new ResourceLocation(s); - } catch (ResourceLocationException resourcekeyinvalidexception) { -@@ -73,6 +83,12 @@ public abstract class BaseSpawner { - } - - public void setEntityId(EntityType type) { -+ // Scissors start - Don't allow unnatural entities to be added to spawners -+ if (!whitelistedCategories.contains(type.getCategory())) { -+ return; -+ } -+ // Scissors end -+ - this.nextSpawnData.getTag().putString("id", Registry.ENTITY_TYPE.getKey(type).toString()); - this.spawnPotentials = BaseSpawner.EMPTY_POTENTIALS; // CraftBukkit - SPIGOT-3496, MC-92282 - } -@@ -121,7 +137,7 @@ public abstract class BaseSpawner { - CompoundTag nbttagcompound = this.nextSpawnData.getTag(); - Optional> optional = EntityType.by(nbttagcompound); - -- if (!optional.isPresent()) { -+ if (!(optional.isPresent() && whitelistedCategories.contains(optional.get().getCategory()))) { // Scissors - Don't try spawning in entites that aren't whitelisted - this.delay(world, pos); - return; - } -@@ -254,12 +270,16 @@ public abstract class BaseSpawner { - ListTag nbttaglist = nbt.getList("SpawnPotentials", 10); - - for (int i = 0; i < nbttaglist.size(); ++i) { -- list.add(new SpawnData(nbttaglist.getCompound(i))); -+ // Scissors start - Filter unnatural entity types from being added -+ if (isValid(nbttaglist.getCompound(i))) { -+ list.add(new SpawnData(nbttaglist.getCompound(i))); -+ } -+ // Scissors end - } - } - - this.spawnPotentials = WeightedRandomList.create((List) list); -- if (nbt.contains("SpawnData", 10)) { -+ if (nbt.contains("SpawnData", 10) && isValid(nbt.getCompound("SpawnData"))) { // Scissors - Filter unnatural entity types from being added - this.setNextSpawnData(world, pos, new SpawnData(1, nbt.getCompound("SpawnData"))); - } else if (!list.isEmpty()) { - this.spawnPotentials.getRandom(this.random).ifPresent((mobspawnerdata) -> { -@@ -371,4 +391,11 @@ public abstract class BaseSpawner { - public double getoSpin() { - return this.oSpin; - } -+ -+ // Scissors start -+ public boolean isValid(CompoundTag tag) { -+ Optional> type = EntityType.by(tag); -+ return type.isPresent() && whitelistedCategories.contains(type.get().getCategory()); -+ } -+ // Scissors end - } diff --git a/patches/server/0028-Reset-large-tags.patch b/patches/server/0028-Reset-large-tags.patch deleted file mode 100644 index afe426e..0000000 --- a/patches/server/0028-Reset-large-tags.patch +++ /dev/null @@ -1,249 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Business Goose -Date: Mon, 18 Apr 2022 03:56:09 +0100 -Subject: [PATCH] Reset large tags - - -diff --git a/src/main/java/com/github/atlasmediagroup/scissors/NbtUtility.java b/src/main/java/com/github/atlasmediagroup/scissors/NbtUtility.java -new file mode 100644 -index 0000000000000000000000000000000000000000..058203440fd071ce5edbe18391ea60f0a5fbee3a ---- /dev/null -+++ b/src/main/java/com/github/atlasmediagroup/scissors/NbtUtility.java -@@ -0,0 +1,28 @@ -+package com.github.atlasmediagroup.scissors; -+ -+import net.minecraft.nbt.CompoundTag; -+ -+import javax.annotation.Nullable; -+import java.nio.charset.StandardCharsets; -+ -+public class NbtUtility -+{ -+ -+ public static boolean isTooLarge(@Nullable CompoundTag tag) -+ { -+ if (tag == null) return false; -+ return tag.toString().getBytes(StandardCharsets.UTF_8).length > (256 * 1024); -+ } -+ -+ public static class Item -+ { -+ -+ public static CompoundTag removeItemData(CompoundTag tag) -+ { -+ CompoundTag cleaned = new CompoundTag(); -+ cleaned.putString("id", tag.getString("id")); -+ cleaned.putByte("Count", tag.getByte("Count")); -+ return cleaned; -+ } -+ } -+} -diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java -index d02339a07e1da56fd5dc171a5e32b00d63fa555c..fe6cb52573ee50a2c02d7add38b5e8411d7177f4 100644 ---- a/src/main/java/net/minecraft/world/item/ItemStack.java -+++ b/src/main/java/net/minecraft/world/item/ItemStack.java -@@ -1,5 +1,6 @@ - package net.minecraft.world.item; - -+import com.github.atlasmediagroup.scissors.NbtUtility; - import com.google.common.collect.HashMultimap; - import com.google.common.collect.Lists; - import com.google.common.collect.Multimap; -@@ -7,23 +8,28 @@ import com.google.gson.JsonParseException; - import com.mojang.brigadier.StringReader; - import com.mojang.brigadier.exceptions.CommandSyntaxException; - import com.mojang.serialization.Codec; -+import com.mojang.serialization.Dynamic; - import com.mojang.serialization.codecs.RecordCodecBuilder; --import java.text.DecimalFormat; --import java.text.DecimalFormatSymbols; --import java.util.Collection; --import java.util.Iterator; --import java.util.List; --import java.util.Collections; --import java.util.Comparator; --import java.util.Locale; --import java.util.Map.Entry; --import java.util.Objects; --import java.util.Optional; --import java.util.Random; --import java.util.function.Consumer; --import java.util.function.Predicate; --import java.util.stream.Collectors; --import javax.annotation.Nullable; -+import net.minecraft.ChatFormatting; -+import net.minecraft.Util; -+import net.minecraft.advancements.CriteriaTriggers; -+import net.minecraft.commands.arguments.blocks.BlockPredicateArgument; -+import net.minecraft.commands.arguments.blocks.BlockStateParser; -+import net.minecraft.core.BlockPos; -+import net.minecraft.core.Direction; -+import net.minecraft.core.Registry; -+import net.minecraft.nbt.CompoundTag; -+import net.minecraft.nbt.ListTag; -+import net.minecraft.nbt.NbtOps; -+import net.minecraft.network.chat.*; -+import net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket; -+import net.minecraft.resources.ResourceLocation; -+import net.minecraft.server.MinecraftServer; -+import net.minecraft.server.level.ServerLevel; -+import net.minecraft.server.level.ServerPlayer; -+import net.minecraft.sounds.SoundEvent; -+import net.minecraft.sounds.SoundSource; -+import net.minecraft.stats.Stats; - import net.minecraft.tags.BlockTags; - import net.minecraft.tags.Tag; - import net.minecraft.tags.TagContainer; -@@ -31,11 +37,7 @@ import net.minecraft.util.datafix.fixes.References; - import net.minecraft.world.InteractionHand; - import net.minecraft.world.InteractionResult; - import net.minecraft.world.InteractionResultHolder; --import net.minecraft.world.entity.Entity; --import net.minecraft.world.entity.EquipmentSlot; --import net.minecraft.world.entity.LivingEntity; --import net.minecraft.world.entity.MobType; --import net.minecraft.world.entity.SlotAccess; -+import net.minecraft.world.entity.*; - import net.minecraft.world.entity.ai.attributes.Attribute; - import net.minecraft.world.entity.ai.attributes.AttributeModifier; - import net.minecraft.world.entity.ai.attributes.Attributes; -@@ -51,50 +53,13 @@ import net.minecraft.world.item.enchantment.EnchantmentHelper; - import net.minecraft.world.item.enchantment.Enchantments; - import net.minecraft.world.level.ItemLike; - import net.minecraft.world.level.Level; --import net.minecraft.world.level.block.BaseEntityBlock; --import net.minecraft.world.level.block.Block; --import org.apache.logging.log4j.LogManager; --import org.apache.logging.log4j.Logger; -- --// CraftBukkit start --import com.mojang.serialization.Dynamic; --import java.util.List; --import java.util.Map; --import net.minecraft.ChatFormatting; --import net.minecraft.Util; --import net.minecraft.advancements.CriteriaTriggers; --import net.minecraft.commands.arguments.blocks.BlockPredicateArgument; --import net.minecraft.commands.arguments.blocks.BlockStateParser; --import net.minecraft.core.BlockPos; --import net.minecraft.core.Direction; --import net.minecraft.core.Registry; --import net.minecraft.nbt.CompoundTag; --import net.minecraft.nbt.ListTag; --import net.minecraft.nbt.NbtOps; --import net.minecraft.network.chat.Component; --import net.minecraft.network.chat.ComponentUtils; --import net.minecraft.network.chat.HoverEvent; --import net.minecraft.network.chat.MutableComponent; --import net.minecraft.network.chat.Style; --import net.minecraft.network.chat.TextComponent; --import net.minecraft.network.chat.TranslatableComponent; --import net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket; --import net.minecraft.resources.ResourceLocation; --import net.minecraft.server.MinecraftServer; --import net.minecraft.server.level.ServerLevel; --import net.minecraft.server.level.ServerPlayer; --import net.minecraft.sounds.SoundEvent; --import net.minecraft.sounds.SoundSource; --import net.minecraft.stats.Stats; --import net.minecraft.world.level.block.Blocks; --import net.minecraft.world.level.block.JukeboxBlock; --import net.minecraft.world.level.block.SaplingBlock; --import net.minecraft.world.level.block.SoundType; --import net.minecraft.world.level.block.WitherSkullBlock; -+import net.minecraft.world.level.block.*; - import net.minecraft.world.level.block.entity.BlockEntity; - import net.minecraft.world.level.block.entity.SignBlockEntity; - import net.minecraft.world.level.block.entity.SkullBlockEntity; - import net.minecraft.world.level.block.state.pattern.BlockInWorld; -+import org.apache.logging.log4j.LogManager; -+import org.apache.logging.log4j.Logger; - import org.bukkit.Location; - import org.bukkit.TreeType; - import org.bukkit.block.BlockState; -@@ -106,6 +71,15 @@ import org.bukkit.entity.Player; - import org.bukkit.event.block.BlockFertilizeEvent; - import org.bukkit.event.player.PlayerItemDamageEvent; - import org.bukkit.event.world.StructureGrowEvent; -+ -+import javax.annotation.Nullable; -+import java.text.DecimalFormat; -+import java.text.DecimalFormatSymbols; -+import java.util.*; -+import java.util.Map.Entry; -+import java.util.function.Consumer; -+import java.util.function.Predicate; -+import java.util.stream.Collectors; - // CraftBukkit end - - public final class ItemStack { -@@ -245,6 +219,13 @@ public final class ItemStack { - - // CraftBukkit - break into own method - private void load(CompoundTag nbttagcompound) { -+ // Scissors start - Reset large tags -+ if (NbtUtility.isTooLarge(nbttagcompound)) { -+ // Reset tag without destroying item -+ nbttagcompound = NbtUtility.Item.removeItemData(nbttagcompound); -+ } -+ // Scissors end -+ - this.item = (Item) Registry.ITEM.get(new ResourceLocation(nbttagcompound.getString("id"))); - this.count = nbttagcompound.getByte("Count"); - if (nbttagcompound.contains("tag", 10)) { -@@ -485,7 +466,11 @@ public final class ItemStack { - nbt.putString("id", minecraftkey == null ? "minecraft:air" : minecraftkey.toString()); - nbt.putByte("Count", (byte) this.count); - if (this.tag != null) { -- nbt.put("tag", this.tag.copy()); -+ // Scissors start - Don't save large tags -+ if (!NbtUtility.isTooLarge(this.tag)) { -+ nbt.put("tag", this.tag.copy()); -+ } -+ // Scissors end - } - - return nbt; -@@ -815,6 +800,9 @@ public final class ItemStack { - } - // Paper end - public void setTag(@Nullable CompoundTag nbt) { -+ // Scissors start - Ignore large tags -+ if (NbtUtility.isTooLarge(nbt)) return; -+ // Scissors end - this.tag = nbt; - processEnchantOrder(this.tag); // Paper - if (this.getItem().canBeDepleted()) { -diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java -index 14da2997b5fff4434b1fe8d5a1b3109dde143740..a4385cea2d472611cfc7ef43662367bb1d780333 100644 ---- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java -+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java -@@ -1,16 +1,12 @@ - package org.bukkit.craftbukkit.inventory; - --import static org.bukkit.craftbukkit.inventory.CraftMetaItem.*; - import com.google.common.collect.ImmutableMap; --import java.util.Map; - import net.minecraft.nbt.CompoundTag; - import net.minecraft.nbt.ListTag; - import net.minecraft.world.item.Item; - import org.apache.commons.lang.Validate; - import org.bukkit.Material; --import org.bukkit.NamespacedKey; - import org.bukkit.configuration.serialization.DelegateDeserialization; --import org.bukkit.craftbukkit.enchantments.CraftEnchantment; - import org.bukkit.craftbukkit.util.CraftLegacy; - import org.bukkit.craftbukkit.util.CraftMagicNumbers; - import org.bukkit.craftbukkit.util.CraftNamespacedKey; -@@ -19,6 +15,11 @@ import org.bukkit.inventory.ItemStack; - import org.bukkit.inventory.meta.ItemMeta; - import org.bukkit.material.MaterialData; - -+import java.util.Map; -+ -+import static org.bukkit.craftbukkit.inventory.CraftMetaItem.ENCHANTMENTS_ID; -+import static org.bukkit.craftbukkit.inventory.CraftMetaItem.ENCHANTMENTS_LVL; -+ - @DelegateDeserialization(ItemStack.class) - public final class CraftItemStack extends ItemStack { -