3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-23 14:50:08 +01:00
Paper/nms-patches/EntityVillagerAbstract.patch

43 Zeilen
1.8 KiB
Diff

2019-04-23 04:00:00 +02:00
--- a/net/minecraft/server/EntityVillagerAbstract.java
+++ b/net/minecraft/server/EntityVillagerAbstract.java
@@ -4,6 +4,12 @@
import java.util.Iterator;
import java.util.Set;
import javax.annotation.Nullable;
+// CraftBukkit start
+import org.bukkit.Bukkit;
+import org.bukkit.craftbukkit.inventory.CraftMerchantRecipe;
+import org.bukkit.entity.AbstractVillager;
+import org.bukkit.event.entity.VillagerAcquireTradeEvent;
+// CraftBukkit end
public abstract class EntityVillagerAbstract extends EntityAgeable implements NPC, IMerchant {
@@ -11,7 +17,7 @@
private EntityHuman tradingPlayer;
@Nullable
protected MerchantRecipeList trades;
- private final InventorySubcontainer inventory = new InventorySubcontainer(8);
+ private final InventorySubcontainer inventory = new InventorySubcontainer(8, (org.bukkit.craftbukkit.entity.CraftAbstractVillager) this.getBukkitEntity()); // CraftBukkit add argument
private int bC;
public EntityVillagerAbstract(EntityTypes<? extends EntityVillagerAbstract> entitytypes, World world) {
@@ -198,7 +204,16 @@
MerchantRecipe merchantrecipe = villagertrades_imerchantrecipeoption.a(this, this.random);
if (merchantrecipe != null) {
- merchantrecipelist.add(merchantrecipe);
+ // CraftBukkit start
+ VillagerAcquireTradeEvent event = new VillagerAcquireTradeEvent((AbstractVillager) getBukkitEntity(), merchantrecipe.asBukkit());
+ // Suppress during worldgen
+ if (this.valid) {
+ Bukkit.getPluginManager().callEvent(event);
+ }
+ if (!event.isCancelled()) {
+ merchantrecipelist.add(CraftMerchantRecipe.fromBukkit(event.getRecipe()).toMinecraft());
+ }
+ // CraftBukkit end
}
}