From 343f0b78b23fbb64064111411e77502d0728b535 Mon Sep 17 00:00:00 2001 From: Telesphoreo Date: Sun, 15 Oct 2023 17:45:13 -0500 Subject: [PATCH] Patches from Luna (#144) --- build-data/dev-imports.txt | 11 ---- gradle.properties | 4 +- ...illing-potion-effects-and-certain-po.patch | 53 --------------- .../server/0039-Limit-map-decorations.patch | 46 ------------- patches/server/0001-Build-changes.patch | 20 +----- patches/server/0002-UUID-validation.patch | 4 +- .../0003-ResourceLocation-validation.patch | 17 +---- ...-handling-of-invalid-JSON-components.patch | 18 +++++ .../0013-Block-server-side-chunkbans.patch} | 66 +++++++++---------- ...-oversized-components-from-updating.patch} | 0 ...Scissors-configuration-file-command.patch} | 4 +- ...s-with-invalid-namespaces-from-bein.patch} | 0 ...ry-player-data-in-the-nbt-component.patch} | 0 ...tring-tag-visitors-to-1024-elements.patch} | 0 ...illing-potion-effects-and-certain-po.patch | 34 ++++++++++ ...ch => 0020-Fix-negative-death-times.patch} | 2 +- ...ehicle-collision-checks-to-3-and-di.patch} | 39 +++++------ ...Add-custom-classes-used-by-Scissors.patch} | 0 ...tags.patch => 0023-Reset-large-tags.patch} | 2 +- ...-Don-t-log-invalid-teams-to-console.patch} | 2 +- ...-bounds-HangingEntity-crash-exploit.patch} | 0 ...ch => 0026-Add-MasterBlockFireEvent.patch} | 0 ...> 0027-Add-spectator-teleport-event.patch} | 21 +++--- ...28-Prevent-invalid-container-events.patch} | 6 +- ...unning-commands-in-books-by-default.patch} | 0 ...k-entity-entity-tag-query-positions.patch} | 2 +- ...ents-on-Signs-bypassing-permissions.patch} | 0 ...-legacy-messages-over-1k-characters.patch} | 0 ...tch => 0033-Prevent-velocity-freeze.patch} | 0 ...n-option-to-disable-chat-signatures.patch} | 15 ++--- ...Patch-large-selector-distance-crash.patch} | 32 ++++++--- ...ch-invalid-entity-rotation-log-spam.patch} | 0 ...mit-sculk-catalyst-cursor-positions.patch} | 0 .../server/0038-Limit-map-decorations.patch | 36 ++++++++++ .../server/0039-Limit-map-decorations.patch | 48 -------------- ...layer-banning-using-duplicate-UUIDs.patch} | 0 ...on-t-warn-on-duplicate-entity-UUIDs.patch} | 0 ...component-extra-empty-array-exploit.patch} | 0 ...pth-limit-to-Component-deserializer.patch} | 0 ...0043-Implement-command-block-events.patch} | 10 +-- ...tch => 0044-Add-depth-limit-to-SNBT.patch} | 0 ...ch => 0045-Limit-beacon-effectRange.patch} | 0 ...ove-validation-of-ResourceLocations.patch} | 0 ...n-t-log-on-too-many-chained-updates.patch} | 0 ...048-Fix-packet-related-lag-exploits.patch} | 10 +-- ...-Limit-save-data-for-Bees-and-Vexes.patch} | 2 +- ...tch => 0050-Mute-invalid-attributes.patch} | 0 ...051-Mute-invalid-Enderdragon-phases.patch} | 0 ...l-Components-in-the-Component-codec.patch} | 43 +++++------- ...dd-length-limit-to-note-block-sound.patch} | 0 50 files changed, 224 insertions(+), 323 deletions(-) delete mode 100644 patches/removed/server/0020-Fixes-creative-killing-potion-effects-and-certain-po.patch delete mode 100644 patches/removed/server/0039-Limit-map-decorations.patch rename patches/{removed/server/0014-Block-server-side-chunkbans.patch => server/0013-Block-server-side-chunkbans.patch} (77%) rename patches/server/{0013-Reject-oversized-components-from-updating.patch => 0014-Reject-oversized-components-from-updating.patch} (100%) rename patches/server/{0014-Add-Scissors-configuration-file-command.patch => 0015-Add-Scissors-configuration-file-command.patch} (99%) rename patches/server/{0015-Prevent-attributes-with-invalid-namespaces-from-bein.patch => 0016-Prevent-attributes-with-invalid-namespaces-from-bein.patch} (100%) rename patches/server/{0016-Don-t-query-player-data-in-the-nbt-component.patch => 0017-Don-t-query-player-data-in-the-nbt-component.patch} (100%) rename patches/server/{0017-Limit-string-tag-visitors-to-1024-elements.patch => 0018-Limit-string-tag-visitors-to-1024-elements.patch} (100%) create mode 100644 patches/server/0019-Fixes-creative-killing-potion-effects-and-certain-po.patch rename patches/server/{0018-Fix-negative-death-times.patch => 0020-Fix-negative-death-times.patch} (90%) rename patches/{removed/server/0022-Limit-amount-of-vehicle-collision-checks-to-3-and-di.patch => server/0021-Limit-amount-of-vehicle-collision-checks-to-3-and-di.patch} (72%) rename patches/server/{0019-Add-custom-classes-used-by-Scissors.patch => 0022-Add-custom-classes-used-by-Scissors.patch} (100%) rename patches/server/{0020-Reset-large-tags.patch => 0023-Reset-large-tags.patch} (99%) rename patches/server/{0021-Don-t-log-invalid-teams-to-console.patch => 0024-Don-t-log-invalid-teams-to-console.patch} (91%) rename patches/server/{0022-Fixes-out-of-bounds-HangingEntity-crash-exploit.patch => 0025-Fixes-out-of-bounds-HangingEntity-crash-exploit.patch} (100%) rename patches/server/{0023-Add-MasterBlockFireEvent.patch => 0026-Add-MasterBlockFireEvent.patch} (100%) rename patches/server/{0024-Add-spectator-teleport-event.patch => 0027-Add-spectator-teleport-event.patch} (75%) rename patches/server/{0025-Prevent-invalid-container-events.patch => 0028-Prevent-invalid-container-events.patch} (89%) rename patches/server/{0026-Disable-running-commands-in-books-by-default.patch => 0029-Disable-running-commands-in-books-by-default.patch} (100%) rename patches/server/{0027-Validate-block-entity-entity-tag-query-positions.patch => 0030-Validate-block-entity-entity-tag-query-positions.patch} (95%) rename patches/server/{0028-Fix-ClickEvents-on-Signs-bypassing-permissions.patch => 0031-Fix-ClickEvents-on-Signs-bypassing-permissions.patch} (100%) rename patches/server/{0029-Refuse-to-convert-legacy-messages-over-1k-characters.patch => 0032-Refuse-to-convert-legacy-messages-over-1k-characters.patch} (100%) rename patches/server/{0030-Prevent-velocity-freeze.patch => 0033-Prevent-velocity-freeze.patch} (100%) rename patches/server/{0031-Add-configuration-option-to-disable-chat-signatures.patch => 0034-Add-configuration-option-to-disable-chat-signatures.patch} (92%) rename patches/{removed/server/0033-Patch-large-selector-distance-crash.patch => server/0035-Patch-large-selector-distance-crash.patch} (61%) rename patches/server/{0032-Patch-invalid-entity-rotation-log-spam.patch => 0036-Patch-invalid-entity-rotation-log-spam.patch} (100%) rename patches/server/{0033-Limit-sculk-catalyst-cursor-positions.patch => 0037-Limit-sculk-catalyst-cursor-positions.patch} (100%) create mode 100644 patches/server/0038-Limit-map-decorations.patch delete mode 100644 patches/server/0039-Limit-map-decorations.patch rename patches/server/{0034-Prevent-player-banning-using-duplicate-UUIDs.patch => 0039-Prevent-player-banning-using-duplicate-UUIDs.patch} (100%) rename patches/server/{0035-Don-t-warn-on-duplicate-entity-UUIDs.patch => 0040-Don-t-warn-on-duplicate-entity-UUIDs.patch} (100%) rename patches/server/{0036-Fix-component-extra-empty-array-exploit.patch => 0041-Fix-component-extra-empty-array-exploit.patch} (100%) rename patches/server/{0037-Add-depth-limit-to-Component-deserializer.patch => 0042-Add-depth-limit-to-Component-deserializer.patch} (100%) rename patches/server/{0038-Implement-command-block-events.patch => 0043-Implement-command-block-events.patch} (92%) rename patches/server/{0040-Add-depth-limit-to-SNBT.patch => 0044-Add-depth-limit-to-SNBT.patch} (100%) rename patches/server/{0042-Limit-beacon-effectRange.patch => 0045-Limit-beacon-effectRange.patch} (100%) rename patches/server/{0041-Improve-validation-of-ResourceLocations.patch => 0046-Improve-validation-of-ResourceLocations.patch} (100%) rename patches/server/{0043-Don-t-log-on-too-many-chained-updates.patch => 0047-Don-t-log-on-too-many-chained-updates.patch} (100%) rename patches/server/{0044-Fix-packet-related-lag-exploits.patch => 0048-Fix-packet-related-lag-exploits.patch} (89%) rename patches/server/{0045-Limit-save-data-for-Bees-and-Vexes.patch => 0049-Limit-save-data-for-Bees-and-Vexes.patch} (96%) rename patches/server/{0046-Mute-invalid-attributes.patch => 0050-Mute-invalid-attributes.patch} (100%) rename patches/server/{0047-Mute-invalid-Enderdragon-phases.patch => 0051-Mute-invalid-Enderdragon-phases.patch} (100%) rename patches/{removed/server/0053-Don-t-return-null-Components-in-the-Component-codec.patch => server/0052-Don-t-return-null-Components-in-the-Component-codec.patch} (63%) rename patches/server/{0048-Add-length-limit-to-note-block-sound.patch => 0053-Add-length-limit-to-note-block-sound.patch} (100%) diff --git a/build-data/dev-imports.txt b/build-data/dev-imports.txt index 5eb90ff..b818b96 100644 --- a/build-data/dev-imports.txt +++ b/build-data/dev-imports.txt @@ -8,14 +8,3 @@ # To import classes from the vanilla Minecraft jar use `minecraft` as the artifactId: # minecraft net.minecraft.world.level.entity.LevelEntityGetterAdapter # minecraft net/minecraft/world/level/entity/LevelEntityGetter.java - -## Used in Scissors 1.19 -#minecraft net/minecraft/world/ContainerHelper -#minecraft net/minecraft/network/chat/contents/NbtContents -#minecraft net/minecraft/network/chat/ComponentUtils -#minecraft net/minecraft/network/chat/contents/EntityDataSource - -## Used in Scissors 1.20.2 -#minecraft net/minecraft/network/chat/HoverEvent -#minecraft net/minecraft/world/level/block/entity/DecoratedPotBlockEntity -#minecraft net/minecraft/advancements/critereon/MinMaxBounds \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index ef9bd20..a0069a3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,9 +2,9 @@ group=me.totalfreedom.scissors version=1.20.2-R0.1-SNAPSHOT mcVersion=1.20.2 -paperRef=852c1c236d080d9fd907a5f4fd3e850437996aa2 +paperRef=e57af7d01e509c747520cc1037169029256289bf org.gradle.caching=true org.gradle.parallel=true org.gradle.vfs.watch=false -org.gradle.jvmargs=-Xmx4096m \ No newline at end of file +org.gradle.jvmargs=-Xmx4096m diff --git a/patches/removed/server/0020-Fixes-creative-killing-potion-effects-and-certain-po.patch b/patches/removed/server/0020-Fixes-creative-killing-potion-effects-and-certain-po.patch deleted file mode 100644 index 9e4a7ab..0000000 --- a/patches/removed/server/0020-Fixes-creative-killing-potion-effects-and-certain-po.patch +++ /dev/null @@ -1,53 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Video -Date: Mon, 11 Apr 2022 13:33:52 -0600 -Subject: [PATCH] Fixes creative-killing potion effects and certain potion - effect overflows - - -diff --git a/src/main/java/net/minecraft/world/effect/MobEffect.java b/src/main/java/net/minecraft/world/effect/MobEffect.java -index 53cc6befb752affcfec65e18365f6d369448d407..181f5aa262689617ff3ad766dae485c36b88c9aa 100644 ---- a/src/main/java/net/minecraft/world/effect/MobEffect.java -+++ b/src/main/java/net/minecraft/world/effect/MobEffect.java -@@ -57,6 +57,7 @@ public class MobEffect { - } - - public void applyEffectTick(LivingEntity entity, int amplifier) { -+ boolean god = entity instanceof Player player && (player.isCreative() || player.isInvulnerable()); // Scissors - if (this == MobEffects.REGENERATION) { - if (entity.getHealth() < entity.getMaxHealth()) { - entity.heal(1.0F, RegainReason.MAGIC_REGEN); // CraftBukkit -@@ -83,17 +84,31 @@ public class MobEffect { - // CraftBukkit end - } - } else if ((this != MobEffects.HEAL || entity.isInvertedHealAndHarm()) && (this != MobEffects.HARM || !entity.isInvertedHealAndHarm())) { -- if (this == MobEffects.HARM && !entity.isInvertedHealAndHarm() || this == MobEffects.HEAL && entity.isInvertedHealAndHarm()) { -+ // Scissors start -+ amplifier = Math.min(Math.abs(amplifier), 124); -+ if (!god && (this == MobEffects.HARM && !entity.isInvertedHealAndHarm() || this == MobEffects.HEAL && entity.isInvertedHealAndHarm())) { -+ // Scissors end - entity.hurt(entity.damageSources().magic(), (float) (6 << amplifier)); - } - } else { -- entity.heal((float) Math.max(4 << amplifier, 0), RegainReason.MAGIC); // CraftBukkit -+ // Scissors start -+ if (!god) { -+ amplifier = Math.min(Math.abs(amplifier), 124); -+ entity.heal((float) Math.max(4 << amplifier, 0), RegainReason.MAGIC); // CraftBukkit -+ } -+ // Scissors end - } - - } - - public void applyInstantenousEffect(@Nullable Entity source, @Nullable Entity attacker, LivingEntity target, int amplifier, double proximity) { - int j; -+ // Scissors start - Don't apply any healing/harming effects for Creative/Invulnerable players and cap the amplifier for those who aren't. -+ if (target instanceof Player player && (player.isCreative() || player.isInvulnerable())) { -+ return; -+ } -+ amplifier = Math.min(Math.abs(amplifier), 124); -+ // Scissors end - - if ((this != MobEffects.HEAL || target.isInvertedHealAndHarm()) && (this != MobEffects.HARM || !target.isInvertedHealAndHarm())) { - if ((this != MobEffects.HARM || target.isInvertedHealAndHarm()) && (this != MobEffects.HEAL || !target.isInvertedHealAndHarm())) { diff --git a/patches/removed/server/0039-Limit-map-decorations.patch b/patches/removed/server/0039-Limit-map-decorations.patch deleted file mode 100644 index 027190b..0000000 --- a/patches/removed/server/0039-Limit-map-decorations.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Luna -Date: Fri, 28 Apr 2023 16:29:23 -0300 -Subject: [PATCH] Limit map decorations - - -diff --git a/src/main/java/net/minecraft/world/level/saveddata/maps/MapDecoration.java b/src/main/java/net/minecraft/world/level/saveddata/maps/MapDecoration.java -index 347d2914f9560a3ee8cea59444bc0dfbb7cf3456..b6a38b1458957bd444fea439fa81d2976ffb86e0 100644 ---- a/src/main/java/net/minecraft/world/level/saveddata/maps/MapDecoration.java -+++ b/src/main/java/net/minecraft/world/level/saveddata/maps/MapDecoration.java -@@ -2,6 +2,7 @@ package net.minecraft.world.level.saveddata.maps; - - import java.util.Objects; - import javax.annotation.Nullable; -+import net.minecraft.ChatFormatting; // Scissors - import net.minecraft.network.chat.Component; - import net.minecraft.util.Mth; - -@@ -14,6 +15,11 @@ public class MapDecoration { - private final Component name; - - public MapDecoration(MapDecoration.Type type, byte x, byte z, byte rotation, @Nullable Component text) { -+ // Scissors start - Limit decoration text length -+ if (text != null && text.getString().length() > 32) { -+ text = null; -+ } -+ // Scissors end - this.type = type; - this.x = x; - this.y = z; -diff --git a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java -index 3b12030b49b1c539684d75ca3896eb498400ef99..0d55d73bd31747ad9579aebbb77f315aa3dc2bc8 100644 ---- a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java -+++ b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java -@@ -354,6 +354,11 @@ public class MapItemSavedData extends SavedData { - } - - private void addDecoration(MapDecoration.Type type, @Nullable LevelAccessor world, String key, double x, double z, double rotation, @Nullable Component text) { -+ // Scissors start - Limit decoration count -+ if (this.decorations.size() > 32) { -+ return; -+ } -+ // Scissors end - int i = 1 << this.scale; - float f = (float) (x - (double) this.centerX) / (float) i; - float f1 = (float) (z - (double) this.centerZ) / (float) i; diff --git a/patches/server/0001-Build-changes.patch b/patches/server/0001-Build-changes.patch index f5826ef..a5eb427 100644 --- a/patches/server/0001-Build-changes.patch +++ b/patches/server/0001-Build-changes.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Build changes diff --git a/build.gradle.kts b/build.gradle.kts -index c187641f0ec6444a10e0e1583e1697d07e8f0267..9d13bd2d5cb152c6aa5834ad735d1695c05c097e 100644 +index a79461457ea19339f47572c70705d655ebc55276..1ac1484fa13e1aadf6dfc964e7797534e2231950 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -13,8 +13,12 @@ configurations.named(log4jPlugins.compileClasspathConfigurationName) { @@ -23,7 +23,7 @@ index c187641f0ec6444a10e0e1583e1697d07e8f0267..9d13bd2d5cb152c6aa5834ad735d1695 // Paper start implementation("org.jline:jline-terminal-jansi:3.21.0") implementation("net.minecrell:terminalconsoleappender:1.3.0") -@@ -68,11 +72,19 @@ tasks.jar { +@@ -66,11 +70,19 @@ tasks.jar { val gitHash = git("rev-parse", "--short=7", "HEAD").getText().trim() val implementationVersion = System.getenv("BUILD_NUMBER") ?: "\"$gitHash\"" val date = git("show", "-s", "--format=%ci", gitHash).getText().trim() // Paper @@ -45,7 +45,7 @@ index c187641f0ec6444a10e0e1583e1697d07e8f0267..9d13bd2d5cb152c6aa5834ad735d1695 "Implementation-Vendor" to date, // Paper "Specification-Title" to "Bukkit", "Specification-Version" to project.version, -@@ -156,7 +168,7 @@ fun TaskContainer.registerRunTask( +@@ -154,7 +166,7 @@ fun TaskContainer.registerRunTask( name: String, block: JavaExec.() -> Unit ): TaskProvider = register(name) { @@ -133,17 +133,3 @@ index 774556a62eb240da42e84db4502e2ed43495be17..741c76c4dfa0bb34cc23bd795c194bde Properties properties = new Properties(); if (stream != null) { -diff --git a/src/test/java/org/bukkit/craftbukkit/legacy/PersistentDataContainerLegacyTest.java b/src/test/java/org/bukkit/craftbukkit/legacy/PersistentDataContainerLegacyTest.java -index 4afaac5928e55e6ef233deb058150e2ec63162c4..c7201e0d1d8fe664b461b1d443c21782bdbfa63c 100644 ---- a/src/test/java/org/bukkit/craftbukkit/legacy/PersistentDataContainerLegacyTest.java -+++ b/src/test/java/org/bukkit/craftbukkit/legacy/PersistentDataContainerLegacyTest.java -@@ -49,7 +49,9 @@ public class PersistentDataContainerLegacyTest extends AbstractTestingBase { - assertEquals(Float.valueOf(Float.MAX_VALUE), pdc.get(this.key("float"), PersistentDataType.FLOAT), "legacy float was wrong"); - assertEquals(Double.valueOf(Double.MAX_VALUE), pdc.get(this.key("double"), PersistentDataType.DOUBLE), "legacy double was wrong"); - assertEquals("stringy", pdc.get(this.key("string_simple"), PersistentDataType.STRING), "legacy string-simple was wrong"); -+ /* This test fails for some reason and I don't know why - assertEquals("What a fun complex string 🔥", pdc.get(this.key("string_complex"), PersistentDataType.STRING), "legacy string-complex was wrong"); -+ */ - - assertArrayEquals(new byte[]{Byte.MIN_VALUE}, pdc.get(this.key("byte_array"), PersistentDataType.BYTE_ARRAY), "legacy byte array was wrong"); - diff --git a/patches/server/0002-UUID-validation.patch b/patches/server/0002-UUID-validation.patch index ee9d2dd..03a55aa 100644 --- a/patches/server/0002-UUID-validation.patch +++ b/patches/server/0002-UUID-validation.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Telesphoreo -Date: Sun, 24 Sep 2023 15:09:27 -0500 +From: Video +Date: Sat, 12 Mar 2022 19:34:59 -0700 Subject: [PATCH] UUID validation diff --git a/patches/server/0003-ResourceLocation-validation.patch b/patches/server/0003-ResourceLocation-validation.patch index ec6b65f..3e1f1a6 100644 --- a/patches/server/0003-ResourceLocation-validation.patch +++ b/patches/server/0003-ResourceLocation-validation.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Telesphoreo -Date: Sun, 24 Sep 2023 15:27:44 -0500 +From: Video +Date: Sun, 13 Mar 2022 07:39:26 -0600 Subject: [PATCH] ResourceLocation validation @@ -109,19 +109,6 @@ index 0425151e688966442340ea1cf892aff34ffe0791..244b04e0020b1bd1e7be34a1b6266a8a this.lootTableSeed = nbt.getLong("LootTableSeed"); return true; } else { -diff --git a/src/main/java/net/minecraft/world/level/block/entity/DecoratedPotBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/DecoratedPotBlockEntity.java -index 6f154e5c4321b761ffa210401885ee3a1dac351b..404585564325e2ec45fc17c5cca4be9356c50093 100644 ---- a/src/main/java/net/minecraft/world/level/block/entity/DecoratedPotBlockEntity.java -+++ b/src/main/java/net/minecraft/world/level/block/entity/DecoratedPotBlockEntity.java -@@ -105,7 +105,7 @@ public class DecoratedPotBlockEntity extends BlockEntity { - return Items.BRICK; - } else { - Tag tag = list.get(index); -- return BuiltInRegistries.ITEM.get(ResourceLocation.tryParse(tag.getAsString())); -+ return BuiltInRegistries.ITEM.get(ResourceLocation.tryParse(tag.getAsString())); // Scissors - } - } - } diff --git a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java index 081691f9710ff1115e4308f79ed49fbc38941193..c29dfd15e147d5c4d9c9584ff7803c2a52009f0d 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java diff --git a/patches/server/0012-Better-handling-of-invalid-JSON-components.patch b/patches/server/0012-Better-handling-of-invalid-JSON-components.patch index 6980650..4c578ba 100644 --- a/patches/server/0012-Better-handling-of-invalid-JSON-components.patch +++ b/patches/server/0012-Better-handling-of-invalid-JSON-components.patch @@ -4,6 +4,24 @@ Date: Mon, 28 Mar 2022 13:19:43 -0600 Subject: [PATCH] Better handling of invalid JSON components +diff --git a/src/main/java/io/papermc/paper/util/MCUtil.java b/src/main/java/io/papermc/paper/util/MCUtil.java +index d02546b18cb689724887b4e85e8d32a18828a4ad..f8ffd6a52ad8c13eb13f51afe3a864cd3595d7eb 100644 +--- a/src/main/java/io/papermc/paper/util/MCUtil.java ++++ b/src/main/java/io/papermc/paper/util/MCUtil.java +@@ -655,12 +655,6 @@ public final class MCUtil { + return null; + } + String string = compound.getString(key); +- try { +- return net.minecraft.network.chat.Component.Serializer.fromJson(string); +- } catch (com.google.gson.JsonParseException e) { +- org.bukkit.Bukkit.getLogger().warning("Unable to parse " + key + " from " + compound +": " + e.getMessage()); +- } +- +- return null; ++ return net.minecraft.network.chat.Component.Serializer.fromJsonSafe(string); + } + } diff --git a/src/main/java/net/minecraft/network/chat/Component.java b/src/main/java/net/minecraft/network/chat/Component.java index b540ce21c65ad52ad7e94d2ca2b3926c0875bee1..9cb6fa8e35c89f73e7c95dbe219a4bf6d00b60a9 100644 --- a/src/main/java/net/minecraft/network/chat/Component.java diff --git a/patches/removed/server/0014-Block-server-side-chunkbans.patch b/patches/server/0013-Block-server-side-chunkbans.patch similarity index 77% rename from patches/removed/server/0014-Block-server-side-chunkbans.patch rename to patches/server/0013-Block-server-side-chunkbans.patch index 013e808..ee6f6ac 100644 --- a/patches/removed/server/0014-Block-server-side-chunkbans.patch +++ b/patches/server/0013-Block-server-side-chunkbans.patch @@ -5,12 +5,12 @@ 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 fbfadeb83719b81f42724e79c59e92ed88fdece7..7de21c9bcc1f3c556790da62f96cc44995e877b2 100644 +index 45b4f1c295eda2fcc5067a4b21de247218ef117f..f2e7585630ff724f966c7bcedc17e502d786870d 100644 --- a/src/main/java/net/minecraft/network/PacketEncoder.java +++ b/src/main/java/net/minecraft/network/PacketEncoder.java -@@ -6,9 +6,17 @@ import io.netty.channel.ChannelHandlerContext; - import io.netty.handler.codec.MessageToByteEncoder; - import io.papermc.paper.adventure.PaperAdventure; // Paper +@@ -7,8 +7,16 @@ import io.netty.handler.codec.MessageToByteEncoder; + import io.netty.util.Attribute; + import io.netty.util.AttributeKey; import java.io.IOException; +import java.util.Collections; // Scissors +import net.minecraft.ChatFormatting; // Scissors @@ -19,7 +19,6 @@ index fbfadeb83719b81f42724e79c59e92ed88fdece7..7de21c9bcc1f3c556790da62f96cc449 +import net.minecraft.network.chat.Component; // Scissors +import net.minecraft.network.chat.SignedMessageBody; // Scissors import net.minecraft.network.protocol.Packet; - import net.minecraft.network.protocol.PacketFlow; +import net.minecraft.network.protocol.game.*; // Scissors import net.minecraft.util.profiling.jfr.JvmProfiler; +import net.minecraft.world.item.ItemStack; // Scissors @@ -27,20 +26,20 @@ index fbfadeb83719b81f42724e79c59e92ed88fdece7..7de21c9bcc1f3c556790da62f96cc449 public class PacketEncoder extends MessageToByteEncoder> { @@ -19,6 +27,23 @@ public class PacketEncoder extends MessageToByteEncoder> { - this.flow = side; + this.codecKey = protocolKey; } + // Scissors start -+ private static int tryWrite(Packet packet, FriendlyByteBuf friendlyByteBuf, ChannelHandlerContext channelHandlerContext, int i) { ++ private int tryWrite(Packet packet, FriendlyByteBuf friendlyByteBuf, ChannelHandlerContext channelHandlerContext, int i) { + friendlyByteBuf.writeVarInt(i); -+ friendlyByteBuf.adventure$locale = channelHandlerContext.channel().attr(PaperAdventure.LOCALE_ATTRIBUTE).get(); ++ friendlyByteBuf.adventure$locale = channelHandlerContext.channel().attr(io.papermc.paper.adventure.PaperAdventure.LOCALE_ATTRIBUTE).get(); // Paper + + int j = friendlyByteBuf.writerIndex(); + packet.write(friendlyByteBuf); + int k = friendlyByteBuf.writerIndex() - j; + int packetLength = friendlyByteBuf.readableBytes(); -+ if (k > 8388608 || packetLength > MAX_PACKET_SIZE) { -+ throw new SkipPacketException(new IllegalArgumentException("Packet too big (is " + k + "): " + packet)); ++ if (packetLength > MAX_PACKET_SIZE) { ++ throw new PacketTooLargeException(packet, this.codecKey, packetLength); + } + + return k; @@ -48,14 +47,14 @@ index fbfadeb83719b81f42724e79c59e92ed88fdece7..7de21c9bcc1f3c556790da62f96cc449 + // Scissors end + protected void encode(ChannelHandlerContext channelHandlerContext, Packet packet, ByteBuf byteBuf) throws Exception { - ConnectionProtocol connectionProtocol = channelHandlerContext.channel().attr(Connection.ATTRIBUTE_PROTOCOL).get(); - if (connectionProtocol == null) { -@@ -33,38 +58,59 @@ public class PacketEncoder extends MessageToByteEncoder> { + Attribute> attribute = channelHandlerContext.channel().attr(this.codecKey); + ConnectionProtocol.CodecData codecData = attribute.get(); +@@ -34,39 +59,59 @@ public class PacketEncoder extends MessageToByteEncoder> { throw new IOException("Can't serialize unregistered packet"); } else { FriendlyByteBuf friendlyByteBuf = new FriendlyByteBuf(byteBuf); - friendlyByteBuf.writeVarInt(i); -- friendlyByteBuf.adventure$locale = channelHandlerContext.channel().attr(PaperAdventure.LOCALE_ATTRIBUTE).get(); // Paper +- friendlyByteBuf.adventure$locale = channelHandlerContext.channel().attr(io.papermc.paper.adventure.PaperAdventure.LOCALE_ATTRIBUTE).get(); // Paper + // Scissors start + int k; @@ -65,33 +64,34 @@ index fbfadeb83719b81f42724e79c59e92ed88fdece7..7de21c9bcc1f3c556790da62f96cc449 - int k = friendlyByteBuf.writerIndex() - j; - if (false && k > 8388608) { // Paper - disable - throw new IllegalArgumentException("Packet too big (is " + k + ", should be less than 8388608): " + packet); -- } else { -- int l = channelHandlerContext.channel().attr(Connection.ATTRIBUTE_PROTOCOL).get().getId(); -- JvmProfiler.INSTANCE.onPacketSent(l, i, channelHandlerContext.channel().remoteAddress(), k); - } -+ k = tryWrite(packet, friendlyByteBuf, channelHandlerContext, i); - } catch (Throwable var10) { -- LOGGER.error("Packet encoding of packet ID {} threw (skippable? {})", i, packet.isSkippable(), var10); // Paper - Give proper error message +- +- JvmProfiler.INSTANCE.onPacketSent(codecData.protocol(), i, channelHandlerContext.channel().remoteAddress(), k); ++ k = this.tryWrite(packet, friendlyByteBuf, channelHandlerContext, i); + } catch (Throwable var13) { +- LOGGER.error("Packet encoding of packet ID {} threw (skippable? {})", i, packet.isSkippable(), var13); // Paper - Give proper error message - if (packet.isSkippable()) { -- throw new SkipPacketException(var10); -- } else { -- throw var10; +- throw new SkipPacketException(var13); + packet = capPacket(packet, i); + if (packet == null) { + throw new SkipPacketException(new IllegalArgumentException("Packet too big: " + packet)); } +- +- throw var13; +- } finally { +- // Paper start +- int packetLength = friendlyByteBuf.readableBytes(); +- if (packetLength > MAX_PACKET_SIZE) { +- throw new PacketTooLargeException(packet, this.codecKey, packetLength); +- } +- // Paper end +- ProtocolSwapHandler.swapProtocolIfNeeded(attribute, packet); + friendlyByteBuf.clear(); -+ k = tryWrite(packet, friendlyByteBuf, channelHandlerContext, i); ++ k = this.tryWrite(packet, friendlyByteBuf, channelHandlerContext, i); } -- // Paper start -- int packetLength = friendlyByteBuf.readableBytes(); -- if (packetLength > MAX_PACKET_SIZE) { -- throw new PacketTooLargeException(packet, packetLength); -- } -- // Paper end -+ int l = channelHandlerContext.channel().attr(Connection.ATTRIBUTE_PROTOCOL).get().getId(); -+ JvmProfiler.INSTANCE.onPacketSent(l, i, channelHandlerContext.channel().remoteAddress(), k); ++ JvmProfiler.INSTANCE.onPacketSent(codecData.protocol(), i, channelHandlerContext.channel().remoteAddress(), k); ++ ProtocolSwapHandler.swapProtocolIfNeeded(attribute, packet); + // Scissors end } } @@ -146,7 +146,7 @@ index 3944852921335c78a04a9dc301882ab5b152b1ed..96ee53c7cc862e059328c5cdf5e07f30 this.type = blockEntityType; this.tag = nbt.isEmpty() ? null : nbt; diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java -index 39b879f21f958dbd91ab0f74e5d4f3c74928fc33..688287c637a0d4b28d630b7304a3c2cf339bdf54 100644 +index 51e24105facfe71ce9f2757c6c881a21b58dacfd..5692fbae221fb01d32d92edc7bea0f6312e24e1c 100644 --- a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java +++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java @@ -33,6 +33,13 @@ public class ClientboundLevelChunkPacketData { diff --git a/patches/server/0013-Reject-oversized-components-from-updating.patch b/patches/server/0014-Reject-oversized-components-from-updating.patch similarity index 100% rename from patches/server/0013-Reject-oversized-components-from-updating.patch rename to patches/server/0014-Reject-oversized-components-from-updating.patch diff --git a/patches/server/0014-Add-Scissors-configuration-file-command.patch b/patches/server/0015-Add-Scissors-configuration-file-command.patch similarity index 99% rename from patches/server/0014-Add-Scissors-configuration-file-command.patch rename to patches/server/0015-Add-Scissors-configuration-file-command.patch index a1ef884..f2a7c3d 100644 --- a/patches/server/0014-Add-Scissors-configuration-file-command.patch +++ b/patches/server/0015-Add-Scissors-configuration-file-command.patch @@ -447,7 +447,7 @@ index dbccbcb9b44e4efacdf53c2d161115cc20b36cff..c3eb9eef724fa04ede965c5875b948c8 this.setFlightAllowed(dedicatedserverproperties.allowFlight); this.setMotd(dedicatedserverproperties.motd); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 5d8b8b17854c1ae2a5e2ccfb8df1d7b927191f03..f14def6e5923afa4880ef3e5626cc973d4b01e48 100644 +index f7c3b65e0d6c76189aea00232b33722c4363d7dd..8b872a406752a72d49ff029e2586d4ac17d7be1f 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -1038,6 +1038,7 @@ public final class CraftServer implements Server { @@ -482,7 +482,7 @@ index 5d8b8b17854c1ae2a5e2ccfb8df1d7b927191f03..f14def6e5923afa4880ef3e5626cc973 public void restart() { org.spigotmc.RestartCommand.restart(); diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java -index e3c230fd2a054a8cb60328c9309410a2f53dad26..d2e06850ec9edadb76668e41403203c66731a961 100644 +index ebec18e919885f9220693a8a419d239e8cddd567..544698c044d9eef57abccfbd41cbfdd6873e4f55 100644 --- a/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/src/main/java/org/bukkit/craftbukkit/Main.java @@ -180,6 +180,20 @@ public class Main { diff --git a/patches/server/0015-Prevent-attributes-with-invalid-namespaces-from-bein.patch b/patches/server/0016-Prevent-attributes-with-invalid-namespaces-from-bein.patch similarity index 100% rename from patches/server/0015-Prevent-attributes-with-invalid-namespaces-from-bein.patch rename to patches/server/0016-Prevent-attributes-with-invalid-namespaces-from-bein.patch diff --git a/patches/server/0016-Don-t-query-player-data-in-the-nbt-component.patch b/patches/server/0017-Don-t-query-player-data-in-the-nbt-component.patch similarity index 100% rename from patches/server/0016-Don-t-query-player-data-in-the-nbt-component.patch rename to patches/server/0017-Don-t-query-player-data-in-the-nbt-component.patch diff --git a/patches/server/0017-Limit-string-tag-visitors-to-1024-elements.patch b/patches/server/0018-Limit-string-tag-visitors-to-1024-elements.patch similarity index 100% rename from patches/server/0017-Limit-string-tag-visitors-to-1024-elements.patch rename to patches/server/0018-Limit-string-tag-visitors-to-1024-elements.patch diff --git a/patches/server/0019-Fixes-creative-killing-potion-effects-and-certain-po.patch b/patches/server/0019-Fixes-creative-killing-potion-effects-and-certain-po.patch new file mode 100644 index 0000000..8e64224 --- /dev/null +++ b/patches/server/0019-Fixes-creative-killing-potion-effects-and-certain-po.patch @@ -0,0 +1,34 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Video +Date: Mon, 11 Apr 2022 13:33:52 -0600 +Subject: [PATCH] Fixes creative-killing potion effects and certain potion + effect overflows + + +diff --git a/src/main/java/net/minecraft/world/effect/HealOrHarmMobEffect.java b/src/main/java/net/minecraft/world/effect/HealOrHarmMobEffect.java +index 1c7794de5f0a7238b944c9473e2cc9d011ef2306..9c594c504611b9da5fcd119284b2dcb4b59d3bf4 100644 +--- a/src/main/java/net/minecraft/world/effect/HealOrHarmMobEffect.java ++++ b/src/main/java/net/minecraft/world/effect/HealOrHarmMobEffect.java +@@ -16,6 +16,11 @@ class HealOrHarmMobEffect extends InstantenousMobEffect { + @Override + public void applyEffectTick(LivingEntity entity, int amplifier) { + super.applyEffectTick(entity, amplifier); ++ // Scissors start - Don't apply any healing/harming effects for Creative/Invulnerable players and cap the amplifier for those who aren't. ++ if (entity instanceof net.minecraft.world.entity.player.Player player && (player.isCreative() || player.isInvulnerable())) return; ++ amplifier = Math.min(Math.abs(amplifier), 124); ++ // Scissors end ++ + if (this.isHarm == entity.isInvertedHealAndHarm()) { + entity.heal((float) Math.max(4 << amplifier, 0), org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.MAGIC); // CraftBukkit + } else { +@@ -27,6 +32,10 @@ class HealOrHarmMobEffect extends InstantenousMobEffect { + @Override + public void applyInstantenousEffect(@Nullable Entity source, @Nullable Entity attacker, LivingEntity target, int amplifier, double proximity) { + int j; ++ // Scissors start - Don't apply any healing/harming effects for Creative/Invulnerable players and cap the amplifier for those who aren't. ++ if (target instanceof net.minecraft.world.entity.player.Player player && (player.isCreative() || player.isInvulnerable())) return; ++ amplifier = Math.min(Math.abs(amplifier), 124); ++ // Scissors end + + if (this.isHarm == target.isInvertedHealAndHarm()) { + j = (int) (proximity * (double) (4 << amplifier) + 0.5D); diff --git a/patches/server/0018-Fix-negative-death-times.patch b/patches/server/0020-Fix-negative-death-times.patch similarity index 90% rename from patches/server/0018-Fix-negative-death-times.patch rename to patches/server/0020-Fix-negative-death-times.patch index aabc6c6..69c0571 100644 --- a/patches/server/0018-Fix-negative-death-times.patch +++ b/patches/server/0020-Fix-negative-death-times.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Fix negative death times diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index c039c77d0dd6ec1d336948ca6b5351d6fae1d8bb..6d851bf1cff06edf0717080c65a504c63914b8cd 100644 +index b95f88d5e5b4785ee063695fd81935636a0588d1..168b002377e258f84a3bb86dd8e4a5f42060e3e0 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -629,7 +629,7 @@ public abstract class LivingEntity extends Entity implements Attackable { diff --git a/patches/removed/server/0022-Limit-amount-of-vehicle-collision-checks-to-3-and-di.patch b/patches/server/0021-Limit-amount-of-vehicle-collision-checks-to-3-and-di.patch similarity index 72% rename from patches/removed/server/0022-Limit-amount-of-vehicle-collision-checks-to-3-and-di.patch rename to patches/server/0021-Limit-amount-of-vehicle-collision-checks-to-3-and-di.patch index 23e7718..2eba0c0 100644 --- a/patches/removed/server/0022-Limit-amount-of-vehicle-collision-checks-to-3-and-di.patch +++ b/patches/server/0021-Limit-amount-of-vehicle-collision-checks-to-3-and-di.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Limit amount of vehicle collision checks to 3 and discard diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java -index 9948a28dae4edba877c13ef0156be5ff58df3fa2..9e25d4a3384d0157b99f7bd4d5f7edce032ece6b 100644 +index 44a6118d3bd67a95180f750c17967561946e2e87..8aece67eba8d6b558bc2441b8b8e599f86e12e4f 100644 --- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java +++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java @@ -8,6 +8,7 @@ import com.mojang.datafixers.util.Pair; @@ -17,7 +17,7 @@ index 9948a28dae4edba877c13ef0156be5ff58df3fa2..9e25d4a3384d0157b99f7bd4d5f7edce import javax.annotation.Nullable; import net.minecraft.BlockUtil; import net.minecraft.Util; -@@ -107,6 +108,7 @@ public abstract class AbstractMinecart extends Entity { +@@ -111,6 +112,7 @@ public abstract class AbstractMinecart extends Entity { private double flyingX = 0.949999988079071D; // Paper - restore vanilla precision private double flyingY = 0.949999988079071D; // Paper - restore vanilla precision private double flyingZ = 0.949999988079071D; // Paper - restore vanilla precision @@ -25,20 +25,18 @@ index 9948a28dae4edba877c13ef0156be5ff58df3fa2..9e25d4a3384d0157b99f7bd4d5f7edce public double maxSpeed = 0.4D; // CraftBukkit end -@@ -434,8 +436,10 @@ public abstract class AbstractMinecart extends Entity { +@@ -432,8 +434,8 @@ public abstract class AbstractMinecart extends Entity { if (this.getMinecartType() == AbstractMinecart.Type.RIDEABLE && this.getDeltaMovement().horizontalDistanceSqr() > 0.01D) { List list = this.level().getEntities((Entity) this, this.getBoundingBox().inflate(0.20000000298023224D, 0.0D, 0.20000000298023224D), EntitySelector.pushableBy(this)); - if (!list.isEmpty()) { -- for (int l = 0; l < list.size(); ++l) { -+ // Scissors start -+ if (!list.isEmpty() && (System.currentTimeMillis() - lastLargeCollision) >= TimeUnit.SECONDS.toMillis(5)) { // Using TimeUnit for better code readability -+ for (int l = 0; l < Math.min(3, list.size()); ++l) { -+ // Scissors end - Entity entity = (Entity) list.get(l); +- Iterator iterator = list.iterator(); ++ if (!list.isEmpty() && (System.currentTimeMillis() - lastLargeCollision) >= TimeUnit.SECONDS.toMillis(5)) { // Scissors - add collision debounce, using TimeUnit for better code readability ++ Iterator iterator = list.size() <= 15 ? list.iterator() : list.subList(0, 15).iterator(); // Scissors - if (!(entity instanceof Player) && !(entity instanceof IronGolem) && !(entity instanceof AbstractMinecart) && !this.isVehicle() && !entity.isPassenger()) { -@@ -462,6 +466,14 @@ public abstract class AbstractMinecart extends Entity { + while (iterator.hasNext()) { + Entity entity = (Entity) iterator.next(); +@@ -462,6 +464,14 @@ public abstract class AbstractMinecart extends Entity { entity.push(this); } } @@ -52,9 +50,9 @@ index 9948a28dae4edba877c13ef0156be5ff58df3fa2..9e25d4a3384d0157b99f7bd4d5f7edce + // Scissors end } } else { - Iterator iterator = this.level().getEntities(this, this.getBoundingBox().inflate(0.20000000298023224D, 0.0D, 0.20000000298023224D)).iterator(); + Iterator iterator1 = this.level().getEntities(this, this.getBoundingBox().inflate(0.20000000298023224D, 0.0D, 0.20000000298023224D)).iterator(); diff --git a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java -index 35aeba4e8430e6419caa9db4a0b931a994228618..289eb39b15a283b0d9dbc33823f3a73f87202907 100644 +index 5c07da62c82bc70138f6cb5007629d6974be69ac..301a72dffd4ac58333d987e85d22136498d2d82a 100644 --- a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java +++ b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java @@ -5,6 +5,7 @@ import com.google.common.collect.UnmodifiableIterator; @@ -65,7 +63,7 @@ index 35aeba4e8430e6419caa9db4a0b931a994228618..289eb39b15a283b0d9dbc33823f3a73f import javax.annotation.Nullable; import net.minecraft.BlockUtil; import net.minecraft.core.BlockPos; -@@ -109,6 +110,7 @@ public class Boat extends Entity implements VariantHolder { +@@ -112,6 +113,7 @@ public class Boat extends Entity implements VariantHolder { public double unoccupiedDeceleration = -1; public boolean landBoats = false; // CraftBukkit end @@ -73,20 +71,19 @@ index 35aeba4e8430e6419caa9db4a0b931a994228618..289eb39b15a283b0d9dbc33823f3a73f public Boat(EntityType type, Level world) { super(type, world); -@@ -421,10 +423,10 @@ public class Boat extends Entity implements VariantHolder { +@@ -465,9 +467,9 @@ public class Boat extends Entity implements VariantHolder { this.checkInsideBlocks(); List list = this.level().getEntities((Entity) this, this.getBoundingBox().inflate(0.20000000298023224D, -0.009999999776482582D, 0.20000000298023224D), EntitySelector.pushableBy(this)); - if (!list.isEmpty()) { + if (!list.isEmpty() && (System.currentTimeMillis() - lastLargeCollision) >= TimeUnit.SECONDS.toMillis(5)) { // Scissors - add collision debounce, using TimeUnit for better code readability boolean flag = !this.level().isClientSide && !(this.getControllingPassenger() instanceof Player); +- Iterator iterator = list.iterator(); ++ Iterator iterator = list.size() <= 15 ? list.iterator() : list.subList(0, 15).iterator(); // Scissors -- for (int j = 0; j < list.size(); ++j) { -+ for (int j = 0; j < Math.min(3, list.size()); ++j) { // Scissors - Limit amount of vehicle collision checks to 3 maximum - Entity entity = (Entity) list.get(j); - - if (!entity.hasPassenger((Entity) this)) { -@@ -435,6 +437,14 @@ public class Boat extends Entity implements VariantHolder { + while (iterator.hasNext()) { + Entity entity = (Entity) iterator.next(); +@@ -480,6 +482,14 @@ public class Boat extends Entity implements VariantHolder { } } } diff --git a/patches/server/0019-Add-custom-classes-used-by-Scissors.patch b/patches/server/0022-Add-custom-classes-used-by-Scissors.patch similarity index 100% rename from patches/server/0019-Add-custom-classes-used-by-Scissors.patch rename to patches/server/0022-Add-custom-classes-used-by-Scissors.patch diff --git a/patches/server/0020-Reset-large-tags.patch b/patches/server/0023-Reset-large-tags.patch similarity index 99% rename from patches/server/0020-Reset-large-tags.patch rename to patches/server/0023-Reset-large-tags.patch index ea31410..15a1805 100644 --- a/patches/server/0020-Reset-large-tags.patch +++ b/patches/server/0023-Reset-large-tags.patch @@ -59,7 +59,7 @@ index 4092c7a8c2b0d9d26e6f4d97386735236300d132..04c47cf1a920ae6c356449df801227ee } } diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java -index 16f087adbf94b8fd6726ffd300b103dd709ad406..71c5d49bfe7c39c11f27e17b156dd4e6d0fef285 100644 +index 4697df75fdee2023c41260bed211e3e3d90d2b9b..1ddf7ca63fee0849f3a41f230e0fd7ab636ff05c 100644 --- a/src/main/java/net/minecraft/world/item/ItemStack.java +++ b/src/main/java/net/minecraft/world/item/ItemStack.java @@ -21,6 +21,7 @@ import java.util.function.Predicate; diff --git a/patches/server/0021-Don-t-log-invalid-teams-to-console.patch b/patches/server/0024-Don-t-log-invalid-teams-to-console.patch similarity index 91% rename from patches/server/0021-Don-t-log-invalid-teams-to-console.patch rename to patches/server/0024-Don-t-log-invalid-teams-to-console.patch index a9f6fa2..c9d51fa 100644 --- a/patches/server/0021-Don-t-log-invalid-teams-to-console.patch +++ b/patches/server/0024-Don-t-log-invalid-teams-to-console.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Don't log invalid teams to console diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 6d851bf1cff06edf0717080c65a504c63914b8cd..93f3eab8008af9fa91dca88ebd2dfbdf27c8281a 100644 +index 168b002377e258f84a3bb86dd8e4a5f42060e3e0..065d2c1543832190bd8bdcd4b553542115c07e64 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -861,7 +861,7 @@ public abstract class LivingEntity extends Entity implements Attackable { diff --git a/patches/server/0022-Fixes-out-of-bounds-HangingEntity-crash-exploit.patch b/patches/server/0025-Fixes-out-of-bounds-HangingEntity-crash-exploit.patch similarity index 100% rename from patches/server/0022-Fixes-out-of-bounds-HangingEntity-crash-exploit.patch rename to patches/server/0025-Fixes-out-of-bounds-HangingEntity-crash-exploit.patch diff --git a/patches/server/0023-Add-MasterBlockFireEvent.patch b/patches/server/0026-Add-MasterBlockFireEvent.patch similarity index 100% rename from patches/server/0023-Add-MasterBlockFireEvent.patch rename to patches/server/0026-Add-MasterBlockFireEvent.patch diff --git a/patches/server/0024-Add-spectator-teleport-event.patch b/patches/server/0027-Add-spectator-teleport-event.patch similarity index 75% rename from patches/server/0024-Add-spectator-teleport-event.patch rename to patches/server/0027-Add-spectator-teleport-event.patch index 2b5dd57..be1985b 100644 --- a/patches/server/0024-Add-spectator-teleport-event.patch +++ b/patches/server/0027-Add-spectator-teleport-event.patch @@ -1,21 +1,20 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Telesphoreo -Date: Sun, 24 Sep 2023 16:19:52 -0500 +From: Allink +Date: Tue, 5 Jul 2022 04:12:31 +0100 Subject: [PATCH] Add spectator teleport event diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index b5fe3786b337fb99920aac72b865e6a25bcb9649..8e1b95371ed0bac1a4fff2d6550de118ba399650 100644 +index 34fcdeb0f4039f1fc6c4c8c593cc615560af1ba2..40166e794ad1f2d2555bd47a442771db5bee79f9 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -29,6 +29,7 @@ import java.util.function.UnaryOperator; - import java.util.stream.Collectors; - import java.util.stream.Stream; - import javax.annotation.Nullable; -+import me.totalfreedom.scissors.event.player.SpectatorTeleportEvent; - import net.minecraft.ChatFormatting; - import net.minecraft.SharedConstants; - import net.minecraft.Util; +@@ -1,5 +1,6 @@ + package net.minecraft.server.network; + ++import me.totalfreedom.scissors.event.player.SpectatorTeleportEvent; // Scissors + import com.google.common.collect.Lists; + import com.google.common.primitives.Floats; + import com.mojang.authlib.GameProfile; @@ -2005,6 +2006,12 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl Entity entity = packet.getEntity(worldserver); diff --git a/patches/server/0025-Prevent-invalid-container-events.patch b/patches/server/0028-Prevent-invalid-container-events.patch similarity index 89% rename from patches/server/0025-Prevent-invalid-container-events.patch rename to patches/server/0028-Prevent-invalid-container-events.patch index 129b334..4f63dd6 100644 --- a/patches/server/0025-Prevent-invalid-container-events.patch +++ b/patches/server/0028-Prevent-invalid-container-events.patch @@ -5,13 +5,13 @@ Subject: [PATCH] Prevent invalid container events diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 8e1b95371ed0bac1a4fff2d6550de118ba399650..e6d7b277b3b305d5069c73d9107c20ff11e34b7c 100644 +index 40166e794ad1f2d2555bd47a442771db5bee79f9..0c878b99574b0e27f1463069f66d24bdecb01647 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -30,6 +30,7 @@ import java.util.stream.Collectors; +@@ -30,6 +30,7 @@ import java.util.function.UnaryOperator; + import java.util.stream.Collectors; import java.util.stream.Stream; import javax.annotation.Nullable; - import me.totalfreedom.scissors.event.player.SpectatorTeleportEvent; +import net.kyori.adventure.text.format.NamedTextColor; // Scissors import net.minecraft.ChatFormatting; import net.minecraft.SharedConstants; diff --git a/patches/server/0026-Disable-running-commands-in-books-by-default.patch b/patches/server/0029-Disable-running-commands-in-books-by-default.patch similarity index 100% rename from patches/server/0026-Disable-running-commands-in-books-by-default.patch rename to patches/server/0029-Disable-running-commands-in-books-by-default.patch diff --git a/patches/server/0027-Validate-block-entity-entity-tag-query-positions.patch b/patches/server/0030-Validate-block-entity-entity-tag-query-positions.patch similarity index 95% rename from patches/server/0027-Validate-block-entity-entity-tag-query-positions.patch rename to patches/server/0030-Validate-block-entity-entity-tag-query-positions.patch index ed9d6cd..5f019ed 100644 --- a/patches/server/0027-Validate-block-entity-entity-tag-query-positions.patch +++ b/patches/server/0030-Validate-block-entity-entity-tag-query-positions.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Validate block entity/entity tag query positions diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index e6d7b277b3b305d5069c73d9107c20ff11e34b7c..001b7ae2067809d7da1d84d7637639f21a1aa980 100644 +index 0c878b99574b0e27f1463069f66d24bdecb01647..51331ad3f295b55631adcb6f47e34d0b03bd148a 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -1261,7 +1261,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl diff --git a/patches/server/0028-Fix-ClickEvents-on-Signs-bypassing-permissions.patch b/patches/server/0031-Fix-ClickEvents-on-Signs-bypassing-permissions.patch similarity index 100% rename from patches/server/0028-Fix-ClickEvents-on-Signs-bypassing-permissions.patch rename to patches/server/0031-Fix-ClickEvents-on-Signs-bypassing-permissions.patch diff --git a/patches/server/0029-Refuse-to-convert-legacy-messages-over-1k-characters.patch b/patches/server/0032-Refuse-to-convert-legacy-messages-over-1k-characters.patch similarity index 100% rename from patches/server/0029-Refuse-to-convert-legacy-messages-over-1k-characters.patch rename to patches/server/0032-Refuse-to-convert-legacy-messages-over-1k-characters.patch diff --git a/patches/server/0030-Prevent-velocity-freeze.patch b/patches/server/0033-Prevent-velocity-freeze.patch similarity index 100% rename from patches/server/0030-Prevent-velocity-freeze.patch rename to patches/server/0033-Prevent-velocity-freeze.patch diff --git a/patches/server/0031-Add-configuration-option-to-disable-chat-signatures.patch b/patches/server/0034-Add-configuration-option-to-disable-chat-signatures.patch similarity index 92% rename from patches/server/0031-Add-configuration-option-to-disable-chat-signatures.patch rename to patches/server/0034-Add-configuration-option-to-disable-chat-signatures.patch index 474113d..cf1b8a7 100644 --- a/patches/server/0031-Add-configuration-option-to-disable-chat-signatures.patch +++ b/patches/server/0034-Add-configuration-option-to-disable-chat-signatures.patch @@ -60,18 +60,17 @@ index c0a80824a0307ea673805015119cc834b268f0dc..9f28f86b1b56ea55ab39f6ac988c1f47 } diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 001b7ae2067809d7da1d84d7637639f21a1aa980..ad87d90de1679955cb5a9d1c925be7d281cc64c9 100644 +index 51331ad3f295b55631adcb6f47e34d0b03bd148a..19f573a1f62280bd9b67a4027962fcb7de6d2514 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -1,5 +1,7 @@ +@@ -1,5 +1,6 @@ package net.minecraft.server.network; +import me.totalfreedom.scissors.ScissorsConfig; // Scissors -+import me.totalfreedom.scissors.event.player.SpectatorTeleportEvent; // Scissors + import me.totalfreedom.scissors.event.player.SpectatorTeleportEvent; // Scissors import com.google.common.collect.Lists; import com.google.common.primitives.Floats; - import com.mojang.authlib.GameProfile; -@@ -2219,7 +2221,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -2219,7 +2220,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl } private void handleMessageDecodeFailure(SignedMessageChain.DecodeException exception) { @@ -80,7 +79,7 @@ index 001b7ae2067809d7da1d84d7637639f21a1aa980..ad87d90de1679955cb5a9d1c925be7d2 this.disconnect(exception.getComponent(), exception.kickCause); // Paper - kick event causes } else { this.player.sendSystemMessage(exception.getComponent().copy().withStyle(ChatFormatting.RED)); -@@ -2275,6 +2277,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -2275,6 +2276,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl Optional optional = this.lastSeenMessages.applyUpdate(acknowledgment); if (optional.isEmpty()) { @@ -88,7 +87,7 @@ index 001b7ae2067809d7da1d84d7637639f21a1aa980..ad87d90de1679955cb5a9d1c925be7d2 ServerGamePacketListenerImpl.LOGGER.warn("Failed to validate message acknowledgements from {}", this.player.getName().getString()); this.disconnect(ServerGamePacketListenerImpl.CHAT_VALIDATION_FAILED, org.bukkit.event.player.PlayerKickEvent.Cause.CHAT_VALIDATION_FAILED); // Paper - kick event causes } -@@ -2483,6 +2486,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -2483,6 +2485,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl synchronized (this.lastSeenMessages) { if (!this.lastSeenMessages.applyOffset(packet.offset())) { @@ -96,7 +95,7 @@ index 001b7ae2067809d7da1d84d7637639f21a1aa980..ad87d90de1679955cb5a9d1c925be7d2 ServerGamePacketListenerImpl.LOGGER.warn("Failed to validate message acknowledgements from {}", this.player.getName().getString()); this.disconnect(ServerGamePacketListenerImpl.CHAT_VALIDATION_FAILED, org.bukkit.event.player.PlayerKickEvent.Cause.CHAT_VALIDATION_FAILED); // Paper - kick event causes } -@@ -3456,6 +3460,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -3455,6 +3458,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl @Override public void handleChatSessionUpdate(ServerboundChatSessionUpdatePacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); diff --git a/patches/removed/server/0033-Patch-large-selector-distance-crash.patch b/patches/server/0035-Patch-large-selector-distance-crash.patch similarity index 61% rename from patches/removed/server/0033-Patch-large-selector-distance-crash.patch rename to patches/server/0035-Patch-large-selector-distance-crash.patch index 98a7565..6dd8079 100644 --- a/patches/removed/server/0033-Patch-large-selector-distance-crash.patch +++ b/patches/server/0035-Patch-large-selector-distance-crash.patch @@ -1,37 +1,49 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Telesphoreo -Date: Mon, 25 Sep 2023 18:58:34 -0500 +From: Luna +Date: Sun, 2 Apr 2023 16:29:51 -0300 Subject: [PATCH] Patch large selector distance crash diff --git a/src/main/java/net/minecraft/advancements/critereon/MinMaxBounds.java b/src/main/java/net/minecraft/advancements/critereon/MinMaxBounds.java -index 8897496323378080135127f53db004d576476c21..a4de9cfcbe7d7d6b05feb3a6be683437e9b00c2b 100644 +index 8897496323378080135127f53db004d576476c21..5f957d3241c1931f8166bc9e4960cef15679e932 100644 --- a/src/main/java/net/minecraft/advancements/critereon/MinMaxBounds.java +++ b/src/main/java/net/minecraft/advancements/critereon/MinMaxBounds.java -@@ -131,7 +131,7 @@ public interface MinMaxBounds { +@@ -129,9 +129,9 @@ public interface MinMaxBounds { + + public static record Doubles(Optional min, Optional max, Optional minSq, Optional maxSq) implements MinMaxBounds { public static final MinMaxBounds.Doubles ANY = new MinMaxBounds.Doubles(Optional.empty(), Optional.empty()); - public static final Codec CODEC = MinMaxBounds.createCodec(Codec.DOUBLE, MinMaxBounds.Doubles::new); +- public static final Codec CODEC = MinMaxBounds.createCodec(Codec.DOUBLE, MinMaxBounds.Doubles::new); ++ public static final Codec CODEC = MinMaxBounds.createCodec(Codec.DOUBLE, MinMaxBounds.Doubles::new); // Scissors - compile fixes - private Doubles(Optional optional, Optional optional2) { + public Doubles(Optional optional, Optional optional2) { // Scissors - private -> public this(optional, optional2, squareOpt(optional), squareOpt(optional2)); } +@@ -202,7 +202,7 @@ public interface MinMaxBounds { + + public static record Ints(Optional min, Optional max, Optional minSq, Optional maxSq) implements MinMaxBounds { + public static final MinMaxBounds.Ints ANY = new MinMaxBounds.Ints(Optional.empty(), Optional.empty()); +- public static final Codec CODEC = MinMaxBounds.createCodec(Codec.INT, MinMaxBounds.Ints::new); ++ public static final Codec CODEC = MinMaxBounds.createCodec(Codec.INT, MinMaxBounds.Ints::new); // Scissors - compile fixes + + private Ints(Optional optional, Optional optional2) { + this(optional, optional2, optional.map((integer) -> { diff --git a/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java b/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java -index 73c15a0c56a103ba4e62f0a51af8d42566b07245..0ea61a4c58bd6d126aff9872ba9c4dc27fb7c099 100644 +index 73c15a0c56a103ba4e62f0a51af8d42566b07245..6cb3e86f2d661a55536b782729f768ef72163223 100644 --- a/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java +++ b/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java @@ -5,11 +5,13 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; import java.util.Collections; import java.util.Iterator; import java.util.List; -+import java.util.Optional; ++import java.util.Optional; // Scissors import java.util.UUID; import java.util.function.BiConsumer; import java.util.function.Function; import java.util.function.Predicate; import javax.annotation.Nullable; -+import me.totalfreedom.scissors.MathUtility; ++import me.totalfreedom.scissors.MathUtility; // Scissors import net.minecraft.advancements.critereon.MinMaxBounds; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.arguments.EntityArgument; @@ -42,8 +54,8 @@ index 73c15a0c56a103ba4e62f0a51af8d42566b07245..0ea61a4c58bd6d126aff9872ba9c4dc2 - this.range = distance; + // Scissors start - Patch large selector distance crash + this.range = new MinMaxBounds.Doubles( -+ Optional.of(distance.min().get() != null ? Math.min(distance.min().get(), 1024) : null), -+ Optional.of(distance.max().get() != null ? Math.min(distance.max().get(), 1024) : null) ++ distance.min().map(min -> Math.min(min, 1024)), ++ distance.max().map(max -> Math.min(max, 1024)) + ); this.position = positionOffset; - this.aabb = box; diff --git a/patches/server/0032-Patch-invalid-entity-rotation-log-spam.patch b/patches/server/0036-Patch-invalid-entity-rotation-log-spam.patch similarity index 100% rename from patches/server/0032-Patch-invalid-entity-rotation-log-spam.patch rename to patches/server/0036-Patch-invalid-entity-rotation-log-spam.patch diff --git a/patches/server/0033-Limit-sculk-catalyst-cursor-positions.patch b/patches/server/0037-Limit-sculk-catalyst-cursor-positions.patch similarity index 100% rename from patches/server/0033-Limit-sculk-catalyst-cursor-positions.patch rename to patches/server/0037-Limit-sculk-catalyst-cursor-positions.patch diff --git a/patches/server/0038-Limit-map-decorations.patch b/patches/server/0038-Limit-map-decorations.patch new file mode 100644 index 0000000..310eaa6 --- /dev/null +++ b/patches/server/0038-Limit-map-decorations.patch @@ -0,0 +1,36 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Luna +Date: Fri, 28 Apr 2023 16:29:23 -0300 +Subject: [PATCH] Limit map decorations + + +diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundMapItemDataPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundMapItemDataPacket.java +index 81f3e64d94fa17e45411e5c1641d9c5a2fe3d2e2..bcf6e2ce9f00d1688a5fa00ec055a57389346922 100644 +--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundMapItemDataPacket.java ++++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundMapItemDataPacket.java +@@ -65,7 +65,8 @@ public class ClientboundMapItemDataPacket implements Packet 32) { ++ return; ++ } ++ // Scissors end + int i = 1 << this.scale; + float f = (float) (x - (double) this.centerX) / (float) i; + float f1 = (float) (z - (double) this.centerZ) / (float) i; diff --git a/patches/server/0039-Limit-map-decorations.patch b/patches/server/0039-Limit-map-decorations.patch deleted file mode 100644 index 5931341..0000000 --- a/patches/server/0039-Limit-map-decorations.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Telesphoreo -Date: Sat, 30 Sep 2023 18:41:40 -0500 -Subject: [PATCH] Limit map decorations - - -diff --git a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java -index e4c4948e076cd64686dfd16ae0568fafc1437140..eff53c21b18574750b691b784fb1688885d4ace7 100644 ---- a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java -+++ b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java -@@ -361,6 +361,11 @@ public class MapItemSavedData extends SavedData { - } - - private void addDecoration(MapDecoration.Type type, @Nullable LevelAccessor world, String key, double x, double z, double rotation, @Nullable Component text) { -+ // Scissors start - Limit decoration count -+ if (this.decorations.size() > 32) { -+ return; -+ } -+ // Scissors end - int i = 1 << this.scale; - float f = (float) (x - (double) this.centerX) / (float) i; - float f1 = (float) (z - (double) this.centerZ) / (float) i; -diff --git a/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java b/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java -index 2d2bf5c37709b8e747fbfa2db5ce86f258e86224..eeffb546dfa6a094089d322e46e44a8a69238680 100644 ---- a/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java -+++ b/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java -@@ -1,5 +1,6 @@ - package org.bukkit.craftbukkit.map; - -+import net.minecraft.network.chat.Component; - import net.minecraft.world.level.saveddata.maps.MapDecoration; - import net.minecraft.world.level.saveddata.maps.MapItemSavedData; - import org.bukkit.Bukkit; -@@ -42,7 +43,13 @@ public class CraftMapRenderer extends MapRenderer { - } - - MapDecoration decoration = worldMap.decorations.get(key); -- cursors.addCursor(decoration.x(), decoration.y(), (byte) (decoration.rot() & 15), decoration.type().getIcon(), true, decoration.name() == null ? null : io.papermc.paper.adventure.PaperAdventure.asAdventure(decoration.name())); // Paper -+ // Scissors start - Limit decoration text length -+ Component name = decoration.name(); -+ if (decoration.name() != null && decoration.name().getString().length() > 32) { -+ name = null; -+ } -+ cursors.addCursor(decoration.x(), decoration.y(), (byte) (decoration.rot() & 15), decoration.type().getIcon(), true, name == null ? null : io.papermc.paper.adventure.PaperAdventure.asAdventure(decoration.name())); // Paper -+ // Scissors end - } - } - diff --git a/patches/server/0034-Prevent-player-banning-using-duplicate-UUIDs.patch b/patches/server/0039-Prevent-player-banning-using-duplicate-UUIDs.patch similarity index 100% rename from patches/server/0034-Prevent-player-banning-using-duplicate-UUIDs.patch rename to patches/server/0039-Prevent-player-banning-using-duplicate-UUIDs.patch diff --git a/patches/server/0035-Don-t-warn-on-duplicate-entity-UUIDs.patch b/patches/server/0040-Don-t-warn-on-duplicate-entity-UUIDs.patch similarity index 100% rename from patches/server/0035-Don-t-warn-on-duplicate-entity-UUIDs.patch rename to patches/server/0040-Don-t-warn-on-duplicate-entity-UUIDs.patch diff --git a/patches/server/0036-Fix-component-extra-empty-array-exploit.patch b/patches/server/0041-Fix-component-extra-empty-array-exploit.patch similarity index 100% rename from patches/server/0036-Fix-component-extra-empty-array-exploit.patch rename to patches/server/0041-Fix-component-extra-empty-array-exploit.patch diff --git a/patches/server/0037-Add-depth-limit-to-Component-deserializer.patch b/patches/server/0042-Add-depth-limit-to-Component-deserializer.patch similarity index 100% rename from patches/server/0037-Add-depth-limit-to-Component-deserializer.patch rename to patches/server/0042-Add-depth-limit-to-Component-deserializer.patch diff --git a/patches/server/0038-Implement-command-block-events.patch b/patches/server/0043-Implement-command-block-events.patch similarity index 92% rename from patches/server/0038-Implement-command-block-events.patch rename to patches/server/0043-Implement-command-block-events.patch index 51e013d..4c96b62 100644 --- a/patches/server/0038-Implement-command-block-events.patch +++ b/patches/server/0043-Implement-command-block-events.patch @@ -18,7 +18,7 @@ index c99fc118013cb3d4043638e2001a8297e79ddf9c..cdaa81e1f2167b29ec01cc25e51a8400 private final boolean trackOutput; diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index ad87d90de1679955cb5a9d1c925be7d281cc64c9..b4213a2f0f8c57b606b1a1a993d352bda200bd63 100644 +index 19f573a1f62280bd9b67a4027962fcb7de6d2514..f5cdac55c8cbe334b96c5a0b2c34f216109120d3 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -1,6 +1,8 @@ @@ -30,7 +30,7 @@ index ad87d90de1679955cb5a9d1c925be7d281cc64c9..b4213a2f0f8c57b606b1a1a993d352bd import me.totalfreedom.scissors.event.player.SpectatorTeleportEvent; // Scissors import com.google.common.collect.Lists; import com.google.common.primitives.Floats; -@@ -155,6 +157,7 @@ import net.minecraft.world.entity.player.Inventory; +@@ -154,6 +156,7 @@ import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.ProfilePublicKey; import net.minecraft.world.entity.projectile.AbstractArrow; import net.minecraft.world.entity.vehicle.Boat; @@ -38,7 +38,7 @@ index ad87d90de1679955cb5a9d1c925be7d281cc64c9..b4213a2f0f8c57b606b1a1a993d352bd import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.BucketItem; import net.minecraft.world.item.Item; -@@ -182,6 +185,8 @@ import net.minecraft.world.phys.Vec3; +@@ -181,6 +184,8 @@ import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.BooleanOp; import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; @@ -47,7 +47,7 @@ index ad87d90de1679955cb5a9d1c925be7d281cc64c9..b4213a2f0f8c57b606b1a1a993d352bd import org.slf4j.Logger; // CraftBukkit start -@@ -893,6 +898,16 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -892,6 +897,16 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl this.player.level().getChunkAt(blockposition).setBlockEntity(tileentity); } @@ -64,7 +64,7 @@ index ad87d90de1679955cb5a9d1c925be7d281cc64c9..b4213a2f0f8c57b606b1a1a993d352bd commandblocklistenerabstract.setCommand(s); commandblocklistenerabstract.setTrackOutput(flag); if (!flag) { -@@ -924,7 +939,18 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -923,7 +938,18 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl BaseCommandBlock commandblocklistenerabstract = packet.getCommandBlock(this.player.level()); if (commandblocklistenerabstract != null) { diff --git a/patches/server/0040-Add-depth-limit-to-SNBT.patch b/patches/server/0044-Add-depth-limit-to-SNBT.patch similarity index 100% rename from patches/server/0040-Add-depth-limit-to-SNBT.patch rename to patches/server/0044-Add-depth-limit-to-SNBT.patch diff --git a/patches/server/0042-Limit-beacon-effectRange.patch b/patches/server/0045-Limit-beacon-effectRange.patch similarity index 100% rename from patches/server/0042-Limit-beacon-effectRange.patch rename to patches/server/0045-Limit-beacon-effectRange.patch diff --git a/patches/server/0041-Improve-validation-of-ResourceLocations.patch b/patches/server/0046-Improve-validation-of-ResourceLocations.patch similarity index 100% rename from patches/server/0041-Improve-validation-of-ResourceLocations.patch rename to patches/server/0046-Improve-validation-of-ResourceLocations.patch diff --git a/patches/server/0043-Don-t-log-on-too-many-chained-updates.patch b/patches/server/0047-Don-t-log-on-too-many-chained-updates.patch similarity index 100% rename from patches/server/0043-Don-t-log-on-too-many-chained-updates.patch rename to patches/server/0047-Don-t-log-on-too-many-chained-updates.patch diff --git a/patches/server/0044-Fix-packet-related-lag-exploits.patch b/patches/server/0048-Fix-packet-related-lag-exploits.patch similarity index 89% rename from patches/server/0044-Fix-packet-related-lag-exploits.patch rename to patches/server/0048-Fix-packet-related-lag-exploits.patch index 713a38a..80be59d 100644 --- a/patches/server/0044-Fix-packet-related-lag-exploits.patch +++ b/patches/server/0048-Fix-packet-related-lag-exploits.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Fix packet-related lag exploits diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 4d225bb5126c083e0bf7f98992cd6d63c2dd44e9..73f6423b96ffa392e390df269f94c4012333a3e4 100644 +index f5cdac55c8cbe334b96c5a0b2c34f216109120d3..78f9e0587f35ed8034fd2c275e0e06abae90e0e6 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -858,7 +858,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -857,7 +857,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl this.player.sendSystemMessage(Component.translatable("advMode.notEnabled")); } else if (!this.player.canUseGameMasterBlocks() && (!this.player.isCreative() || !this.player.getBukkitEntity().hasPermission("minecraft.commandblock"))) { // Paper - command block permission this.player.sendSystemMessage(Component.translatable("advMode.notAllowed")); @@ -17,7 +17,7 @@ index 4d225bb5126c083e0bf7f98992cd6d63c2dd44e9..73f6423b96ffa392e390df269f94c401 BaseCommandBlock commandblocklistenerabstract = null; CommandBlockEntity tileentitycommand = null; BlockPos blockposition = packet.getPos(); -@@ -1025,7 +1025,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -1024,7 +1024,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl @Override public void handleSetStructureBlock(ServerboundSetStructureBlockPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); @@ -26,7 +26,7 @@ index 4d225bb5126c083e0bf7f98992cd6d63c2dd44e9..73f6423b96ffa392e390df269f94c401 BlockPos blockposition = packet.getPos(); BlockState iblockdata = this.player.level().getBlockState(blockposition); BlockEntity tileentity = this.player.level().getBlockEntity(blockposition); -@@ -1083,7 +1083,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -1082,7 +1082,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl @Override public void handleSetJigsawBlock(ServerboundSetJigsawBlockPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); @@ -35,7 +35,7 @@ index 4d225bb5126c083e0bf7f98992cd6d63c2dd44e9..73f6423b96ffa392e390df269f94c401 BlockPos blockposition = packet.getPos(); BlockState iblockdata = this.player.level().getBlockState(blockposition); BlockEntity tileentity = this.player.level().getBlockEntity(blockposition); -@@ -1106,7 +1106,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -1105,7 +1105,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl @Override public void handleJigsawGenerate(ServerboundJigsawGeneratePacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); diff --git a/patches/server/0045-Limit-save-data-for-Bees-and-Vexes.patch b/patches/server/0049-Limit-save-data-for-Bees-and-Vexes.patch similarity index 96% rename from patches/server/0045-Limit-save-data-for-Bees-and-Vexes.patch rename to patches/server/0049-Limit-save-data-for-Bees-and-Vexes.patch index 2ffec9d..a3d10c6 100644 --- a/patches/server/0045-Limit-save-data-for-Bees-and-Vexes.patch +++ b/patches/server/0049-Limit-save-data-for-Bees-and-Vexes.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Limit save data for Bees and Vexes diff --git a/src/main/java/net/minecraft/world/entity/animal/Bee.java b/src/main/java/net/minecraft/world/entity/animal/Bee.java -index 55026e1731e41b4e3e4c6a8fef5d96a32051a556..4a8383d48da4fcf39ec528a00cd09417f8d08c57 100644 +index 9a7956befc346e1b58f064213800fd099a052fc6..2ebedd806bafc6ff7c4bf5a962ead50ce2ad1a8a 100644 --- a/src/main/java/net/minecraft/world/entity/animal/Bee.java +++ b/src/main/java/net/minecraft/world/entity/animal/Bee.java @@ -227,8 +227,12 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal { diff --git a/patches/server/0046-Mute-invalid-attributes.patch b/patches/server/0050-Mute-invalid-attributes.patch similarity index 100% rename from patches/server/0046-Mute-invalid-attributes.patch rename to patches/server/0050-Mute-invalid-attributes.patch diff --git a/patches/server/0047-Mute-invalid-Enderdragon-phases.patch b/patches/server/0051-Mute-invalid-Enderdragon-phases.patch similarity index 100% rename from patches/server/0047-Mute-invalid-Enderdragon-phases.patch rename to patches/server/0051-Mute-invalid-Enderdragon-phases.patch diff --git a/patches/removed/server/0053-Don-t-return-null-Components-in-the-Component-codec.patch b/patches/server/0052-Don-t-return-null-Components-in-the-Component-codec.patch similarity index 63% rename from patches/removed/server/0053-Don-t-return-null-Components-in-the-Component-codec.patch rename to patches/server/0052-Don-t-return-null-Components-in-the-Component-codec.patch index 31e2c5a..52f7bb2 100644 --- a/patches/removed/server/0053-Don-t-return-null-Components-in-the-Component-codec.patch +++ b/patches/server/0052-Don-t-return-null-Components-in-the-Component-codec.patch @@ -6,23 +6,11 @@ Subject: [PATCH] Don't return null Components in the Component codec Found by Sk8kman diff --git a/src/main/java/net/minecraft/util/ExtraCodecs.java b/src/main/java/net/minecraft/util/ExtraCodecs.java -index 066d423dc908080157586555ba01053a2477d570..aa6e5de37ce69c9bc6b8e1e0b5ab0ee918fc27e2 100644 +index 607f32b856c6c1fb81d3f1604f3bf3fb240d713f..5afdc9d93e696568cc8a263ab0142fbac258e874 100644 --- a/src/main/java/net/minecraft/util/ExtraCodecs.java +++ b/src/main/java/net/minecraft/util/ExtraCodecs.java -@@ -62,7 +62,10 @@ public class ExtraCodecs { - }); - public static final Codec COMPONENT = JSON.flatXmap((element) -> { - try { -- return DataResult.success(Component.Serializer.fromJson(element)); -+ // Scissors start -+ final Component component = Component.Serializer.fromJson(element); -+ return DataResult.success(component != null ? component : Component.empty()); -+ // Scissors end - } catch (JsonParseException var2) { - return DataResult.error(var2::getMessage); - } -@@ -75,7 +78,10 @@ public class ExtraCodecs { - }); +@@ -70,7 +70,10 @@ public class ExtraCodecs { + public static final Codec COMPONENT = adaptJsonSerializer(Component.Serializer::fromJson, Component.Serializer::toJsonTree); public static final Codec FLAT_COMPONENT = Codec.STRING.flatXmap((json) -> { try { - return DataResult.success(Component.Serializer.fromJson(json)); @@ -33,7 +21,19 @@ index 066d423dc908080157586555ba01053a2477d570..aa6e5de37ce69c9bc6b8e1e0b5ab0ee9 } catch (JsonParseException var2) { return DataResult.error(var2::getMessage); } -@@ -246,7 +252,7 @@ public class ExtraCodecs { +@@ -233,7 +236,10 @@ public class ExtraCodecs { + public static Codec adaptJsonSerializer(Function deserializer, Function serializer) { + return JSON.flatXmap((json) -> { + try { +- return DataResult.success(deserializer.apply(json)); ++ // Scissors start ++ final T value = deserializer.apply(json); ++ return DataResult.success(value != null ? value : (T)Component.empty()); ++ // Scissors end + } catch (JsonParseException var3) { + return DataResult.error(var3::getMessage); + } +@@ -260,7 +266,7 @@ public class ExtraCodecs { }, (pair) -> { return ImmutableList.of(leftFunction.apply(pair), rightFunction.apply(pair)); }); @@ -42,7 +42,7 @@ index 066d423dc908080157586555ba01053a2477d570..aa6e5de37ce69c9bc6b8e1e0b5ab0ee9 return instance.group(codec.fieldOf(leftFieldName).forGetter(Pair::getFirst), codec.fieldOf(rightFieldName).forGetter(Pair::getSecond)).apply(instance, Pair::of); }).comapFlatMap((pair) -> { return combineFunction.apply((P)pair.getFirst(), (P)pair.getSecond()); -@@ -278,7 +284,7 @@ public class ExtraCodecs { +@@ -286,7 +292,7 @@ public class ExtraCodecs { Optional> optional = dataResult.resultOrPartial(mutableObject::setValue); return optional.isPresent() ? dataResult : DataResult.error(() -> { return "(" + (String)mutableObject.getValue() + " -> using default)"; @@ -51,12 +51,3 @@ index 066d423dc908080157586555ba01053a2477d570..aa6e5de37ce69c9bc6b8e1e0b5ab0ee9 } public DataResult coApply(DynamicOps dynamicOps, A objectx, DataResult dataResult) { -@@ -565,7 +571,7 @@ public class ExtraCodecs { - - static record LazyInitializedCodec(Supplier> delegate) implements Codec { - LazyInitializedCodec { -- supplier = Suppliers.memoize(supplier::get); -+ delegate = Suppliers.memoize(delegate::get); // Scissors - Decompile error - } - - public DataResult> decode(DynamicOps dynamicOps, T object) { diff --git a/patches/server/0048-Add-length-limit-to-note-block-sound.patch b/patches/server/0053-Add-length-limit-to-note-block-sound.patch similarity index 100% rename from patches/server/0048-Add-length-limit-to-note-block-sound.patch rename to patches/server/0053-Add-length-limit-to-note-block-sound.patch