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

55 lines
2.8 KiB
Diff
Raw Normal View History

2022-03-14 06:52:57 +00:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Video <videogamesm12@gmail.com>
Date: Mon, 14 Mar 2022 00:49:35 -0600
Subject: [PATCH] Even more resource location validation
diff --git a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
index 4733f74ff028c03a60b73280caf9e4d1e2f0ca30..02172fdcf587904258387d309938fb379a300524 100644
--- a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
+++ b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
@@ -143,7 +143,7 @@ public class AreaEffectCloud extends Entity {
}
public void setType(String string) {
- this.setPotion(Registry.POTION.get(new ResourceLocation(string)));
+ this.setPotion(Registry.POTION.get(ResourceLocation.tryParse(string))); // Scissors - Validate resource locations
}
// CraftBukkit end
diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java
index 1c446dba5de89698397041ee38a2e1a00bec8a56..93799eda06c7b699580251f80b641c47643f3615 100644
--- a/src/main/java/net/minecraft/world/entity/EntityType.java
+++ b/src/main/java/net/minecraft/world/entity/EntityType.java
@@ -513,7 +513,7 @@ public class EntityType<T extends Entity> implements EntityTypeTest<Entity, T> {
}), (entity) -> {
entity.load(nbt);
}, () -> {
- EntityType.LOGGER.warn("Skipping Entity with id {}", nbt.getString("id"));
+ // Scissors - Don't log invalid entities
});
}
@@ -537,7 +537,7 @@ public class EntityType<T extends Entity> implements EntityTypeTest<Entity, T> {
}
public static Optional<EntityType<?>> by(CompoundTag nbt) {
- return Registry.ENTITY_TYPE.getOptional(new ResourceLocation(nbt.getString("id")));
+ return Registry.ENTITY_TYPE.getOptional(ResourceLocation.tryParse(nbt.getString("id"))); // Scissors - Validate resource locations
}
@Nullable
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
index 8837fc04a67a656d0e780965ac113d3b28e2369f..11427668a0af28cf638df3574357f696f49af13d 100644
--- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
@@ -570,7 +570,7 @@ public abstract class Mob extends LivingEntity {
this.setLeftHanded(nbt.getBoolean("LeftHanded"));
if (nbt.contains("DeathLootTable", 8)) {
- this.lootTable = new ResourceLocation(nbt.getString("DeathLootTable"));
+ this.lootTable = ResourceLocation.tryParse(nbt.getString("DeathLootTable")); // Scissors - Validate resource locations
this.lootTableSeed = nbt.getLong("DeathLootTableSeed");
}