當前位置: 首頁>>代碼示例>>Java>>正文


Java MerchantRecipeList類代碼示例

本文整理匯總了Java中net.minecraft.village.MerchantRecipeList的典型用法代碼示例。如果您正苦於以下問題:Java MerchantRecipeList類的具體用法?Java MerchantRecipeList怎麽用?Java MerchantRecipeList使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MerchantRecipeList類屬於net.minecraft.village包,在下文中一共展示了MerchantRecipeList類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: displayVillagerTradeGui

import net.minecraft.village.MerchantRecipeList; //導入依賴的package包/類
public void displayVillagerTradeGui(IMerchant villager)
{
    this.getNextWindowId();
    this.openContainer = new ContainerMerchant(this.inventory, villager, this.worldObj);
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.onCraftGuiOpened(this);
    IInventory iinventory = ((ContainerMerchant)this.openContainer).getMerchantInventory();
    IChatComponent ichatcomponent = villager.getDisplayName();
    this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, "minecraft:villager", ichatcomponent, iinventory.getSizeInventory()));
    MerchantRecipeList merchantrecipelist = villager.getRecipes(this);

    if (merchantrecipelist != null)
    {
        PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
        packetbuffer.writeInt(this.currentWindowId);
        merchantrecipelist.writeToBuf(packetbuffer);
        this.playerNetServerHandler.sendPacket(new S3FPacketCustomPayload("MC|TrList", packetbuffer));
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:20,代碼來源:EntityPlayerMP.java

示例2: modifyMerchantRecipeList

import net.minecraft.village.MerchantRecipeList; //導入依賴的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())));
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:19,代碼來源:EntityVillager.java

示例3: itemExpire

import net.minecraft.village.MerchantRecipeList; //導入依賴的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);
	}
}
 
開發者ID:rafradek,項目名稱:Mods,代碼行數:19,代碼來源:TF2EventsCommon.java

示例4: displayVillagerTradeGui

import net.minecraft.village.MerchantRecipeList; //導入依賴的package包/類
public void displayVillagerTradeGui(IMerchant villager)
{
    this.getNextWindowId();
    this.openContainer = new ContainerMerchant(this.inventory, villager, this.worldObj);
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.addListener(this);
    net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerContainerEvent.Open(this, this.openContainer));
    IInventory iinventory = ((ContainerMerchant)this.openContainer).getMerchantInventory();
    ITextComponent itextcomponent = villager.getDisplayName();
    this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, "minecraft:villager", itextcomponent, iinventory.getSizeInventory()));
    MerchantRecipeList merchantrecipelist = villager.getRecipes(this);

    if (merchantrecipelist != null)
    {
        PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
        packetbuffer.writeInt(this.currentWindowId);
        merchantrecipelist.writeToBuf(packetbuffer);
        this.connection.sendPacket(new SPacketCustomPayload("MC|TrList", packetbuffer));
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:21,代碼來源:EntityPlayerMP.java

示例5: modifyMerchantRecipeList

import net.minecraft.village.MerchantRecipeList; //導入依賴的package包/類
/**
 * Affects the given MerchantRecipeList to possibly add or remove MerchantRecipes.
 */
public void modifyMerchantRecipeList(MerchantRecipeList recipeList, Random random)
{
    Enchantment enchantment = (Enchantment)Enchantment.REGISTRY.getRandomObject(random);
    int i = MathHelper.getRandomIntegerInRange(random, enchantment.getMinLevel(), enchantment.getMaxLevel());
    ItemStack itemstack = Items.ENCHANTED_BOOK.getEnchantedItemStack(new EnchantmentData(enchantment, i));
    int j = 2 + random.nextInt(5 + i * 10) + 3 * i;

    if (enchantment.isTreasureEnchantment())
    {
        j *= 2;
    }

    if (j > 64)
    {
        j = 64;
    }

    recipeList.add(new MerchantRecipe(new ItemStack(Items.BOOK), new ItemStack(Items.EMERALD, j), itemstack));
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:23,代碼來源:EntityVillager.java

示例6: serializeNBT

import net.minecraft.village.MerchantRecipeList; //導入依賴的package包/類
@Override
public NBTTagCompound serializeNBT() {
	NBTTagCompound nbt=new NBTTagCompound();
	nbt.setInteger("Event", eventFlag);
	NBTTagCompound items=new NBTTagCompound();
	nbt.setTag("Items", items);
	NBTTagList bannersS = new NBTTagList();
	for(BlockPos pos:banners){
		
		NBTTagList coords = new NBTTagList();
		coords.appendTag(new NBTTagInt(pos.getX()));
		coords.appendTag(new NBTTagInt(pos.getY()));
		coords.appendTag(new NBTTagInt(pos.getZ()));
		bannersS.appendTag(coords);
	}
	nbt.setTag("Banners", bannersS);
	for(Entry<String,MerchantRecipeList> entry:lostItems.entrySet()){
		items.setTag(entry.getKey(), entry.getValue().getRecipiesAsTags());
	}
	return nbt;
}
 
開發者ID:rafradek,項目名稱:Mods,代碼行數:22,代碼來源:TF2EventsCommon.java

示例7: displayVillagerTradeGui

import net.minecraft.village.MerchantRecipeList; //導入依賴的package包/類
public void displayVillagerTradeGui(IMerchant villager)
{
    this.getNextWindowId();
    this.openContainer = new ContainerMerchant(this.inventory, villager, this.world);
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.addListener(this);
    IInventory iinventory = ((ContainerMerchant)this.openContainer).getMerchantInventory();
    ITextComponent itextcomponent = villager.getDisplayName();
    this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, "minecraft:villager", itextcomponent, iinventory.getSizeInventory()));
    MerchantRecipeList merchantrecipelist = villager.getRecipes(this);

    if (merchantrecipelist != null)
    {
        PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
        packetbuffer.writeInt(this.currentWindowId);
        merchantrecipelist.writeToBuf(packetbuffer);
        this.connection.sendPacket(new SPacketCustomPayload("MC|TrList", packetbuffer));
    }
}
 
開發者ID:NSExceptional,項目名稱:Zombe-Modpack,代碼行數:20,代碼來源:EntityPlayerMP.java

示例8: func_190888_a

import net.minecraft.village.MerchantRecipeList; //導入依賴的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));
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:20,代碼來源:EntityVillager.java

示例9: populateBuyingList

import net.minecraft.village.MerchantRecipeList; //導入依賴的package包/類
private void populateBuyingList()
{
    if (this.careerId != 0 && this.careerLevel != 0)
    {
        ++this.careerLevel;
    }
    else
    {
        this.careerId = this.getProfessionForge().getRandomCareer(this.rand) + 1;
        this.careerLevel = 1;
    }

    if (this.buyingList == null)
    {
        this.buyingList = new MerchantRecipeList();
    }

    int i = this.careerId - 1;
    int j = this.careerLevel - 1;
    java.util.List<EntityVillager.ITradeList> trades = this.getProfessionForge().getCareer(i).getTrades(j);

    if (trades != null)
    {
        for (EntityVillager.ITradeList entityvillager$itradelist : trades)
        {
            entityvillager$itradelist.modifyMerchantRecipeList(this.buyingList, this.rand);
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:30,代碼來源:EntityVillager.java

示例10: update

import net.minecraft.village.MerchantRecipeList; //導入依賴的package包/類
public void update()
{
    if(merchant.getCustomer() == null)
        return;
    InventoryMerchant inventory = container.getMerchantInventory();
    ItemStack firstStack = inventory.getStackInSlot(0);
    ItemStack secondStack = inventory.getStackInSlot(1);
    MerchantRecipeList currentList = merchant.getRecipes(merchant.getCustomer());
    if(currentList != replacedList && currentList != defaultList) {
        defaultList = currentList; //We have a new default list, mark dirty so we generate a new replacement
        dirty = true;
    }
    if(firstStack.getItem() == Registry.SIGNET_ANTIMONY || secondStack.getItem() == Registry.SIGNET_ANTIMONY)
    {
        if(dirty) {
            replacedList = generateReplacement(defaultList);
            dirty = false;
        }
        if(currentList != replacedList) {
            replaceList(merchant, replacedList);
            container.getMerchantInventory().resetRecipeAndSlots();
        }
    }
    else
    {
        if(currentList != defaultList) {
            replaceList(merchant, defaultList);
            container.getMerchantInventory().resetRecipeAndSlots();
        }
    }
}
 
開發者ID:DaedalusGame,項目名稱:Soot,代碼行數:32,代碼來源:VillagerAntimonyHandler.java

示例11: replaceList

import net.minecraft.village.MerchantRecipeList; //導入依賴的package包/類
public void replaceList(IMerchant merchant, MerchantRecipeList list)
{
    if(merchant instanceof EntityVillager)
    {
        replaceTradeList((EntityVillager) merchant,list);
    }
    else
    {
        merchant.setRecipes(list);
    }
}
 
開發者ID:DaedalusGame,項目名稱:Soot,代碼行數:12,代碼來源:VillagerAntimonyHandler.java

示例12: protectedUpdate

import net.minecraft.village.MerchantRecipeList; //導入依賴的package包/類
@Override
public void protectedUpdate() {
    super.protectedUpdate();
    if (!villager.getStackInSlot(0).isEmpty() && villager.getStackInSlot(0).getTagCompound().hasKey("Offers")) {
        merchantRecipes = new MerchantRecipeList(villager.getStackInSlot(0).getTagCompound().getCompoundTag("Offers"));
        merchantRecipes.removeIf(MerchantRecipe::hasSecondItemToBuy); // TODO this is a temporary fix until we add actual support for trades with 2 items (#77)
    } else {
        merchantRecipes = null;
        current = 0;
    }
}
 
開發者ID:Buuz135,項目名稱:Industrial-Foregoing,代碼行數:12,代碼來源:VillagerTradeExchangerTile.java

示例13: addMerchantRecipe

import net.minecraft.village.MerchantRecipeList; //導入依賴的package包/類
@Override
public void addMerchantRecipe(IMerchant merchant, MerchantRecipeList recipeList, Random random)
{
	int buyingPrice = this.buyingPriceInfo.getPrice(random);
	int sellingPrice = this.sellingPriceInfo.getPrice(random);

	ItemStack buying = buyingItemStack.copy();
	buying.setCount(buyingPrice);

	ItemStack selling = sellingItemStack.copy();
	selling.setCount(sellingPrice);

	MerchantRecipe tradeRecipe = new MerchantRecipe(buying, selling);
	recipeList.add(tradeRecipe);
}
 
開發者ID:DarkMorford,項目名稱:BetterThanWeagles,代碼行數:16,代碼來源:VillagerTradeItemForItem.java

示例14: readEntityFromNBT

import net.minecraft.village.MerchantRecipeList; //導入依賴的package包/類
/**
 * (abstract) Protected helper method to read subclass entity data from NBT.
 */
public void readEntityFromNBT(NBTTagCompound tagCompund)
{
    super.readEntityFromNBT(tagCompund);
    this.setProfession(tagCompund.getInteger("Profession"));
    this.wealth = tagCompund.getInteger("Riches");
    this.careerId = tagCompund.getInteger("Career");
    this.careerLevel = tagCompund.getInteger("CareerLevel");
    this.isWillingToMate = tagCompund.getBoolean("Willing");

    if (tagCompund.hasKey("Offers", 10))
    {
        NBTTagCompound nbttagcompound = tagCompund.getCompoundTag("Offers");
        this.buyingList = new MerchantRecipeList(nbttagcompound);
    }

    NBTTagList nbttaglist = tagCompund.getTagList("Inventory", 10);

    for (int i = 0; i < nbttaglist.tagCount(); ++i)
    {
        ItemStack itemstack = ItemStack.loadItemStackFromNBT(nbttaglist.getCompoundTagAt(i));

        if (itemstack != null)
        {
            this.villagerInventory.func_174894_a(itemstack);
        }
    }

    this.setCanPickUpLoot(true);
    this.setAdditionalAItasks();
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:34,代碼來源:EntityVillager.java

示例15: getRecipes

import net.minecraft.village.MerchantRecipeList; //導入依賴的package包/類
@Override
public MerchantRecipeList getRecipes(EntityPlayer player) {
	// TODO Auto-generated method stub
	if (this.tradeOffers == null)
		makeOffers();
	return tradeOffers;
}
 
開發者ID:rafradek,項目名稱:Mods,代碼行數:8,代碼來源:EntityTF2Character.java


注:本文中的net.minecraft.village.MerchantRecipeList類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。