当前位置: 首页>>代码示例>>Java>>正文


Java InventoryBasic.setInventorySlotContents方法代码示例

本文整理汇总了Java中net.minecraft.inventory.InventoryBasic.setInventorySlotContents方法的典型用法代码示例。如果您正苦于以下问题:Java InventoryBasic.setInventorySlotContents方法的具体用法?Java InventoryBasic.setInventorySlotContents怎么用?Java InventoryBasic.setInventorySlotContents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.inventory.InventoryBasic的用法示例。


在下文中一共展示了InventoryBasic.setInventorySlotContents方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readInventoryFromNBT

import net.minecraft.inventory.InventoryBasic; //导入方法依赖的package包/类
/**
 * Reads an inventory from an NBTTagCompound. Can be used to load an Inventory from a
 * TileEntity or perhaps an ItemStak.
 *
 * @param tag: The NBTTagCompound to read the inventory data from.
 * @param inventory: The inventory to set all of the inventory data to.
 * @return InventoryBasic: The same instance of InventoryBasic that was passed to this
 *         method.
 */
public static InventoryBasic readInventoryFromNBT (NBTTagCompound tag, InventoryBasic inventory) {

    if (tag.hasKey("CustomName", 8)) {
        inventory.setCustomName(tag.getString("CustomName"));
    }

    final NBTTagList items = tag.getTagList("Items", 10);

    for (int storedCount = 0; storedCount < items.tagCount(); storedCount++) {

        final NBTTagCompound itemTag = items.getCompoundTagAt(storedCount);
        final int slotCount = itemTag.getByte("Slot") & 0xFF;

        if (slotCount >= 0 && slotCount < inventory.getSizeInventory()) {
            inventory.setInventorySlotContents(slotCount, new ItemStack(itemTag));
        }
    }

    return inventory;
}
 
开发者ID:Darkhax-Minecraft,项目名称:Bookshelf,代码行数:30,代码来源:NBTUtils.java

示例2: countPossibleRecipes

import net.minecraft.inventory.InventoryBasic; //导入方法依赖的package包/类
public int countPossibleRecipes(IInventory inventory)
{
	InventoryBasic basic = new InventoryBasic("basic", false, inventory.getSizeInventory());
	for (int i = 0; i < basic.getSizeInventory(); i++) 
		if(inventory.getStackInSlot(i) != null)
			basic.setInventorySlotContents(i, inventory.getStackInSlot(i).copy());
	
	searched.clear();
	
	ArrayList<RecipeOverflow> overflow = new ArrayList<RecipeOverflow>();
	int ammount = 0;
	ConsumeResult result = consumeRecipe(basic, input, overflow, new SearchLimiter());
	while(result != null)
	{
		overflow.addAll(result.overflow);
		ammount++;
		result = consumeRecipe(basic, input, overflow, new SearchLimiter());
		searched.clear();
	}
	
	searched.clear();
	
	return ammount;
}
 
开发者ID:CreativeMD,项目名称:HandCraft,代码行数:25,代码来源:HandRecipe.java

示例3: addToInventory

import net.minecraft.inventory.InventoryBasic; //导入方法依赖的package包/类
public static void addToInventory(ItemStack itemStack, InventoryBasic inventory) {
    if (itemStack != null && itemStack.stackSize != 0 && itemStack.getItem() != null) {
        int emptySlot = getFirstEmptyStack(inventory);

        if (itemStack.isItemDamaged()) {
            if (emptySlot > -1) {
                inventory.setInventorySlotContents(emptySlot, itemStack);
            }
        }
        else {
            int compatibleSlot = getExistingCompatibleStack(itemStack, inventory);
            if (compatibleSlot > -1) {
                ItemStack existingStack = inventory.getStackInSlot(compatibleSlot);
                existingStack.stackSize += itemStack.stackSize;
            }
            else if (emptySlot > -1) {
                inventory.setInventorySlotContents(emptySlot, itemStack);
            }
        }
    }
}
 
开发者ID:civilframe,项目名称:TameHumans,代码行数:22,代码来源:InventoryUtils.java

示例4: readInventoryBasicFromNBT

import net.minecraft.inventory.InventoryBasic; //导入方法依赖的package包/类
public static NBTTagCompound readInventoryBasicFromNBT(final NBTTagCompound tag, final InventoryBasic inventoryBasic) {
    if (tag.hasKey("CustomName", 8)) {
        inventoryBasic.func_110133_a(tag.getString("CustomName"));
    }
    final NBTTagList items = tag.getTagList("Items", 10);
    for (int i = 0; i < items.tagCount(); ++i) {
        final NBTTagCompound itemTag = items.getCompoundTagAt(i);
        final int j = itemTag.getByte("Slot") & 0xFF;
        if (j >= 0 && j < inventoryBasic.getSizeInventory()) {
            inventoryBasic.setInventorySlotContents(j, ItemStack.loadItemStackFromNBT(itemTag));
        }
    }
    return tag;
}
 
开发者ID:sameer,项目名称:ExtraUtilities,代码行数:15,代码来源:XUHelper.java

示例5: getSavedBaubles

import net.minecraft.inventory.InventoryBasic; //导入方法依赖的package包/类
public static IInventory getSavedBaubles(NBTTagCompound compound, IBaublesItemHandler baubles)
{
    InventoryBasic basic = new InventoryBasic("SavedBaubles", false, baubles.getSlots());

    NBTTagList tagList = compound.getTagList(BAUBLES_NBT, 10);

    for (int i=0; i < tagList.tagCount(); i++)
    {
        NBTTagCompound slot = (NBTTagCompound)tagList.get(i);
        basic.setInventorySlotContents(slot.getInteger("Slot"), ItemStack.loadItemStackFromNBT(slot));
    }

    return basic;
}
 
开发者ID:M4thG33k,项目名称:TombManyGraves,代码行数:15,代码来源:BaubleHandler.java

示例6: getCurrentBaubles

import net.minecraft.inventory.InventoryBasic; //导入方法依赖的package包/类
public static IInventory getCurrentBaubles(IBaublesItemHandler baubles)
{
    InventoryBasic basic = new InventoryBasic("CurrentBaubles", false, baubles.getSlots());

    for (int i=0; i < basic.getSizeInventory(); i++)
    {
        basic.setInventorySlotContents(i, baubles.getStackInSlot(i));
    }

    return basic;
}
 
开发者ID:M4thG33k,项目名称:TombManyGraves,代码行数:12,代码来源:BaubleHandler.java

示例7: readInventoryFromNBT

import net.minecraft.inventory.InventoryBasic; //导入方法依赖的package包/类
/**
 * Reads an inventory from an NBTTagCompound. Can be used to load an Inventory from a
 * TileEntity or perhaps an ItemStak.
 *
 * @param tag: The NBTTagCompound to read the inventory data from.
 * @param inventory: The inventory to set all of the inventory data to.
 * @return InventoryBasic: The same instance of InventoryBasic that was passed to this
 *         method.
 */
public static InventoryBasic readInventoryFromNBT (NBTTagCompound tag, InventoryBasic inventory) {
    if (tag.hasKey("CustomName", 8))
        inventory.setCustomName(tag.getString("CustomName"));
    final NBTTagList items = tag.getTagList("Items", 10);
    for (int storedCount = 0; storedCount < items.tagCount(); storedCount++) {
        final NBTTagCompound itemTag = items.getCompoundTagAt(storedCount);
        final int slotCount = itemTag.getByte("Slot") & 0xFF;
        if (slotCount >= 0 && slotCount < inventory.getSizeInventory())
            inventory.setInventorySlotContents(slotCount, ItemStack.loadItemStackFromNBT(itemTag));
    }
    return inventory;
}
 
开发者ID:MinecraftModDevelopmentMods,项目名称:MMDLib-old,代码行数:22,代码来源:NBTUtils.java

示例8: openPotionGui

import net.minecraft.inventory.InventoryBasic; //导入方法依赖的package包/类
private void openPotionGui(EntityPlayerMP player, PacketCustom packet) {
    InventoryBasic b = new InventoryBasic("potionStore", true, 9);
    for (int i = 0; i < b.getSizeInventory(); i++) {
        b.setInventorySlotContents(i, packet.readItemStack());
    }
    ServerUtils.openSMPContainer(player, new ContainerPotionCreator(player.inventory, b), (player1, windowId) -> {
        PacketCustom packet1 = new PacketCustom(channel, 24);
        packet1.writeByte(windowId);
        packet1.sendToPlayer(player1);
    });
}
 
开发者ID:TheCBProject,项目名称:NotEnoughItems,代码行数:12,代码来源:NEIServerPacketHandler.java

示例9: getReadOnly

import net.minecraft.inventory.InventoryBasic; //导入方法依赖的package包/类
public InventoryBasic getReadOnly() {
    final InventoryBasic clone = new InventoryBasic(this.getName(), true, this.getSizeInventory());
    for (int i = 0; i < this.getSizeInventory(); i++) {
        clone.setInventorySlotContents(i, this.getStackInSlot(i));
    }
    return clone;
}
 
开发者ID:AlmuraDev,项目名称:Backpack,代码行数:8,代码来源:BackpackInventory.java

示例10: readFromNBT

import net.minecraft.inventory.InventoryBasic; //导入方法依赖的package包/类
public static void readFromNBT(NBTTagCompound ntb, InventoryBasic inventory) {
    NBTTagList nbtTagList = ntb.getTagList(NTB_INVENTORY_TAG, 10);

    for (int i = 0; i < nbtTagList.tagCount(); ++i) {
        NBTTagCompound ntbItem = nbtTagList.getCompoundTagAt(i);
        int j = ntbItem.getByte("Slot") & 255;

        if (j >= 0 && j < inventory.getSizeInventory()) {
            inventory.setInventorySlotContents(j, ItemStack.loadItemStackFromNBT(ntbItem));
        }
    }
}
 
开发者ID:civilframe,项目名称:TameHumans,代码行数:13,代码来源:InventoryUtils.java

示例11: ContainerSkills

import net.minecraft.inventory.InventoryBasic; //导入方法依赖的package包/类
public ContainerSkills(EntityPlayer player) {
	ZSSPlayerSkills skills = ZSSPlayerSkills.get(player);
	inventory = new InventoryBasic("", true, SkillBase.getNumSkills());
	boolean flag = false;
	int x, y, i1;

	for (SkillBase skill : SkillBase.getSkills()) {
		if (skills.hasSkill(skill)) {
			inventory.setInventorySlotContents(skill.getId(), new ItemStack(ZSSItems.skillOrb, 1, skill.getId()));
		}
	}

	addSlotToContainer(new Slot(inventory, 0, 65, 141));

	for (int i = 1; i < inventory.getSizeInventory(); ++i) {
		if (i == SkillBase.bonusHeart.getId()) {
			flag = true;
			continue;
		}

		int bottom = 3;
		int sideBar = 5;
		int rightSide = bottom + sideBar;
		i1 = (flag ? i - 1 : i);
		if (i1 > bottom) {
			x = (i1 > rightSide ? 108 : 22);
			y = 120 - (i1 > rightSide ? (i1 - (rightSide + 1)) : (i1 - (sideBar - 1))) * 21;
		} else {
			x = 44 + (i1 - 1) * 21;
			y = 120;
		}

		addSlotToContainer(new Slot(inventory, i, x, y));
	}
}
 
开发者ID:coolAlias,项目名称:ZeldaSwordSkills,代码行数:36,代码来源:ContainerSkills.java

示例12: tagToInventory

import net.minecraft.inventory.InventoryBasic; //导入方法依赖的package包/类
/**
 * NBTからInventoryBasicに書き出し
 * @param tag 読み出すNBT
 * @param inv 書き出すInventoryBasic
 * @return 書き込まれたスロットの合計
 */
public static int tagToInventory(NBTTagList tag, InventoryBasic inv)
{
	int elements = inv.getSizeInventory();
	ItemStack[] _inv = new ItemStack[elements];
	int e = VillagerData.tagToInventory(tag, _inv);
	for(int i = 0; i < elements; i++)
	{
		inv.setInventorySlotContents(i, _inv[i]);
	}
	return e;
}
 
开发者ID:a1lic,项目名称:McMod-CubicVillager,代码行数:18,代码来源:VillagerData.java

示例13: updateTask

import net.minecraft.inventory.InventoryBasic; //导入方法依赖的package包/类
/**
 * Updates the task
 */
public void updateTask()
{
    super.updateTask();
    this.theVillager.getLookHelper().setLookPosition((double)this.destinationBlock.getX() + 0.5D, (double)(this.destinationBlock.getY() + 1), (double)this.destinationBlock.getZ() + 0.5D, 10.0F, (float)this.theVillager.getVerticalFaceSpeed());

    if (this.getIsAboveDestination())
    {
        World world = this.theVillager.worldObj;
        BlockPos blockpos = this.destinationBlock.up();
        IBlockState iblockstate = world.getBlockState(blockpos);
        Block block = iblockstate.getBlock();

        if (this.field_179501_f == 0 && block instanceof BlockCrops && ((Integer)iblockstate.getValue(BlockCrops.AGE)).intValue() == 7)
        {
            world.destroyBlock(blockpos, true);
        }
        else if (this.field_179501_f == 1 && block == Blocks.air)
        {
            InventoryBasic inventorybasic = this.theVillager.getVillagerInventory();

            for (int i = 0; i < inventorybasic.getSizeInventory(); ++i)
            {
                ItemStack itemstack = inventorybasic.getStackInSlot(i);
                boolean flag = false;

                if (itemstack != null)
                {
                    if (itemstack.getItem() == Items.wheat_seeds)
                    {
                        world.setBlockState(blockpos, Blocks.wheat.getDefaultState(), 3);
                        flag = true;
                    }
                    else if (itemstack.getItem() == Items.potato)
                    {
                        world.setBlockState(blockpos, Blocks.potatoes.getDefaultState(), 3);
                        flag = true;
                    }
                    else if (itemstack.getItem() == Items.carrot)
                    {
                        world.setBlockState(blockpos, Blocks.carrots.getDefaultState(), 3);
                        flag = true;
                    }
                }

                if (flag)
                {
                    --itemstack.stackSize;

                    if (itemstack.stackSize <= 0)
                    {
                        inventorybasic.setInventorySlotContents(i, (ItemStack)null);
                    }

                    break;
                }
            }
        }

        this.field_179501_f = -1;
        this.runDelay = 10;
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:66,代码来源:EntityAIHarvestFarmland.java

示例14: updateTask

import net.minecraft.inventory.InventoryBasic; //导入方法依赖的package包/类
/**
 * Updates the task
 */
public void updateTask()
{
    super.updateTask();
    this.theVillager.getLookHelper().setLookPosition((double)this.destinationBlock.getX() + 0.5D, (double)(this.destinationBlock.getY() + 1), (double)this.destinationBlock.getZ() + 0.5D, 10.0F, (float)this.theVillager.getVerticalFaceSpeed());

    if (this.getIsAboveDestination())
    {
        World world = this.theVillager.world;
        BlockPos blockpos = this.destinationBlock.up();
        IBlockState iblockstate = world.getBlockState(blockpos);
        Block block = iblockstate.getBlock();

        if (this.currentTask == 0 && block instanceof BlockCrops && ((BlockCrops)block).isMaxAge(iblockstate))
        {
            world.destroyBlock(blockpos, true);
        }
        else if (this.currentTask == 1 && iblockstate.getMaterial() == Material.AIR)
        {
            InventoryBasic inventorybasic = this.theVillager.getVillagerInventory();

            for (int i = 0; i < inventorybasic.getSizeInventory(); ++i)
            {
                ItemStack itemstack = inventorybasic.getStackInSlot(i);
                boolean flag = false;

                if (!itemstack.func_190926_b())
                {
                    if (itemstack.getItem() == Items.WHEAT_SEEDS)
                    {
                        world.setBlockState(blockpos, Blocks.WHEAT.getDefaultState(), 3);
                        flag = true;
                    }
                    else if (itemstack.getItem() == Items.POTATO)
                    {
                        world.setBlockState(blockpos, Blocks.POTATOES.getDefaultState(), 3);
                        flag = true;
                    }
                    else if (itemstack.getItem() == Items.CARROT)
                    {
                        world.setBlockState(blockpos, Blocks.CARROTS.getDefaultState(), 3);
                        flag = true;
                    }
                    else if (itemstack.getItem() == Items.BEETROOT_SEEDS)
                    {
                        world.setBlockState(blockpos, Blocks.BEETROOTS.getDefaultState(), 3);
                        flag = true;
                    }
                }

                if (flag)
                {
                    itemstack.func_190918_g(1);

                    if (itemstack.func_190926_b())
                    {
                        inventorybasic.setInventorySlotContents(i, ItemStack.field_190927_a);
                    }

                    break;
                }
            }
        }

        this.currentTask = -1;
        this.runDelay = 10;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:71,代码来源:EntityAIHarvestFarmland.java

示例15: updateTask

import net.minecraft.inventory.InventoryBasic; //导入方法依赖的package包/类
/**
 * Updates the task
 */
public void updateTask()
{
    super.updateTask();
    this.theVillager.getLookHelper().setLookPosition((double)this.destinationBlock.getX() + 0.5D, (double)(this.destinationBlock.getY() + 1), (double)this.destinationBlock.getZ() + 0.5D, 10.0F, (float)this.theVillager.getVerticalFaceSpeed());

    if (this.getIsAboveDestination())
    {
        World world = this.theVillager.worldObj;
        BlockPos blockpos = this.destinationBlock.up();
        IBlockState iblockstate = world.getBlockState(blockpos);
        Block block = iblockstate.getBlock();

        if (this.currentTask == 0 && block instanceof BlockCrops && ((BlockCrops)block).isMaxAge(iblockstate))
        {
            world.destroyBlock(blockpos, true);
        }
        else if (this.currentTask == 1 && iblockstate.getMaterial() == Material.AIR)
        {
            InventoryBasic inventorybasic = this.theVillager.getVillagerInventory();

            for (int i = 0; i < inventorybasic.getSizeInventory(); ++i)
            {
                ItemStack itemstack = inventorybasic.getStackInSlot(i);
                boolean flag = false;

                if (itemstack != null)
                {
                    if (itemstack.getItem() == Items.WHEAT_SEEDS)
                    {
                        world.setBlockState(blockpos, Blocks.WHEAT.getDefaultState(), 3);
                        flag = true;
                    }
                    else if (itemstack.getItem() == Items.POTATO)
                    {
                        world.setBlockState(blockpos, Blocks.POTATOES.getDefaultState(), 3);
                        flag = true;
                    }
                    else if (itemstack.getItem() == Items.CARROT)
                    {
                        world.setBlockState(blockpos, Blocks.CARROTS.getDefaultState(), 3);
                        flag = true;
                    }
                    else if (itemstack.getItem() == Items.BEETROOT_SEEDS)
                    {
                        world.setBlockState(blockpos, Blocks.BEETROOTS.getDefaultState(), 3);
                        flag = true;
                    }
                }

                if (flag)
                {
                    --itemstack.stackSize;

                    if (itemstack.stackSize <= 0)
                    {
                        inventorybasic.setInventorySlotContents(i, (ItemStack)null);
                    }

                    break;
                }
            }
        }

        this.currentTask = -1;
        this.runDelay = 10;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:71,代码来源:EntityAIHarvestFarmland.java


注:本文中的net.minecraft.inventory.InventoryBasic.setInventorySlotContents方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。