testserver/patches/server/0575-Do-not-crash-from-inva...

25 lines
1.4 KiB
Diff
Raw Normal View History

2021-06-11 12:02:28 +00: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
2021-06-14 18:50:22 +00:00
index 2610d9cd849aa38cc7a67aef21223707e85682ec..4a7b657265cbbc91ae85409abb3db29cfc555a2c 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java
+++ b/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java
2021-06-14 18:50:22 +00:00
@@ -279,7 +279,11 @@ public abstract class AbstractVillager extends AgeableMob implements InventoryCa
2021-06-11 12:02:28 +00: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
}