Java 类net.minecraft.entity.passive.EntityVillager.ITradeList 实例源码

项目:CustomWorldGen    文件:VillagerRegistry.java   
public VillagerCareer addTrade(int level, ITradeList... trades)
{
    if (level <= 0)
        throw new IllegalArgumentException("Levels start at 1");

    List<ITradeList> levelTrades = level <= this.trades.size() ? this.trades.get(level - 1) : null;
    if (levelTrades == null)
    {
        while (this.trades.size() < level)
        {
            levelTrades = Lists.newArrayList();
            this.trades.add(levelTrades);
        }
    }
    if (levelTrades == null) //Not sure how this could happen, but screw it
    {
        levelTrades = Lists.newArrayList();
        this.trades.set(level - 1, levelTrades);
    }
    for (ITradeList t : trades)
        levelTrades.add(t);
    return this;
}
项目:BaseMetals    文件:VillagerTrades.java   
private static ITradeList[] makeTradePalette(ITradeList[]... list){
    if(list.length == 1) return list[0];
    int totalsize = 0;
    for(ITradeList[] e : list){
        totalsize += e.length;
    }
    ITradeList[] concat = new ITradeList[totalsize];
    int index = 0;
    int element = 0;
    while(index < totalsize){
        System.arraycopy(list[element], 0, concat, index, list[element].length);
        index += list[element].length;
        element++;
    }
    return concat;
}
项目:VillagerTrades    文件:TradeHandlers.java   
@Override
public ItemStack getBuyingStack(ITradeList t)
{
    EmeraldForItems trade = (EmeraldForItems)t;
    ItemStack stack = new ItemStack(trade.buyingItem, 1, 0);
    return stack;
}
项目:VillagerTrades    文件:TradeHandlers.java   
@Override
public ItemStack getSellingStack(ITradeList t)
{
    ItemAndEmeraldToItem trade = (ItemAndEmeraldToItem)t;
    ItemStack stack = trade.sellingItemstack.copy();
    return stack;
}
项目:VillagerTrades    文件:TradeHandlers.java   
@Override
public ItemStack getSellingStack(ITradeList t)
{
    ListEnchantedBookForEmeralds trade = (ListEnchantedBookForEmeralds)t;
    ItemStack stack = new ItemStack(Items.ENCHANTED_BOOK, 1, 0);
    return stack;
}
项目:VillagerTrades    文件:TradeHandlers.java   
@Override
public ItemStack getSellingStack(ITradeList t)
{
    ListEnchantedItemForEmeralds trade = (ListEnchantedItemForEmeralds)t;
    ItemStack stack = trade.enchantedItemStack.copy();
    return stack;
}
项目:VillagerTrades    文件:TradeHandlers.java   
@Override
public ItemStack getSellingStack(ITradeList t)
{
    ListItemForEmeralds trade = (ListItemForEmeralds)t;
    ItemStack stack = trade.itemToBuy.copy();
    return stack;
}
项目:VillagerTrades    文件:TradeHandlers.java   
@Override
        public ItemStack getSellingStack(ITradeList t)
        {
//          TreasureMapForEmeralds trade = (TreasureMapForEmeralds)t;
            ItemStack stack = new ItemStack(Items.FILLED_MAP, 1);
            return stack;
        }
项目:VillagerTrades    文件:TradeLoader.java   
private static void clearCareerTrades(VillagerCareer career)
{
    List<List<ITradeList>> trades = new VTTVillagerCareer(career).getTrades();
    for (List<ITradeList> careerTrades : trades)
    {
        careerTrades.clear();
    }
    trades.clear();
}
项目:BaseMetals    文件:VillagerTrades.java   
private static ITradeList[] makePurchasePalette(int emeraldPrice, int stackSize, Item... items){
    ITradeList[] trades = new ITradeList[items.length];
    for(int i = 0; i < items.length; i++){
        Item item = items[i];
        trades[i] = new SimpleTrade(
                new ItemStack(net.minecraft.init.Items.EMERALD,emeraldPrice,0), fluctuation(emeraldPrice),
                (ItemStack)null, 0,
                new ItemStack(item,stackSize,0), 0);
    }
    return trades;
}
项目:BaseMetals    文件:VillagerTrades.java   
private static ITradeList[] makeSalePalette(int emeraldValue, int stackSize, Item... items){
    ITradeList[] trades = new ITradeList[items.length];
    for(int i = 0; i < items.length; i++){
        Item item = items[i];
        trades[i] = new SimpleTrade(
                new ItemStack(item,stackSize,0), fluctuation(stackSize),
                (ItemStack)null, 0,
                new ItemStack(net.minecraft.init.Items.EMERALD,emeraldValue,0), 0);
    }
    return trades;
}
项目:VillagerTrades    文件:TradeHandlers.java   
public ItemStack getBuyingStack(ITradeList trade)
{
    return ItemStack.EMPTY;
}
项目:VillagerTrades    文件:TradeHandlers.java   
public ItemStack getSellingStack(ITradeList trade)
{
    return ItemStack.EMPTY;
}
项目:VillagerTrades    文件:TradeLoader.java   
private static void clearCareerTrades(VillagerCareer career, int careerLevel)
{
    List<ITradeList> trades = new VTTVillagerCareer(career).getTrades(careerLevel);
    trades.clear();
}
项目:VillagerTrades    文件:TradeLoader.java   
/**
 * Sorts the trades at each level of a career so that the buying trades appear before the selling trades
 * @param career The VillagerCareer instance on which to sort the trades
 */
private static void sortCareerTrades(VillagerCareer career)
{
    // get the trades from the career instance in a modifiable form
    List<List<ITradeList>> trades = new VTTVillagerCareer(career).getTrades();

    // iterate over the trades at each career level
    for (List<ITradeList> levelTrades : trades)
    {
        // sort the trades using a comparator
        Collections.sort(levelTrades, new Comparator<ITradeList>()
        {

            @Override
            public int compare(ITradeList tradeA, ITradeList tradeB)
            {
                // get the appropriate trade handler for the two trades being compared
                ITradeHandler handlerA = TradeHandlers.tradeHandlers.get(tradeA.getClass());
                ITradeHandler handlerB = TradeHandlers.tradeHandlers.get(tradeB.getClass());

                if (handlerA != null && handlerB != null)
                {
                    // if one is a buying trade and the other a selling trade, put the buying trade first
                    if (handlerA instanceof VTTVillagerBuyingHandler && handlerB instanceof VTTVillagerSellingHandler)
                    {
                        return -1;
                    }
                    else if (handlerA instanceof VTTVillagerSellingHandler && handlerB instanceof VTTVillagerBuyingHandler)
                    {
                        return 1;
                    }
                }
                // otherwise leave their current positions unmodified
                return 0;
            }

        });

    }

}
项目:VillagerTrades    文件:VillagerRegistryHelper.java   
public List<List<ITradeList>> getTrades()
{
    return ReflectionHelper.getFieldValue(careerTradesField, this.career);
}
项目:VillagerTrades    文件:VillagerRegistryHelper.java   
public List<ITradeList> getTrades(int level)
{
    List<List<ITradeList>> trades = this.getTrades();
    int index = level - 1;
    return index >= 0 && index < trades.size() ? trades.get(index) : null;
}
项目:CustomWorldGen    文件:VillagerRegistry.java   
public List<ITradeList> getTrades(int level)
{
    return level >= 0 && level < this.trades.size() ? Collections.unmodifiableList(this.trades.get(level)) : null;
}
项目:CustomWorldGen    文件:VillagerRegistry.java   
private VillagerCareer init(EntityVillager.ITradeList[][] trades)
{
    for (int x = 0; x < trades.length; x++)
        this.trades.add(Lists.newArrayList(trades[x]));
    return this;
}
项目:Rediscovered-Mod-1.8    文件:GreenRegistry.java   
private VillagerCareer init(EntityVillager.ITradeList[][] traids)
{
    return this;
}
项目:Rediscovered-Mod-1.8.8    文件:GreenRegistry.java   
private VillagerCareer init(EntityVillager.ITradeList[][] traids)
{
    return this;
}
项目:BaseMetals    文件:VillagerTrades.java   
/**
 * Creates an ITradeList instanec that randomly adds multiple trades at a time
 * @param tradeCount Number of trades to add to the merchant's trade menu
 * @param tradePalette The trades to randomly choose from
 */
public MultiTradeGenerator(int tradeCount, List<ITradeList> tradePalette){
    this.numberOfTrades = Math.min(tradeCount,tradePalette.size());
    trades = tradePalette.toArray(new ITradeList[tradePalette.size()]);
}