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


Java ItemStack.loadItemStackFromNBT方法代码示例

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


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

示例1: readFromNBT

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public void readFromNBT(NBTTagCompound compound)
{
    super.readFromNBT(compound);
    NBTTagList nbttaglist = compound.getTagList("Items", 10);
    this.brewingItemStacks = new ItemStack[this.getSizeInventory()];

    for (int i = 0; i < nbttaglist.tagCount(); ++i)
    {
        NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);
        int j = nbttagcompound.getByte("Slot");

        if (j >= 0 && j < this.brewingItemStacks.length)
        {
            this.brewingItemStacks[j] = ItemStack.loadItemStackFromNBT(nbttagcompound);
        }
    }

    this.brewTime = compound.getShort("BrewTime");

    if (compound.hasKey("CustomName", 8))
    {
        this.customName = compound.getString("CustomName");
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:25,代码来源:TileEntityBrewingStand.java

示例2: readEntityFromNBT

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
 * (abstract) Protected helper method to read subclass entity data from NBT.
 */
public void readEntityFromNBT(NBTTagCompound tagCompund)
{
    this.fireworkAge = tagCompund.getInteger("Life");
    this.lifetime = tagCompund.getInteger("LifeTime");
    NBTTagCompound nbttagcompound = tagCompund.getCompoundTag("FireworksItem");

    if (nbttagcompound != null)
    {
        ItemStack itemstack = ItemStack.loadItemStackFromNBT(nbttagcompound);

        if (itemstack != null)
        {
            this.dataWatcher.updateObject(8, itemstack);
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:20,代码来源:EntityFireworkRocket.java

示例3: readEntityFromNBT

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
 * (abstract) Protected helper method to read subclass entity data from NBT.
 */
protected void readEntityFromNBT(NBTTagCompound tagCompund)
{
    super.readEntityFromNBT(tagCompund);
    NBTTagList nbttaglist = tagCompund.getTagList("Items", 10);
    this.minecartContainerItems = new ItemStack[this.getSizeInventory()];

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

        if (j >= 0 && j < this.minecartContainerItems.length)
        {
            this.minecartContainerItems[j] = ItemStack.loadItemStackFromNBT(nbttagcompound);
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:21,代码来源:EntityMinecartContainer.java

示例4: readEntityFromNBT

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
 * (abstract) Protected helper method to read subclass entity data from NBT.
 */
public void readEntityFromNBT(NBTTagCompound tagCompund)
{
    super.readEntityFromNBT(tagCompund);

    if (tagCompund.hasKey("Potion", 10))
    {
        this.potionDamage = ItemStack.loadItemStackFromNBT(tagCompund.getCompoundTag("Potion"));
    }
    else
    {
        this.setPotionDamage(tagCompund.getInteger("potionValue"));
    }

    if (this.potionDamage == null)
    {
        this.setDead();
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:22,代码来源:EntityPotion.java

示例5: readFromNBT

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public void readFromNBT(NBTTagCompound compound)
{
    super.readFromNBT(compound);
    NBTTagList nbttaglist = compound.getTagList("Items", 10);
    this.chestContents = new ItemStack[this.getSizeInventory()];

    if (compound.hasKey("CustomName", 8))
    {
        this.customName = compound.getString("CustomName");
    }

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

        if (j >= 0 && j < this.chestContents.length)
        {
            this.chestContents[j] = ItemStack.loadItemStackFromNBT(nbttagcompound);
        }
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:23,代码来源:TileEntityChest.java

示例6: readFromNBT

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public void readFromNBT(NBTTagCompound compound)
{
    super.readFromNBT(compound);
    NBTTagList nbttaglist = compound.getTagList("Items", 10);
    this.inventory = new ItemStack[this.getSizeInventory()];

    if (compound.hasKey("CustomName", 8))
    {
        this.customName = compound.getString("CustomName");
    }

    this.transferCooldown = compound.getInteger("TransferCooldown");

    for (int i = 0; i < nbttaglist.tagCount(); ++i)
    {
        NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);
        int j = nbttagcompound.getByte("Slot");

        if (j >= 0 && j < this.inventory.length)
        {
            this.inventory[j] = ItemStack.loadItemStackFromNBT(nbttagcompound);
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:25,代码来源:TileEntityHopper.java

示例7: readFromNBT

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public void readFromNBT(NBTTagCompound tagCompound) {
	super.readFromNBT(tagCompound);
	NBTTagList tagList = tagCompound.getTagList("Items", 10);
	machineItemStacks = new ItemStack[getSizeInventory()];

	for(int i = 0; i < tagList.tagCount(); ++i) {
		NBTTagCompound tagCompund1 = tagList.getCompoundTagAt(i);
		byte b = tagCompund1.getByte("Slot");
		if(b >= 0 && b < machineItemStacks.length)
			machineItemStacks[b] = ItemStack.loadItemStackFromNBT(tagCompund1);
	}
	machineBurnTime = tagCompound.getShort("BurnTime");
	machineCookTime = tagCompound.getShort("CookTime");
	if(getItemBurnTimeElectrical(machineItemStacks[3]) != 0)
		currentBurnTime = getItemBurnTimeElectrical(machineItemStacks[3]);
	else
		currentBurnTime = getItemBurnTimeBurning(machineItemStacks[4]);

	if(tagCompound.hasKey("CustomName", 8)) {
		machineName = tagCompound.getString("CustomName");
	}
}
 
开发者ID:viddeno,项目名称:Technical,代码行数:23,代码来源:TileEntityMachine.java

示例8: readFromNBT

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public void readFromNBT(NBTTagCompound tagCompound) {
	super.tileEntityReadFromNBT(tagCompound);
	NBTTagList tagList = tagCompound.getTagList("Items", getSizeInventory());
	machineItemStacks = new ItemStack[getSizeInventory()];

	for(int i = 0; i < tagList.tagCount(); ++i) {
		NBTTagCompound tagCompund1 = tagList.getCompoundTagAt(i);
		byte b = tagCompund1.getByte("Slot");
		if(b >= 0 && b < machineItemStacks.length)
			machineItemStacks[b] = ItemStack.loadItemStackFromNBT(tagCompund1);
	}
	machineBurnTime = tagCompound.getShort("BurnTime");
	machineCookTime = tagCompound.getShort("CookTime");
	if(getItemBurnTimeElectrical(machineItemStacks[1]) != 1)
		currentBurnTime = getItemBurnTimeElectrical(machineItemStacks[1]);
	else if(getItemBurnTimeElectrical(machineItemStacks[2]) != 2)
		currentBurnTime = getItemBurnTimeElectrical(machineItemStacks[2]);
	else if(getItemBurnTimeElectrical(machineItemStacks[3]) != 3)
		currentBurnTime = getItemBurnTimeElectrical(machineItemStacks[3]);
	else if(getItemBurnTimeElectrical(machineItemStacks[4]) != 4)
		currentBurnTime = getItemBurnTimeElectrical(machineItemStacks[4]);
	else if(getItemBurnTimeBurning(machineItemStacks[1]) != 1)
		currentBurnTime = getItemBurnTimeBurning(machineItemStacks[1]);
	else if(getItemBurnTimeBurning(machineItemStacks[2]) != 2)
		currentBurnTime = getItemBurnTimeBurning(machineItemStacks[2]);
	else if(getItemBurnTimeBurning(machineItemStacks[3]) != 3)
		currentBurnTime = getItemBurnTimeBurning(machineItemStacks[3]);
	else
		currentBurnTime = getItemBurnTimeBurning(machineItemStacks[4]);

	miningAtX = tagCompound.getInteger("MiningAtX");
	miningAtY = tagCompound.getInteger("MiningAtY");
	miningAtZ = tagCompound.getInteger("MiningAtZ");
	gottenOres = tagCompound.getInteger("GottenOres");
	finnished = tagCompound.getBoolean("Finnished");

	if(tagCompound.hasKey("CustomName", 8)) {
		machineName = tagCompound.getString("CustomName");
	}
}
 
开发者ID:viddeno,项目名称:Technical,代码行数:41,代码来源:TileEntityMachineMiner.java

示例9: readFromTags

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public void readFromTags(NBTTagCompound tagCompound)
{
    NBTTagCompound nbttagcompound = tagCompound.getCompoundTag("buy");
    this.itemToBuy = ItemStack.loadItemStackFromNBT(nbttagcompound);
    NBTTagCompound nbttagcompound1 = tagCompound.getCompoundTag("sell");
    this.itemToSell = ItemStack.loadItemStackFromNBT(nbttagcompound1);

    if (tagCompound.hasKey("buyB", 10))
    {
        this.secondItemToBuy = ItemStack.loadItemStackFromNBT(tagCompound.getCompoundTag("buyB"));
    }

    if (tagCompound.hasKey("uses", 99))
    {
        this.toolUses = tagCompound.getInteger("uses");
    }

    if (tagCompound.hasKey("maxUses", 99))
    {
        this.maxTradeUses = tagCompound.getInteger("maxUses");
    }
    else
    {
        this.maxTradeUses = 7;
    }

    if (tagCompound.hasKey("rewardExp", 1))
    {
        this.rewardsExp = tagCompound.getBoolean("rewardExp");
    }
    else
    {
        this.rewardsExp = true;
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:36,代码来源:MerchantRecipe.java

示例10: readEntityFromNBT

import net.minecraft.item.ItemStack; //导入方法依赖的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:SkidJava,项目名称:BaseClient,代码行数:34,代码来源:EntityVillager.java

示例11: readFromNBT

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public void readFromNBT(NBTTagCompound compound)
{
    super.readFromNBT(compound);
    this.inventory = new ItemStack[this.getSizeInventory()];

    if (compound.hasKey("CustomName", 8))
    {
        this.customName = compound.getString("CustomName");
    }

    this.transferCooldown = compound.getInteger("TransferCooldown");

    if (!this.checkLootAndRead(compound))
    {
        NBTTagList nbttaglist = compound.getTagList("Items", 10);

        for (int i = 0; i < nbttaglist.tagCount(); ++i)
        {
            NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);
            int j = nbttagcompound.getByte("Slot");

            if (j >= 0 && j < this.inventory.length)
            {
                this.inventory[j] = ItemStack.loadItemStackFromNBT(nbttagcompound);
            }
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:29,代码来源:TileEntityHopper.java

示例12: readEntityFromNBT

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
 * (abstract) Protected helper method to read subclass entity data from NBT.
 */
public void readEntityFromNBT(NBTTagCompound tagCompund)
{
    super.readEntityFromNBT(tagCompund);

    if (tagCompund.hasKey("Equipment", 9))
    {
        NBTTagList nbttaglist = tagCompund.getTagList("Equipment", 10);

        for (int i = 0; i < this.contents.length; ++i)
        {
            this.contents[i] = ItemStack.loadItemStackFromNBT(nbttaglist.getCompoundTagAt(i));
        }
    }

    this.setInvisible(tagCompund.getBoolean("Invisible"));
    this.setSmall(tagCompund.getBoolean("Small"));
    this.setShowArms(tagCompund.getBoolean("ShowArms"));
    this.disabledSlots = tagCompund.getInteger("DisabledSlots");
    this.setNoGravity(tagCompund.getBoolean("NoGravity"));
    this.setNoBasePlate(tagCompund.getBoolean("NoBasePlate"));
    this.func_181027_m(tagCompund.getBoolean("Marker"));
    this.field_181028_bj = !this.func_181026_s();
    this.noClip = this.hasNoGravity();
    NBTTagCompound nbttagcompound = tagCompund.getCompoundTag("Pose");
    this.writePoseToNBT(nbttagcompound);
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:30,代码来源:EntityArmorStand.java

示例13: readEntityFromNBT

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
 * (abstract) Protected helper method to read subclass entity data from NBT.
 */
public void readEntityFromNBT(NBTTagCompound compound)
{
    super.readEntityFromNBT(compound);
    ItemStack itemstack = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("Potion"));

    if (itemstack == null)
    {
        this.setDead();
    }
    else
    {
        this.setItem(itemstack);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:18,代码来源:EntityPotion.java

示例14: readEntityFromNBT

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public void readEntityFromNBT(NBTTagCompound tag)
   {
	super.readEntityFromNBT(tag);
	
	if (this.worldObj.isRemote) { return; }	// Not doing the rest on client side
	
	this.ownerName = tag.getString("owner");
	this.movementSpeed = tag.getDouble("movementSpeed");
	
	// Restoring Upgrades
	this.hasArmorUpgrade = tag.getBoolean("hasArmorUpgrade");
	this.hasMobilityUpgrade = tag.getBoolean("hasMobilityUpgrade");
	this.hasStorageUpgrade = tag.getBoolean("hasStorageUpgrade");
	this.hasWeaponUpgrade = tag.getBoolean("hasWeaponUpgrade");
	this.hasRidingUpgrade = tag.getBoolean("hasRidingUpgrade");
	this.hasHeavyPlatingUpgrade = tag.getBoolean("hasHeavyPlatingUpgrade");
	this.hasCommunicationUpgrade = tag.getBoolean("hasCommunicationUpgrade");
	
	this.hasFirstWeapon = tag.getBoolean("hasFirstWeapon");	// Were you holding a weapon before?

	// Restoring the held weapon
	if (this.hasFirstWeapon)
	{
		this.firstWeapon = Main.weapons.get(tag.getInteger("firstWeapon"));
		AI_WeaponHandler.setFirstWeapon(this, new ItemStack(Main.weapons.get(tag.getInteger("firstWeapon"))));
		
		if (this.getHeldItem() != null)
		{
			this.getHeldItem().setItemDamage(tag.getInteger("firstAmmo"));	// restoring known ammo
		}
	}

	if (this.hasStorageUpgrade) { AI_Properties.applyStorageUpgrade(this); }	// Restoring the fact that we've got this (also tells the client about this)
	
	this.hasSecondWeapon = tag.getBoolean("hasSecondWeapon");	// Were you holding a weapon before?
	
	if (this.hasWeaponUpgrade && this.hasSecondWeapon)
	{
		AI_WeaponHandler.setSecondWeapon(this, new ItemStack(Main.weapons.get(tag.getInteger("secondWeapon"))));
		
		if (this.getHeldItem() != null)
		{
			this.getHeldItem().setItemDamage(tag.getInteger("firstAmmo"));	// restoring known ammo
		}
	}
	
	// Restoring items
	if (tag.hasKey("storedItems", 9))
       {
		NBTTagList itemList = tag.getTagList("storedItems", 10);

		int counter = 0;
           
		while (counter < this.storage.length)
        {
               this.storage[counter] = ItemStack.loadItemStackFromNBT(itemList.getCompoundTagAt(counter));
               
               counter += 1;
           }
       }
	
	// Restoring stationary coords, in case we have them
	this.stationaryX = tag.getDouble("stationaryX");
	this.stationaryY = tag.getDouble("stationaryY");
	this.stationaryZ = tag.getDouble("stationaryZ");
   }
 
开发者ID:Domochevsky,项目名称:minecraft-quiverbow,代码行数:68,代码来源:Entity_AA.java


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