From c401e92012cf141c5fe61cf2d9dd3d55b3a0ce7f Mon Sep 17 00:00:00 2001 From: Telesphoreo Date: Sun, 7 Jan 2024 14:19:55 -0600 Subject: [PATCH] Update Paper --- gradle.properties | 2 +- patches/server/0002-UUID-validation.patch | 17 ----------- .../0003-ResourceLocation-validation.patch | 28 ++----------------- ...Removes-useless-spammy-error-logging.patch | 4 +-- ...ate-BlockState-and-SoundEvent-values.patch | 23 ++++----------- ...-handling-of-invalid-JSON-components.patch | 4 +-- ...tch-invalid-entity-rotation-log-spam.patch | 4 +-- 7 files changed, 15 insertions(+), 67 deletions(-) diff --git a/gradle.properties b/gradle.properties index a77c774..b56cde1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ group=me.totalfreedom.scissors version=1.20.4-R0.1-SNAPSHOT mcVersion=1.20.4 -paperRef=1fa48d140c5469d894b436a7ba0cb5cb6f819ee0 +paperRef=07b956e3a30d9cd192111829b59bdf4372f128b1 org.gradle.caching=true org.gradle.parallel=true diff --git a/patches/server/0002-UUID-validation.patch b/patches/server/0002-UUID-validation.patch index 6b7d031..58db905 100644 --- a/patches/server/0002-UUID-validation.patch +++ b/patches/server/0002-UUID-validation.patch @@ -4,23 +4,6 @@ Date: Sun, 10 Dec 2023 13:11:22 -0600 Subject: [PATCH] UUID validation -diff --git a/src/main/java/net/minecraft/nbt/NbtUtils.java b/src/main/java/net/minecraft/nbt/NbtUtils.java -index b65dcff9812dbc3256c080ac264c4aafd83ce276..82b53a7bfb37bfa1752a016a8a454c0b994b9108 100644 ---- a/src/main/java/net/minecraft/nbt/NbtUtils.java -+++ b/src/main/java/net/minecraft/nbt/NbtUtils.java -@@ -74,7 +74,11 @@ public final class NbtUtils { - UUID uUID = nbt.hasUUID("Id") ? nbt.getUUID("Id") : Util.NIL_UUID; - // Paper start - support string UUID's - if (nbt.contains("Id", Tag.TAG_STRING)) { -- uUID = UUID.fromString(nbt.getString("Id")); -+ // Scissors start - Validate String UUIDs in game profiles -+ try { -+ uUID = UUID.fromString(nbt.getString("Id")); -+ } catch (Exception ignored) {} -+ // Scissors end - } - // Paper end - String string = nbt.getString("Name"); diff --git a/src/main/java/net/minecraft/network/chat/HoverEvent.java b/src/main/java/net/minecraft/network/chat/HoverEvent.java index 7fd85ae2ebd7225f06d874aa7e37fbdb89e3ea92..b2cc15da40aa7bbcfc234b4e147ed0e53f359efa 100644 --- a/src/main/java/net/minecraft/network/chat/HoverEvent.java diff --git a/patches/server/0003-ResourceLocation-validation.patch b/patches/server/0003-ResourceLocation-validation.patch index bed355f..e9ba273 100644 --- a/patches/server/0003-ResourceLocation-validation.patch +++ b/patches/server/0003-ResourceLocation-validation.patch @@ -44,11 +44,11 @@ index 1f55185814125c691288294d18bf1580461c8066..259d65f8e21f9cf99585d416eafdc967 } diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java -index 940b8d0b89d7e55c938aefbe80ee71b0db3dacb8..297a214a7833fd67640c94352671483bc4fc8dd5 100644 +index 6cfce9755dd464a7afb01f9032e567ce3bcd5bc5..264c94f49035236e3584a3577f2516f0f430a552 100644 --- a/src/main/java/net/minecraft/world/entity/EntityType.java +++ b/src/main/java/net/minecraft/world/entity/EntityType.java -@@ -593,7 +593,7 @@ public class EntityType implements FeatureElement, EntityTypeT - }), (entity) -> { +@@ -599,7 +599,7 @@ public class EntityType implements FeatureElement, EntityTypeT + if (generation) entity.generation = true; // Paper - add generation bool param entity.load(nbt); }, () -> { - EntityType.LOGGER.warn("Skipping Entity with id {}", nbt.getString("id")); @@ -56,28 +56,6 @@ index 940b8d0b89d7e55c938aefbe80ee71b0db3dacb8..297a214a7833fd67640c94352671483b }); } -@@ -612,7 +612,7 @@ public class EntityType implements FeatureElement, EntityTypeT - } - - public static Optional> by(CompoundTag nbt) { -- return BuiltInRegistries.ENTITY_TYPE.getOptional(new ResourceLocation(nbt.getString("id"))); -+ return BuiltInRegistries.ENTITY_TYPE.getOptional(ResourceLocation.tryParse(nbt.getString("id"))); // Scissors - } - - @Nullable -diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java -index 5af48151159135b869ec4753bbcf79dd257c1570..6c4425c08ea4a4444bac50fe5cf587870d9576a5 100644 ---- a/src/main/java/net/minecraft/world/entity/Mob.java -+++ b/src/main/java/net/minecraft/world/entity/Mob.java -@@ -620,7 +620,7 @@ public abstract class Mob extends LivingEntity implements Targeting { - - 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 - this.lootTableSeed = nbt.getLong("DeathLootTableSeed"); - } - diff --git a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java index a18aadbf7ae83713e1f2b21553185d8000bc7699..f5ad7ddf13cbb6452c2927aef9b54eae3335b4c6 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java diff --git a/patches/server/0005-Removes-useless-spammy-error-logging.patch b/patches/server/0005-Removes-useless-spammy-error-logging.patch index 40bab92..4f2da2b 100644 --- a/patches/server/0005-Removes-useless-spammy-error-logging.patch +++ b/patches/server/0005-Removes-useless-spammy-error-logging.patch @@ -5,10 +5,10 @@ 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 182bc05a839781794188352120968fdf67e794e7..98118cadae93000192003b40e9051a6df216d197 100644 +index 91bbea5cb169f96910cc8661151c04dbff057091..84c9f2b09576046c138a11a835c9192a6e347c1d 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java -@@ -1812,8 +1812,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { +@@ -1805,8 +1805,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { resource = CraftNamespacedKey.fromMinecraft(key); } } catch (IllegalArgumentException ex) { diff --git a/patches/server/0009-Validate-BlockState-and-SoundEvent-values.patch b/patches/server/0009-Validate-BlockState-and-SoundEvent-values.patch index c8fc971..f2e62be 100644 --- a/patches/server/0009-Validate-BlockState-and-SoundEvent-values.patch +++ b/patches/server/0009-Validate-BlockState-and-SoundEvent-values.patch @@ -5,28 +5,15 @@ 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 82b53a7bfb37bfa1752a016a8a454c0b994b9108..b8720020f98ea26da7d3225ddfbb1d9e80be4eb1 100644 +index 80083fed4b44b9d433925f09db83e559582109a1..032fc2add6c25780a3663fd1d2e429fcfd37dc4a 100644 --- a/src/main/java/net/minecraft/nbt/NbtUtils.java +++ b/src/main/java/net/minecraft/nbt/NbtUtils.java @@ -231,7 +231,7 @@ public final class NbtUtils { - if (!nbt.contains("Name", 8)) { return Blocks.AIR.defaultBlockState(); } else { -- ResourceLocation resourceLocation = new ResourceLocation(nbt.getString("Name")); + // Paper start - Validate resource location +- ResourceLocation resourceLocation = ResourceLocation.tryParse(nbt.getString("Name")); + ResourceLocation resourceLocation = ResourceLocation.tryParse(nbt.getString("Name")); // Scissors - Validate BlockState - Optional> optional = blockLookup.get(ResourceKey.create(Registries.BLOCK, resourceLocation)); + Optional> optional = resourceLocation != null ? blockLookup.get(ResourceKey.create(Registries.BLOCK, resourceLocation)) : Optional.empty(); + // Paper end if (optional.isEmpty()) { - return Blocks.AIR.defaultBlockState(); -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 42ebd91196ae420eee57f4380abc558555457163..8e81f50b52bc1d3eb25a842d1c41a7a18f53bf27 100644 ---- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java -+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java -@@ -560,7 +560,7 @@ public abstract class AbstractArrow extends Projectile { - this.setCritArrow(nbt.getBoolean("crit")); - this.setPierceLevel(nbt.getByte("PierceLevel")); - if (nbt.contains("SoundEvent", 8)) { -- this.soundEvent = (SoundEvent) BuiltInRegistries.SOUND_EVENT.getOptional(new ResourceLocation(nbt.getString("SoundEvent"))).orElse(this.getDefaultHitGroundSoundEvent()); -+ this.soundEvent = (SoundEvent) BuiltInRegistries.SOUND_EVENT.getOptional(ResourceLocation.tryParse(nbt.getString("SoundEvent"))).orElse(this.getDefaultHitGroundSoundEvent()); // Scissors - Validate SoundEvents before trying to play them - } - - this.setShotFromCrossbow(nbt.getBoolean("ShotFromCrossbow")); 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 0b7c484..4b8430e 100644 --- a/patches/server/0012-Better-handling-of-invalid-JSON-components.patch +++ b/patches/server/0012-Better-handling-of-invalid-JSON-components.patch @@ -93,10 +93,10 @@ index 186547674894fd084bceb478bb6017b747df4173..74c880425964da042ca57c097eb93273 } }).reduce((accumulator, current) -> { diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 0c46a4aeafd03fbbfd590b0362d41bf2b1d5ca74..a8ae232f9ef204e6dd2f14c1e92008ceb7af7ab2 100644 +index 1be10c57e374ad4018c08d96cfb69397a2f541d3..2e11d0f17fc8fa4ed84c40dd9747e136675030a4 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -2522,11 +2522,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -2526,11 +2526,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S if (nbt.contains("CustomName", 8)) { String s = nbt.getString("CustomName"); diff --git a/patches/server/0036-Patch-invalid-entity-rotation-log-spam.patch b/patches/server/0036-Patch-invalid-entity-rotation-log-spam.patch index 72fa154..e5fb78c 100644 --- a/patches/server/0036-Patch-invalid-entity-rotation-log-spam.patch +++ b/patches/server/0036-Patch-invalid-entity-rotation-log-spam.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Patch invalid entity rotation log spam diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index a8ae232f9ef204e6dd2f14c1e92008ceb7af7ab2..4f032b8303c6c1dc3c829c3c09009aaa0a5209fa 100644 +index 2e11d0f17fc8fa4ed84c40dd9747e136675030a4..acd0dcf69a23ec6dda8e58621b8634076ba8eec1 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -4734,7 +4734,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -4745,7 +4745,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S public void setXRot(float pitch) { if (!Float.isFinite(pitch)) {