本文整理汇总了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");
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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();
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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");
}
}
示例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");
}
}
示例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;
}
}
示例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();
}
示例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);
}
}
}
}
示例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);
}
示例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);
}
}
示例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");
}