mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-19 19:59:42 +00:00
40 lines
1.2 KiB
Java
40 lines
1.2 KiB
Java
package cpw.mods.fml.common.modloader;
|
|
|
|
import java.util.List;
|
|
import java.util.Random;
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
import net.minecraft.src.EntityVillager;
|
|
import net.minecraft.src.Item;
|
|
import net.minecraft.src.MerchantRecipeList;
|
|
import net.minecraft.src.TradeEntry;
|
|
import cpw.mods.fml.common.registry.VillagerRegistry;
|
|
import cpw.mods.fml.common.registry.VillagerRegistry.IVillageTradeHandler;
|
|
|
|
public class ModLoaderVillageTradeHandler implements IVillageTradeHandler
|
|
{
|
|
private List<TradeEntry> trades = Lists.newArrayList();
|
|
|
|
@Override
|
|
public void manipulateTradesForVillager(EntityVillager villager, MerchantRecipeList recipeList, Random random)
|
|
{
|
|
for (TradeEntry ent : trades)
|
|
{
|
|
if (ent.buying)
|
|
{
|
|
VillagerRegistry.addEmeraldBuyRecipe(villager, recipeList, random, Item.field_77698_e[ent.id], ent.chance, ent.min, ent.max);
|
|
}
|
|
else
|
|
{
|
|
VillagerRegistry.addEmeraldSellRecipe(villager, recipeList, random, Item.field_77698_e[ent.id], ent.chance, ent.min, ent.max);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void addTrade(TradeEntry entry)
|
|
{
|
|
trades.add(entry);
|
|
}
|
|
}
|