    001    package cpw.mods.fml.common.modloader;
    002
    003    import java.util.List;
    004    import java.util.Random;
    005
    006    import com.google.common.collect.Lists;
    007
    008    import net.minecraft.entity.passive.EntityVillager;
    009    import net.minecraft.item.Item;
    010    import net.minecraft.src.TradeEntry;
    011    import net.minecraft.village.MerchantRecipeList;
    012    import cpw.mods.fml.common.registry.VillagerRegistry;
    013    import cpw.mods.fml.common.registry.VillagerRegistry.IVillageTradeHandler;
    014
    015    public class ModLoaderVillageTradeHandler implements IVillageTradeHandler
    016    {
    017        private List<TradeEntry> trades = Lists.newArrayList();
    018
    019        @Override
    020        public void manipulateTradesForVillager(EntityVillager villager, MerchantRecipeList recipeList, Random random)
    021        {
    022            for (TradeEntry ent : trades)
    023            {
    024                if (ent.buying)
    025                {
    026                    VillagerRegistry.addEmeraldBuyRecipe(villager, recipeList, random, Item.itemsList[ent.id], ent.chance, ent.min, ent.max);
    027                }
    028                else
    029                {
    030                    VillagerRegistry.addEmeraldSellRecipe(villager, recipeList, random, Item.itemsList[ent.id], ent.chance, ent.min, ent.max);
    031                }
    032            }
    033        }
    034
    035        public void addTrade(TradeEntry entry)
    036        {
    037            trades.add(entry);
    038        }
    039    }