mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-14 14:45:40 +01:00
53 lines
2.3 KiB
Diff
53 lines
2.3 KiB
Diff
--- a/net/minecraft/server/EntityVillagerAbstract.java
|
|
+++ b/net/minecraft/server/EntityVillagerAbstract.java
|
|
@@ -4,15 +4,30 @@
|
|
import java.util.Iterator;
|
|
import java.util.Set;
|
|
import javax.annotation.Nullable;
|
|
+// CraftBukkit start
|
|
+import org.bukkit.Bukkit;
|
|
+import org.bukkit.craftbukkit.inventory.CraftMerchant;
|
|
+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 {
|
|
|
|
+ // CraftBukkit start
|
|
+ private CraftMerchant craftMerchant;
|
|
+
|
|
+ @Override
|
|
+ public CraftMerchant getCraftMerchant() {
|
|
+ return (craftMerchant == null) ? craftMerchant = new CraftMerchant(this) : craftMerchant;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
private static final DataWatcherObject<Integer> bx = DataWatcher.a(EntityVillagerAbstract.class, DataWatcherRegistry.b);
|
|
@Nullable
|
|
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
|
|
|
|
public EntityVillagerAbstract(EntityTypes<? extends EntityVillagerAbstract> entitytypes, World world) {
|
|
super(entitytypes, world);
|
|
@@ -231,7 +246,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
|
|
}
|
|
}
|
|
|