Scissors/patches/server/0013-Even-more-resource-location-validation.patch

55 lines
2.8 KiB
Diff
Raw Normal View History

2022-07-28 03:57:50 +00:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Telesphoreo <me@telesphoreo.me>
Date: Sat, 10 Dec 2022 23:02:48 -0600
2022-07-28 03:57:50 +00:00
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 c4810371c00eb92dc8574841c74a89203d586c78..929f05c8692223959282f68bf68c4467e4167a80 100644
2022-07-28 03:57:50 +00:00
--- a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
+++ b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
@@ -145,7 +145,7 @@ public class AreaEffectCloud extends Entity {
2022-07-28 03:57:50 +00:00
}
public void setPotionType(String string) {
- this.setPotion(BuiltInRegistries.POTION.get(new ResourceLocation(string)));
+ this.setPotion(BuiltInRegistries.POTION.get(ResourceLocation.tryParse(string))); // Scissors - Validate resource locations
2022-07-28 03:57:50 +00:00
}
// CraftBukkit end
diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java
2023-01-02 01:37:43 +00:00
index 4589f7db68f7a72065c85c0a50216c6d02658f1e..5c23608e20e243eb844c73f713c39bf3e5ab05dd 100644
2022-07-28 03:57:50 +00:00
--- a/src/main/java/net/minecraft/world/entity/EntityType.java
+++ b/src/main/java/net/minecraft/world/entity/EntityType.java
2023-01-02 01:37:43 +00:00
@@ -580,7 +580,7 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT
2022-07-28 03:57:50 +00:00
}), (entity) -> {
entity.load(nbt);
}, () -> {
- EntityType.LOGGER.warn("Skipping Entity with id {}", nbt.getString("id"));
+ /*EntityType.LOGGER.warn("Skipping Entity with id {}", nbt.getString("id"));*/ // Scissors - Don't log invalid entities
2022-07-28 03:57:50 +00:00
});
}
2023-01-02 01:37:43 +00:00
@@ -599,7 +599,7 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT
2022-07-28 03:57:50 +00:00
}
public static Optional<EntityType<?>> by(CompoundTag nbt) {
- return BuiltInRegistries.ENTITY_TYPE.getOptional(new ResourceLocation(nbt.getString("id")));
+ return BuiltInRegistries.ENTITY_TYPE.getOptional(ResourceLocation.tryParse(nbt.getString("id")));
2022-07-28 03:57:50 +00:00
}
@Nullable
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
index 49b983064ea810382b6112f5dc7f93ba4e5710bd..4dd32f38ebf06d868a37c8e4ae667ac14a774b8d 100644
2022-07-28 03:57:50 +00:00
--- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
2022-09-13 06:41:21 +00:00
@@ -585,7 +585,7 @@ public abstract class Mob extends LivingEntity {
2022-07-28 03:57:50 +00:00
this.setLeftHanded(nbt.getBoolean("LeftHanded"));
if (nbt.contains("DeathLootTable", 8)) {
- this.lootTable = new ResourceLocation(nbt.getString("DeathLootTable"));
+ this.lootTable = ResourceLocation.tryParse(nbt.getString("DeathLootTable"));
2022-07-28 03:57:50 +00:00
this.lootTableSeed = nbt.getLong("DeathLootTableSeed");
}