aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0458-Fix-crash-from-invalid-ingredient-lists-in-VillagerA.patch
blob: 762023bb097f170286c323703999884da80db94e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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] Fix 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
index 79e81fd5490a493b595dc1034641e13451e5a61a..6e29b5729b8184d13065c9c4e18f6e450c9d88a6 100644
--- a/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java
+++ b/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java
@@ -269,7 +269,11 @@ public abstract class AbstractVillager extends AgeableMob implements InventoryCa
                     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;