From 5b7474984ba8737f465a04c12a30319613de4536 Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Sun, 27 Dec 2020 11:31:06 +0000 Subject: [PATCH] Fix crash from invalid ingredient lists in VillagerAcquireTradeEvent --- .../world/entity/npc/AbstractVillager.java.patch | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/paper-server/patches/sources/net/minecraft/world/entity/npc/AbstractVillager.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/npc/AbstractVillager.java.patch index 2ee4a021d8..37321c76f6 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/npc/AbstractVillager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/npc/AbstractVillager.java.patch @@ -54,7 +54,7 @@ Logger logger = AbstractVillager.LOGGER; Objects.requireNonNull(logger); -@@ -246,7 +266,16 @@ +@@ -246,7 +266,20 @@ MerchantOffer merchantrecipe = ((VillagerTrades.ItemListing) arraylist.remove(this.random.nextInt(arraylist.size()))).getOffer(this, this.random); if (merchantrecipe != null) { @@ -66,7 +66,11 @@ + Bukkit.getPluginManager().callEvent(event); + } + if (!event.isCancelled()) { -+ recipeList.add(CraftMerchantRecipe.fromBukkit(event.getRecipe()).toMinecraft()); ++ // Paper start - Fix crash from invalid ingredient list ++ final CraftMerchantRecipe craftMerchantRecipe = CraftMerchantRecipe.fromBukkit(event.getRecipe()); ++ if (craftMerchantRecipe.getIngredients().isEmpty()) return; ++ recipeList.add(craftMerchantRecipe.toMinecraft()); ++ // Paper end - Fix crash from invalid ingredient list + } + // CraftBukkit end ++j;