本文整理汇总了Java中net.minecraft.entity.passive.EntityVillager.ITradeList类的典型用法代码示例。如果您正苦于以下问题:Java ITradeList类的具体用法?Java ITradeList怎么用?Java ITradeList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITradeList类属于net.minecraft.entity.passive.EntityVillager包,在下文中一共展示了ITradeList类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addTrade
import net.minecraft.entity.passive.EntityVillager.ITradeList; //导入依赖的package包/类
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;
}
示例2: makeTradePalette
import net.minecraft.entity.passive.EntityVillager.ITradeList; //导入依赖的package包/类
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;
}
示例3: getBuyingStack
import net.minecraft.entity.passive.EntityVillager.ITradeList; //导入依赖的package包/类
@Override
public ItemStack getBuyingStack(ITradeList t)
{
EmeraldForItems trade = (EmeraldForItems)t;
ItemStack stack = new ItemStack(trade.buyingItem, 1, 0);
return stack;
}
示例4: getSellingStack
import net.minecraft.entity.passive.EntityVillager.ITradeList; //导入依赖的package包/类
@Override
public ItemStack getSellingStack(ITradeList t)
{
ItemAndEmeraldToItem trade = (ItemAndEmeraldToItem)t;
ItemStack stack = trade.sellingItemstack.copy();
return stack;
}
示例5: clearCareerTrades
import net.minecraft.entity.passive.EntityVillager.ITradeList; //导入依赖的package包/类
private static void clearCareerTrades(VillagerCareer career)
{
List<List<ITradeList>> trades = new VTTVillagerCareer(career).getTrades();
for (List<ITradeList> careerTrades : trades)
{
careerTrades.clear();
}
trades.clear();
}
示例6: makePurchasePalette
import net.minecraft.entity.passive.EntityVillager.ITradeList; //导入依赖的package包/类
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;
}
示例7: makeSalePalette
import net.minecraft.entity.passive.EntityVillager.ITradeList; //导入依赖的package包/类
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;
}
示例8: sortCareerTrades
import net.minecraft.entity.passive.EntityVillager.ITradeList; //导入依赖的package包/类
/**
* 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;
}
});
}
}
示例9: getTrades
import net.minecraft.entity.passive.EntityVillager.ITradeList; //导入依赖的package包/类
public List<List<ITradeList>> getTrades()
{
return ReflectionHelper.getFieldValue(careerTradesField, this.career);
}
示例10: getTrades
import net.minecraft.entity.passive.EntityVillager.ITradeList; //导入依赖的package包/类
public List<ITradeList> getTrades(int level)
{
return level >= 0 && level < this.trades.size() ? Collections.unmodifiableList(this.trades.get(level)) : null;
}
示例11: init
import net.minecraft.entity.passive.EntityVillager.ITradeList; //导入依赖的package包/类
private VillagerCareer init(EntityVillager.ITradeList[][] trades)
{
for (int x = 0; x < trades.length; x++)
this.trades.add(Lists.newArrayList(trades[x]));
return this;
}
示例12: init
import net.minecraft.entity.passive.EntityVillager.ITradeList; //导入依赖的package包/类
private VillagerCareer init(EntityVillager.ITradeList[][] traids)
{
return this;
}
示例13: MultiTradeGenerator
import net.minecraft.entity.passive.EntityVillager.ITradeList; //导入依赖的package包/类
/**
* 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()]);
}