diff options
Diffstat (limited to 'patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/npc/AbstractVillager.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/npc/AbstractVillager.java.patch | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/npc/AbstractVillager.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/npc/AbstractVillager.java.patch new file mode 100644 index 0000000000..f8fffcf3b4 --- /dev/null +++ b/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/npc/AbstractVillager.java.patch @@ -0,0 +1,63 @@ +--- a/net/minecraft/world/entity/npc/AbstractVillager.java ++++ b/net/minecraft/world/entity/npc/AbstractVillager.java +@@ -34,8 +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 { ++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; +@@ -43,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); +@@ -226,11 +243,21 @@ + ArrayList<VillagerTrades.ItemListing> list = Lists.newArrayList(newTrades); + int i = 0; + +- while (i < maxNumbers && !list.isEmpty()) { +- MerchantOffer offer = list.remove(this.random.nextInt(list.size())).getOffer(this, this.random); +- if (offer != null) { +- givenMerchantOffers.add(offer); +- i++; ++ while (j < maxNumbers && !arraylist.isEmpty()) { ++ MerchantOffer merchantrecipe = ((VillagerTrades.ItemListing) arraylist.remove(this.random.nextInt(arraylist.size()))).getOffer(this, this.random); ++ ++ 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; + } + } + } |