aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0505-Do-not-crash-from-invalid-ingredient-lists-in-Villag.patch
blob: 429087e774a4604042df0fa74f49cda03dca81c8 (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] 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
index 66b7a2c9a7dc18a98bf2c3aac863a10cbc3ae9f9..73bc45000b5285ccf5b06e2f372d6c82bf843b82 100644
--- a/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java
+++ b/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java
@@ -261,7 +261,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
+                    final CraftMerchantRecipe craftMerchantRecipe = CraftMerchantRecipe.fromBukkit(event.getRecipe());
+                    if (craftMerchantRecipe.getIngredients().isEmpty()) return;
+                    recipeList.add(craftMerchantRecipe.toMinecraft());
+                    // Paper end
                 }
                 // CraftBukkit end
                 ++j;