mirror of
https://hub.spigotmc.org/stash/scm/spigot/craftbukkit.git
synced 2024-11-22 10:06:16 +00:00
62 lines
3.2 KiB
Diff
62 lines
3.2 KiB
Diff
--- a/net/minecraft/world/entity/npc/EntityVillagerAbstract.java
|
|
+++ b/net/minecraft/world/entity/npc/EntityVillagerAbstract.java
|
|
@@ -40,8 +40,22 @@
|
|
import net.minecraft.world.phys.Vec3D;
|
|
import org.slf4j.Logger;
|
|
|
|
+// 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 InventoryCarrier, NPC, IMerchant {
|
|
|
|
+ // CraftBukkit start
|
|
+ @Override
|
|
+ public CraftMerchant getCraftMerchant() {
|
|
+ return (org.bukkit.craftbukkit.entity.CraftAbstractVillager) getBukkitEntity();
|
|
+ }
|
|
+ // CraftBukkit end
|
|
private static final DataWatcherObject<Integer> DATA_UNHAPPY_COUNTER = DataWatcher.defineId(EntityVillagerAbstract.class, DataWatcherRegistry.INT);
|
|
private static final Logger LOGGER = LogUtils.getLogger();
|
|
public static final int VILLAGER_SLOT_OFFSET = 300;
|
|
@@ -50,7 +64,7 @@
|
|
private EntityHuman tradingPlayer;
|
|
@Nullable
|
|
protected MerchantRecipeList offers;
|
|
- 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);
|
|
@@ -179,7 +193,7 @@
|
|
public void readAdditionalSaveData(NBTTagCompound nbttagcompound) {
|
|
super.readAdditionalSaveData(nbttagcompound);
|
|
if (nbttagcompound.contains("Offers")) {
|
|
- DataResult dataresult = MerchantRecipeList.CODEC.parse(this.registryAccess().createSerializationContext(DynamicOpsNBT.INSTANCE), nbttagcompound.get("Offers"));
|
|
+ DataResult<MerchantRecipeList> dataresult = MerchantRecipeList.CODEC.parse(this.registryAccess().createSerializationContext(DynamicOpsNBT.INSTANCE), nbttagcompound.get("Offers")); // CraftBukkit - decompile error
|
|
Logger logger = EntityVillagerAbstract.LOGGER;
|
|
|
|
Objects.requireNonNull(logger);
|
|
@@ -246,7 +260,16 @@
|
|
MerchantRecipe merchantrecipe = ((VillagerTrades.IMerchantRecipeOption) arraylist.remove(this.random.nextInt(arraylist.size()))).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
|
|
++j;
|
|
}
|
|
}
|