13
0
geforkt von Mirrors/Paper
Paper/paper-server/nms-patches/EntityVillagerTrader.patch
CraftBukkit/Spigot b2efd58164 Organise imports
By: md_5 <git@md-5.net>
2021-03-09 08:47:33 +11:00

43 Zeilen
1.6 KiB
Diff

--- a/net/minecraft/server/EntityVillagerTrader.java
+++ b/net/minecraft/server/EntityVillagerTrader.java
@@ -3,6 +3,13 @@
import java.util.EnumSet;
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 class EntityVillagerTrader extends EntityVillagerAbstract {
@Nullable
@@ -12,6 +19,7 @@
public EntityVillagerTrader(EntityTypes<? extends EntityVillagerTrader> entitytypes, World world) {
super(entitytypes, world);
this.attachedToPlayer = true;
+ this.u(48000); // CraftBukkit - set default from MobSpawnerTrader
}
@Override
@@ -89,7 +97,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
}
}