aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/og/net/minecraft/world/entity/npc/EntityVillagerTrader.patch
blob: 13fa1f829d3a6ae6e641c3c5431f1f1c0c3923e8 (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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
--- a/net/minecraft/world/entity/npc/EntityVillagerTrader.java
+++ b/net/minecraft/world/entity/npc/EntityVillagerTrader.java
@@ -47,6 +47,13 @@
 import net.minecraft.world.phys.Vec3D;
 import org.apache.commons.lang3.tuple.Pair;
 
+// 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 class EntityVillagerTrader extends EntityVillagerAbstract {
 
     private static final int NUMBER_OF_TRADE_OFFERS = 5;
@@ -56,6 +63,7 @@
 
     public EntityVillagerTrader(EntityTypes<? extends EntityVillagerTrader> entitytypes, World world) {
         super(entitytypes, world);
+        this.setDespawnDelay(48000); // CraftBukkit - set default from MobSpawnerTrader
     }
 
     @Override
@@ -136,7 +144,16 @@
                 MerchantRecipe merchantrecipe = villagertrades_imerchantrecipeoption.getOffer(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
                 }
 
             }