2019-04-23 04:00:00 +02:00
|
|
|
--- a/net/minecraft/server/EntityVillagerAbstract.java
|
|
|
|
+++ b/net/minecraft/server/EntityVillagerAbstract.java
|
2019-05-14 02:00:00 +02:00
|
|
|
@@ -4,15 +4,30 @@
|
2019-04-23 04:00:00 +02:00
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.Set;
|
|
|
|
import javax.annotation.Nullable;
|
|
|
|
+// CraftBukkit start
|
|
|
|
+import org.bukkit.Bukkit;
|
2019-04-28 04:35:28 +02:00
|
|
|
+import org.bukkit.craftbukkit.inventory.CraftMerchant;
|
2019-04-23 04:00:00 +02:00
|
|
|
+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 {
|
|
|
|
|
2019-04-28 04:35:28 +02:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ private CraftMerchant craftMerchant;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public CraftMerchant getCraftMerchant() {
|
|
|
|
+ return (craftMerchant == null) ? craftMerchant = new CraftMerchant(this) : craftMerchant;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2019-12-10 23:00:00 +01:00
|
|
|
private static final DataWatcherObject<Integer> bx = DataWatcher.a(EntityVillagerAbstract.class, DataWatcherRegistry.b);
|
2019-04-28 04:35:28 +02:00
|
|
|
@Nullable
|
2019-04-23 04:00:00 +02:00
|
|
|
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) {
|
2019-05-14 02:00:00 +02:00
|
|
|
super(entitytypes, world);
|
2019-12-10 23:00:00 +01:00
|
|
|
@@ -231,7 +246,16 @@
|
2019-04-23 04:00:00 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|