Paper/patches/server/0540-Do-not-crash-from-invalid-ingredient-lists-in-Villag.patch

25 Zeilen
1.4 KiB
Diff

2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Sun, 27 Dec 2020 11:31:06 +0000
Subject: [PATCH] Do not crash from invalid ingredient lists in
VillagerAcquireTradeEvent
diff --git a/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java b/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java
2022-06-08 09:30:41 +02:00
index 6717e3d116b7bff8ab4d7b45f8c4ec00939c9c73..0c585354ba459ceb6badbf60dcf7b068bfa108b6 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java
+++ b/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java
2021-11-24 18:22:48 +01:00
@@ -275,7 +275,11 @@ public abstract class AbstractVillager extends AgeableMob implements InventoryCa
2021-06-11 14:02:28 +02:00
Bukkit.getPluginManager().callEvent(event);
}
if (!event.isCancelled()) {
- recipeList.add(CraftMerchantRecipe.fromBukkit(event.getRecipe()).toMinecraft());
+ // Paper start
+ final CraftMerchantRecipe craftMerchantRecipe = CraftMerchantRecipe.fromBukkit(event.getRecipe());
+ if (craftMerchantRecipe.getIngredients().isEmpty()) return;
+ recipeList.add(craftMerchantRecipe.toMinecraft());
+ // Paper end
}
// CraftBukkit end
}