Paper/Spigot-Server-Patches/0622-Do-not-crash-from-invalid-ingredient-lists-in-Villag.patch
Riley Park 4e958e229f
We're going on an Adventure! (#4842)
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
Co-authored-by: zml <zml@stellardrift.ca>
Co-authored-by: Mariell Hoversholm <proximyst@proximyst.com>
2021-02-21 20:45:33 +01:00

25 lines
1.4 KiB
Diff

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/server/EntityVillagerAbstract.java b/src/main/java/net/minecraft/server/EntityVillagerAbstract.java
index 1fddf7c77488a5e53fc48d0db0a7b8acc71e2f42..8971dd013498e70c4e7a6ac6a218f62e599c86b9 100644
--- a/src/main/java/net/minecraft/server/EntityVillagerAbstract.java
+++ b/src/main/java/net/minecraft/server/EntityVillagerAbstract.java
@@ -245,7 +245,11 @@ public abstract class EntityVillagerAbstract extends EntityAgeable implements NP
Bukkit.getPluginManager().callEvent(event);
}
if (!event.isCancelled()) {
- merchantrecipelist.add(CraftMerchantRecipe.fromBukkit(event.getRecipe()).toMinecraft());
+ // Paper start
+ final CraftMerchantRecipe craftMerchantRecipe = CraftMerchantRecipe.fromBukkit(event.getRecipe());
+ if (craftMerchantRecipe.getIngredients().isEmpty()) return;
+ merchantrecipelist.add(craftMerchantRecipe.toMinecraft());
+ // Paper end
}
// CraftBukkit end
}