mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-10 12:02:36 +01:00
40076782ed
By: md_5 <git@md-5.net>
42 lines
1.7 KiB
Diff
42 lines
1.7 KiB
Diff
--- a/net/minecraft/world/entity/npc/EntityVillagerTrader.java
|
|
+++ b/net/minecraft/world/entity/npc/EntityVillagerTrader.java
|
|
@@ -46,6 +46,13 @@
|
|
import net.minecraft.world.phys.Vec3D;
|
|
import org.apache.commons.lang3.ArrayUtils;
|
|
|
|
+// 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;
|
|
@@ -55,6 +62,7 @@
|
|
|
|
public EntityVillagerTrader(EntityTypes<? extends EntityVillagerTrader> entitytypes, World world) {
|
|
super(entitytypes, world);
|
|
+ this.setDespawnDelay(48000); // CraftBukkit - set default from MobSpawnerTrader
|
|
}
|
|
|
|
@Override
|
|
@@ -140,7 +148,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
|
|
}
|
|
|
|
}
|