    001package cpw.mods.fml.common.modloader;
    002
    003import java.util.List;
    004import java.util.Random;
    005
    006import com.google.common.collect.Lists;
    007
    008import net.minecraft.entity.passive.EntityVillager;
    009import net.minecraft.item.Item;
    010import net.minecraft.src.TradeEntry;
    011import net.minecraft.village.MerchantRecipeList;
    012import cpw.mods.fml.common.registry.VillagerRegistry;
    013import cpw.mods.fml.common.registry.VillagerRegistry.IVillageTradeHandler;
    014
    015public 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}