Scissors/patches/server/0012-Even-more-ResourceLocation-validation-and-log-spam-f.patch

87 lines
4.2 KiB
Diff
Raw Normal View History

2022-07-28 03:57:50 +00:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Video <videogamesm12@gmail.com>
Date: Mon, 9 May 2022 23:40:59 -0500
Subject: [PATCH] Even more ResourceLocation validation and log spam fixes
diff --git a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
index 7e1885d9cc568a544e934cede32bff05c20b567a..2481c50d8eb58a003e30e2d957b877bce5123a3a 100644
--- a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
+++ b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
@@ -420,7 +420,7 @@ public class AreaEffectCloud extends Entity {
try {
this.setParticle(ParticleArgument.readParticle(new StringReader(nbt.getString("Particle"))));
} catch (CommandSyntaxException commandsyntaxexception) {
- AreaEffectCloud.LOGGER.warn("Couldn't load custom particle {}", nbt.getString("Particle"), commandsyntaxexception);
+ // Scissors - Don't log custom particle errors
}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java b/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java
index e49eece9bff3a53469673d03a7bbf8f9cf8776b8..a49f32e9649155b6af4b1f236e4e8142d730e7e8 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java
@@ -30,8 +30,14 @@ public abstract class CraftLootable<T extends RandomizableContainerBlockEntity>
return null;
}
- ResourceLocation key = getSnapshot().lootTable;
- return Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(key));
+ // Scissors start - Return a null loot table if the specified loot table is not valid
+ try {
+ ResourceLocation key = getSnapshot().lootTable;
+ return Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(key));
+ } catch (Exception ex) {
+ return null;
+ }
+ // Scissors end
}
@Override
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java
index 0dd0ce9a9b3253e87eda12354249ec2fd2a33cf2..b6920f9432ca1736afbe775186fbbcf11cf046fb 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java
@@ -33,8 +33,14 @@ public abstract class CraftMinecartContainer extends CraftMinecart implements Lo
return null; // return empty loot table?
}
- NamespacedKey key = CraftNamespacedKey.fromMinecraft(nmsTable);
- return Bukkit.getLootTable(key);
+ // Scissors start - Return a null loot table if the specified loot table is not valid
+ try {
+ NamespacedKey key = CraftNamespacedKey.fromMinecraft(nmsTable);
+ return Bukkit.getLootTable(key);
+ } catch (Exception ex) {
+ return null;
+ }
+ // Scissors end
}
@Override
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
2022-09-26 18:07:45 +00:00
index 620d918e302a00d5a6640648e3096988d15535a0..ac6831248b7c4f25d48391432afb613f25d7e23a 100644
2022-07-28 03:57:50 +00:00
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
2022-09-26 18:07:45 +00:00
@@ -80,8 +80,18 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob {
2022-07-28 03:57:50 +00:00
@Override
public LootTable getLootTable() {
- NamespacedKey key = CraftNamespacedKey.fromMinecraft(this.getHandle().getLootTable());
- return Bukkit.getLootTable(key);
+ if (this.getHandle().lootTable == null) {
+ this.getHandle().lootTable = this.getHandle().getDefaultLootTable();
+ }
+
+ // Scissors start - Return a null loot table if the specified loot table is not valid
+ try {
+ NamespacedKey key = CraftNamespacedKey.fromMinecraft(this.getHandle().getLootTable());
+ return Bukkit.getLootTable(key);
+ } catch (Exception ex) {
+ return null;
+ }
+ // Scissors end
}
@Override