diff options
Diffstat (limited to 'patch-remap/og/net/minecraft/world/entity/npc/EntityVillagerAbstract.patch')
-rw-r--r-- | patch-remap/og/net/minecraft/world/entity/npc/EntityVillagerAbstract.patch | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/patch-remap/og/net/minecraft/world/entity/npc/EntityVillagerAbstract.patch b/patch-remap/og/net/minecraft/world/entity/npc/EntityVillagerAbstract.patch new file mode 100644 index 0000000000..d6c61da367 --- /dev/null +++ b/patch-remap/og/net/minecraft/world/entity/npc/EntityVillagerAbstract.patch @@ -0,0 +1,54 @@ +--- a/net/minecraft/world/entity/npc/EntityVillagerAbstract.java ++++ b/net/minecraft/world/entity/npc/EntityVillagerAbstract.java +@@ -35,8 +35,24 @@ + import net.minecraft.world.level.pathfinder.PathType; + import net.minecraft.world.phys.Vec3D; + ++// 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 ++ private CraftMerchant craftMerchant; ++ ++ @Override ++ public CraftMerchant getCraftMerchant() { ++ return (craftMerchant == null) ? craftMerchant = new CraftMerchant(this) : craftMerchant; ++ } ++ // CraftBukkit end + private static final DataWatcherObject<Integer> DATA_UNHAPPY_COUNTER = DataWatcher.defineId(EntityVillagerAbstract.class, DataWatcherRegistry.INT); + public static final int VILLAGER_SLOT_OFFSET = 300; + private static final int VILLAGER_INVENTORY_SIZE = 8; +@@ -44,7 +60,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); +@@ -233,7 +249,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; + } + } |