本文整理汇总了Java中net.minecraft.village.MerchantRecipe类的典型用法代码示例。如果您正苦于以下问题:Java MerchantRecipe类的具体用法?Java MerchantRecipe怎么用?Java MerchantRecipe使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MerchantRecipe类属于net.minecraft.village包,在下文中一共展示了MerchantRecipe类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: modifyMerchantRecipeList
import net.minecraft.village.MerchantRecipe; //导入依赖的package包/类
public void modifyMerchantRecipeList(MerchantRecipeList recipeList, Random random)
{
int i = 1;
if (this.field_179409_b != null)
{
i = this.field_179409_b.getPrice(random);
}
int j = 1;
if (this.field_179408_d != null)
{
j = this.field_179408_d.getPrice(random);
}
recipeList.add(new MerchantRecipe(new ItemStack(this.field_179411_a.getItem(), i, this.field_179411_a.getMetadata()), new ItemStack(Items.emerald), new ItemStack(this.field_179410_c.getItem(), j, this.field_179410_c.getMetadata())));
}
示例2: doTrade
import net.minecraft.village.MerchantRecipe; //导入依赖的package包/类
private boolean doTrade(MerchantRecipe trade, ItemStack firstItem, ItemStack secondItem)
{
ItemStack itemstack = trade.getItemToBuy();
ItemStack itemstack1 = trade.getSecondItemToBuy();
if (firstItem != null && firstItem.getItem() == itemstack.getItem())
{
if (itemstack1 != null && secondItem != null && itemstack1.getItem() == secondItem.getItem())
{
firstItem.stackSize -= itemstack.stackSize;
secondItem.stackSize -= itemstack1.stackSize;
return true;
}
if (itemstack1 == null && secondItem == null)
{
firstItem.stackSize -= itemstack.stackSize;
return true;
}
}
return false;
}
示例3: func_190888_a
import net.minecraft.village.MerchantRecipe; //导入依赖的package包/类
public void func_190888_a(IMerchant p_190888_1_, MerchantRecipeList p_190888_2_, Random p_190888_3_)
{
Enchantment enchantment = (Enchantment)Enchantment.REGISTRY.getRandomObject(p_190888_3_);
int i = MathHelper.getInt(p_190888_3_, enchantment.getMinLevel(), enchantment.getMaxLevel());
ItemStack itemstack = Items.ENCHANTED_BOOK.getEnchantedItemStack(new EnchantmentData(enchantment, i));
int j = 2 + p_190888_3_.nextInt(5 + i * 10) + 3 * i;
if (enchantment.isTreasureEnchantment())
{
j *= 2;
}
if (j > 64)
{
j = 64;
}
p_190888_2_.add(new MerchantRecipe(new ItemStack(Items.BOOK), new ItemStack(Items.EMERALD, j), itemstack));
}
示例4: func_190901_a
import net.minecraft.village.MerchantRecipe; //导入依赖的package包/类
public ItemStack func_190901_a(EntityPlayer p_190901_1_, ItemStack p_190901_2_)
{
this.onCrafting(p_190901_2_);
MerchantRecipe merchantrecipe = this.theMerchantInventory.getCurrentRecipe();
if (merchantrecipe != null)
{
ItemStack itemstack = this.theMerchantInventory.getStackInSlot(0);
ItemStack itemstack1 = this.theMerchantInventory.getStackInSlot(1);
if (this.doTrade(merchantrecipe, itemstack, itemstack1) || this.doTrade(merchantrecipe, itemstack1, itemstack))
{
this.theMerchant.useRecipe(merchantrecipe);
p_190901_1_.addStat(StatList.TRADED_WITH_VILLAGER);
this.theMerchantInventory.setInventorySlotContents(0, itemstack);
this.theMerchantInventory.setInventorySlotContents(1, itemstack1);
}
}
return p_190901_2_;
}
示例5: doTrade
import net.minecraft.village.MerchantRecipe; //导入依赖的package包/类
private boolean doTrade(MerchantRecipe trade, ItemStack firstItem, ItemStack secondItem)
{
ItemStack itemstack = trade.getItemToBuy();
ItemStack itemstack1 = trade.getSecondItemToBuy();
if (firstItem.getItem() == itemstack.getItem() && firstItem.func_190916_E() >= itemstack.func_190916_E())
{
if (!itemstack1.func_190926_b() && !secondItem.func_190926_b() && itemstack1.getItem() == secondItem.getItem() && secondItem.func_190916_E() >= itemstack1.func_190916_E())
{
firstItem.func_190918_g(itemstack.func_190916_E());
secondItem.func_190918_g(itemstack1.func_190916_E());
return true;
}
if (itemstack1.func_190926_b() && secondItem.func_190926_b())
{
firstItem.func_190918_g(itemstack.func_190916_E());
return true;
}
}
return false;
}
示例6: itemExpire
import net.minecraft.village.MerchantRecipe; //导入依赖的package包/类
@SubscribeEvent
public void itemExpire(ItemExpireEvent event) {
ItemStack stack=event.getEntityItem().getItem();
String thrower=event.getEntityItem().getThrower();
if(stack.getItem() instanceof ItemFromData && thrower!=null){
//System.out.println("put");
HashMap<String,MerchantRecipeList> map=event.getEntityItem().world.getCapability(TF2weapons.WORLD_CAP, null).lostItems;
if(!map.containsKey(thrower))
map.put(thrower, new MerchantRecipeList());
int cost = ItemFromData.getData(stack).getInt(PropertyType.COST)/3;
ItemStack ingot = new ItemStack(TF2weapons.itemTF2, cost / 9, 2);
ItemStack nugget = new ItemStack(TF2weapons.itemTF2, cost % 9, 6);
map.get(thrower).add(new MerchantRecipe(ingot.getCount() > 0 ? ingot : nugget,
nugget.getCount() > 0 && ingot.getCount() > 0 ? nugget : null, stack, 0, 1));
//ItemHandlerHelper.insertItemStacked(map.get(thrower), stack, false);
}
}
示例7: useRecipe
import net.minecraft.village.MerchantRecipe; //导入依赖的package包/类
@Override
public void useRecipe(MerchantRecipe recipe) {
recipe.incrementToolUses();
if (recipe.getItemToBuy().getItem() instanceof ItemWeapon) {
this.loadout.setStackInSlot(ItemFromData.getData(recipe.getItemToBuy()).getInt(PropertyType.SLOT), recipe.getItemToBuy());
this.switchSlot(0);
}
else if(recipe.getItemToBuy().getItem() instanceof ItemWearable) {
this.setItemStackToSlot(EntityEquipmentSlot.HEAD, recipe.getItemToBuy());
}
this.livingSoundTime = -this.getTalkInterval();
this.playSound(SoundEvents.ENTITY_VILLAGER_YES, this.getSoundVolume(), this.getSoundPitch());
int i = 3 + this.rand.nextInt(4);
this.lastTrader = this.trader;
this.tradeCount.put(this.trader,
this.tradeCount.containsKey(trader) ? this.tradeCount.get(this.trader) + 1 : 1);
this.traderFollowTicks = Math.min(4800, this.tradeCount.get(this.trader) * 250 + 350);
if (recipe.getRewardsExp())
this.world.spawnEntity(new EntityXPOrb(this.world, this.posX, this.posY + 0.5D, this.posZ, i));
}
示例8: modifyMerchantRecipeList
import net.minecraft.village.MerchantRecipe; //导入依赖的package包/类
/**
* Affects the given MerchantRecipeList to possibly add or remove MerchantRecipes.
*/
public void modifyMerchantRecipeList(MerchantRecipeList recipeList, Random random)
{
int i = 1;
if (this.buyingPriceInfo != null)
{
i = this.buyingPriceInfo.getPrice(random);
}
int j = 1;
if (this.sellingPriceInfo != null)
{
j = this.sellingPriceInfo.getPrice(random);
}
recipeList.add(new MerchantRecipe(new ItemStack(this.buyingItemStack.getItem(), i, this.buyingItemStack.getMetadata()), new ItemStack(Items.EMERALD), new ItemStack(this.sellingItemstack.getItem(), j, this.sellingItemstack.getMetadata())));
}
示例9: doTrade
import net.minecraft.village.MerchantRecipe; //导入依赖的package包/类
private boolean doTrade(MerchantRecipe trade, ItemStack firstItem, ItemStack secondItem)
{
ItemStack itemstack = trade.getItemToBuy();
ItemStack itemstack1 = trade.getSecondItemToBuy();
if (firstItem != null && firstItem.getItem() == itemstack.getItem() && firstItem.stackSize >= itemstack.stackSize)
{
if (itemstack1 != null && secondItem != null && itemstack1.getItem() == secondItem.getItem() && secondItem.stackSize >= itemstack1.stackSize)
{
firstItem.stackSize -= itemstack.stackSize;
secondItem.stackSize -= itemstack1.stackSize;
return true;
}
if (itemstack1 == null && secondItem == null)
{
firstItem.stackSize -= itemstack.stackSize;
return true;
}
}
return false;
}
示例10: compare
import net.minecraft.village.MerchantRecipe; //导入依赖的package包/类
@Override
public int compare(final Object arg0, final Object arg1) {
final int i = this.intCompare(GuiTradingPost.getProf(((Object[])arg0)[0]), GuiTradingPost.getProf(((Object[])arg0)[0]));
if (i != 0) {
return i;
}
final MerchantRecipe m1 = (MerchantRecipe)((Object[])arg0)[1];
final MerchantRecipe m2 = (MerchantRecipe)((Object[])arg1)[1];
final int i2 = this.itemCompare(m1.getItemToBuy().getItem(), m2.getItemToBuy().getItem());
if (i2 != 0) {
return i2;
}
final int i3 = this.intCompare(m1.getItemToBuy().stackSize, m2.getItemToBuy().stackSize);
if (i3 != 0) {
return i3;
}
final int i4 = this.itemCompare(m1.getItemToSell().getItem(), m2.getItemToSell().getItem());
if (i4 != 0) {
return i4;
}
final int i5 = this.intCompare(m1.getItemToSell().stackSize, m2.getItemToSell().stackSize);
if (i5 == 0) {
return this.intCompare(m1.writeToTags().hashCode(), m2.writeToTags().hashCode());
}
return i5;
}
示例11: manipulateTradesForVillager
import net.minecraft.village.MerchantRecipe; //导入依赖的package包/类
@Override
public void manipulateTradesForVillager(EntityVillager villager, MerchantRecipeList recipeList, Random random)
{
for (int i = 0; i < 4; i++)
{
switch(villager.getProfession())
{
case 0: // FARMER
recipeList.add(new MerchantRecipe(new ItemStack(ItemRegister.COMBUSTIUM, 2), new ItemStack(Items.apple, 1)));
break;
case 1: // LIBRARIAN
recipeList.add(new MerchantRecipe(new ItemStack(ItemRegister.COMBUSTIUM, 4, 15), new ItemStack(Items.paper, 1, 6)));
recipeList.add(new MerchantRecipe(new ItemStack(ItemRegister.COMBUSTIUM, 1), Items.enchanted_book.getEnchantedItemStack(new EnchantmentData(Enchantment.flame, 1))));
break;
case 2: // PRIEST
recipeList.add(new MerchantRecipe(new ItemStack(ItemRegister.COMBUSTIUM, 6), new ItemStack(Items.apple, 2), new ItemStack(Items.apple, 2)));
break;
case 3: // BLACKSMITH
recipeList.add(new MerchantRecipe(new ItemStack(ItemRegister.COMBUSTIUM, 6 + random.nextInt(6)), new ItemStack(Items.apple, 5 + random.nextInt(4)), new ItemStack(Items.apple, 1)));
recipeList.add(new MerchantRecipe(new ItemStack(ItemRegister.ETHERNIUM, 64), new ItemStack(ItemRegister.ELLAMAYNE, 1)));
break;
default:
break;
}
}
}
示例12: addMerchantRecipe
import net.minecraft.village.MerchantRecipe; //导入依赖的package包/类
@Override
public void addMerchantRecipe(IMerchant merchant, MerchantRecipeList recipeList, Random rand) {
int i = 1;
if (this.priceInfo != null) {
i = this.priceInfo.getPrice(rand);
}
ItemStack itemstack;
ItemStack itemstack1;
if (i < 0) {
itemstack = new ItemStack(ModItems.trading_token);
itemstack1 = new ItemStack(this.itemToBuy.getItem(), abs(i), this.itemToBuy.getMetadata());
} else {
itemstack = new ItemStack(ModItems.trading_token, i);
itemstack1 = new ItemStack(this.itemToBuy.getItem(), 1, this.itemToBuy.getMetadata());
}
recipeList.add(new MerchantRecipe(itemstack, itemstack1));
}
示例13: addTrade
import net.minecraft.village.MerchantRecipe; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void addTrade(MerchantRecipeList recipeList, Random rand, float chance, Offer sale, Offer... offers) {
if (offers.length <= 0 || sale.obj == null)
return;
for (Offer offer : offers) {
if (offer.obj == null)
return;
}
if (rand.nextFloat() < adjustProbability(chance)) {
ItemStack sellStack = prepareStack(rand, sale);
ItemStack buyStack1 = prepareStack(rand, offers[0]);
ItemStack buyStack2 = null;
if (offers.length >= 2)
buyStack2 = prepareStack(rand, offers[1]);
recipeList.add(new MerchantRecipe(buyStack1, buyStack2, sellStack));
}
}
示例14: modifyMerchantRecipeList
import net.minecraft.village.MerchantRecipe; //导入依赖的package包/类
/**
* Affects the given MerchantRecipeList to possibly add or remove MerchantRecipes.
*/
public void modifyMerchantRecipeList(MerchantRecipeList recipeList, Random random) {
int i = 1;
if (this.priceInfo != null) {
i = this.priceInfo.getPrice(random);
}
ItemStack itemstack;
ItemStack itemstack1;
if (i < 0) {
itemstack = new ItemStack(Items.EMERALD);
itemstack1 = new ItemStack(this.itemToBuy.getItem(), -i, this.itemToBuy.getMetadata());
}
else {
itemstack = new ItemStack(Items.EMERALD, i, 0);
itemstack1 = this.itemToBuy.copy();
//copy does same thing but yeah. the stackSize is hardcodeed 1 in vanilla
//THIS IS THE FIX!!!! vanilla is hardcoded to 1 but we just do stacksize
////new ItemStack(this.itemToBuy.getItem(), this.itemToBuy.stackSize, this.itemToBuy.getMetadata());
}
recipeList.add(new MerchantRecipe(itemstack, itemstack1));
}
示例15: modifyMerchantRecipeList
import net.minecraft.village.MerchantRecipe; //导入依赖的package包/类
public void modifyMerchantRecipeList(MerchantRecipeList recipeList, Random random)
{
int i = 1;
if (this.field_179409_b != null)
{
i = this.field_179409_b.func_179412_a(random);
}
int j = 1;
if (this.field_179408_d != null)
{
j = this.field_179408_d.func_179412_a(random);
}
recipeList.add(new MerchantRecipe(new ItemStack(this.field_179411_a.getItem(), i, this.field_179411_a.getMetadata()), new ItemStack(Items.emerald), new ItemStack(this.field_179410_c.getItem(), j, this.field_179410_c.getMetadata())));
}