diff options
Diffstat (limited to 'patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/npc/AbstractVillager.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/npc/AbstractVillager.java.patch | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/npc/AbstractVillager.java.patch b/patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/npc/AbstractVillager.java.patch new file mode 100644 index 0000000000..cef3364ec8 --- /dev/null +++ b/patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/npc/AbstractVillager.java.patch @@ -0,0 +1,55 @@ +--- a/net/minecraft/world/entity/npc/AbstractVillager.java ++++ b/net/minecraft/world/entity/npc/AbstractVillager.java +@@ -34,9 +34,23 @@ + import net.minecraft.world.level.ServerLevelAccessor; + import net.minecraft.world.level.pathfinder.BlockPathTypes; + import net.minecraft.world.phys.Vec3; ++// CraftBukkit start ++import org.bukkit.Bukkit; ++import org.bukkit.craftbukkit.inventory.CraftMerchant; ++import org.bukkit.craftbukkit.inventory.CraftMerchantRecipe; ++import org.bukkit.event.entity.VillagerAcquireTradeEvent; ++// CraftBukkit end + + public abstract class AbstractVillager extends AgeableMob implements InventoryCarrier, Npc, Merchant { + ++ // CraftBukkit start ++ private CraftMerchant craftMerchant; ++ ++ @Override ++ public CraftMerchant getCraftMerchant() { ++ return (craftMerchant == null) ? craftMerchant = new CraftMerchant(this) : craftMerchant; ++ } ++ // CraftBukkit end + private static final EntityDataAccessor<Integer> DATA_UNHAPPY_COUNTER = SynchedEntityData.defineId(AbstractVillager.class, EntityDataSerializers.INT); + public static final int VILLAGER_SLOT_OFFSET = 300; + private static final int VILLAGER_INVENTORY_SIZE = 8; +@@ -44,7 +58,7 @@ + private Player tradingPlayer; + @Nullable + protected MerchantOffers offers; +- private final SimpleContainer inventory = new SimpleContainer(8); ++ private final SimpleContainer inventory = new SimpleContainer(8, (org.bukkit.craftbukkit.entity.CraftAbstractVillager) this.getBukkitEntity()); // CraftBukkit add argument + + public AbstractVillager(EntityType<? extends AbstractVillager> entitytype, Level level) { + super(entitytype, level); +@@ -252,8 +246,17 @@ + while (j < i && !arraylist.isEmpty()) { + MerchantOffer merchantoffer = ((VillagerTrades.ItemListing) arraylist.remove(this.random.nextInt(arraylist.size()))).getOffer(this, this.random); + +- if (merchantoffer != null) { +- merchantoffers.add(merchantoffer); ++ if (merchantrecipe != null) { ++ // CraftBukkit start ++ VillagerAcquireTradeEvent event = new VillagerAcquireTradeEvent((org.bukkit.entity.AbstractVillager) getBukkitEntity(), merchantrecipe.asBukkit()); ++ // Suppress during worldgen ++ if (this.valid) { ++ Bukkit.getPluginManager().callEvent(event); ++ } ++ if (!event.isCancelled()) { ++ givenMerchantOffers.add(CraftMerchantRecipe.fromBukkit(event.getRecipe()).toMinecraft()); ++ } ++ // CraftBukkit end + ++j; + } + } |