本文整理汇总了Java中net.minecraft.item.ItemStack.writeToNBT方法的典型用法代码示例。如果您正苦于以下问题:Java ItemStack.writeToNBT方法的具体用法?Java ItemStack.writeToNBT怎么用?Java ItemStack.writeToNBT使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.item.ItemStack
的用法示例。
在下文中一共展示了ItemStack.writeToNBT方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeEntityToNBT
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound compound)
{
super.writeEntityToNBT(compound);
compound.setBoolean("ChestedHorse", this.func_190695_dh());
if (this.func_190695_dh())
{
NBTTagList nbttaglist = new NBTTagList();
for (int i = 2; i < this.horseChest.getSizeInventory(); ++i)
{
ItemStack itemstack = this.horseChest.getStackInSlot(i);
if (!itemstack.func_190926_b())
{
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setByte("Slot", (byte)i);
itemstack.writeToNBT(nbttagcompound);
nbttaglist.appendTag(nbttagcompound);
}
}
compound.setTag("Items", nbttaglist);
}
}
示例2: serializeNBT
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public NBTTagList serializeNBT() {
NBTTagList list = new NBTTagList();
for (int i = 0; i < this.getSizeInventory(); i++) {
ItemStack itemstack = this.getStackInSlot(i);
if (!itemstack.isEmpty()) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setByte("Slot", (byte) i);
itemstack.writeToNBT(nbttagcompound);
list.appendTag(nbttagcompound);
}
}
// System.out.println("Saving ");
return list;
}
示例3: saveInventoryToNBT
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public NBTTagList saveInventoryToNBT()
{
NBTTagList nbttaglist = new NBTTagList();
for (int i = 0; i < this.getSizeInventory(); ++i)
{
ItemStack itemstack = this.getStackInSlot(i);
if (itemstack != null)
{
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setByte("Slot", (byte)i);
itemstack.writeToNBT(nbttagcompound);
nbttaglist.appendTag(nbttagcompound);
}
}
return nbttaglist;
}
示例4: ItemInfo
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public ItemInfo(int _shopId, int _catId, int mid, int _rating, int cos, String n, int lim, ItemStack data) {
super(_shopId, _catId, mid, _rating);
this.cost = cos;
this.name = n;
this.limit = lim;
this.stack_data = new NBTTagCompound ( ) ;
data.writeToNBT(stack_data);
m_stack = data;
}
示例5: writeItemStack
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public static void writeItemStack(ByteBuf dataOut, ItemStack itemStack) {
PacketBuffer buf = new PacketBuffer(dataOut);
NBTTagCompound nbt = new NBTTagCompound();
itemStack.writeToNBT(nbt);
try {
PacketBufferTools.writeCompoundTag(buf, nbt);
buf.writeInt(ItemStackTools.getStackSize(itemStack));
} catch (Exception e) {
InteractionWheel.logger.log(Level.ERROR, "Error writing item stack", e);
}
}
示例6: writeEntityToNBT
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound tagCompound)
{
tagCompound.setInteger("Life", this.fireworkAge);
tagCompound.setInteger("LifeTime", this.lifetime);
ItemStack itemstack = this.dataWatcher.getWatchableObjectItemStack(8);
if (itemstack != null)
{
NBTTagCompound nbttagcompound = new NBTTagCompound();
itemstack.writeToNBT(nbttagcompound);
tagCompound.setTag("FireworksItem", nbttagcompound);
}
}
示例7: writeToNBT
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public void writeToNBT(NBTTagCompound tag)
{
super.writeToNBT(tag);
// write input stack
ItemStack items = this.getStackInSlot(0);
if(items != null){
NBTTagCompound tinput = new NBTTagCompound();
items.writeToNBT(tinput);
tag.setTag("items", tinput);
}
}
示例8: createCmdBlock
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public void createCmdBlock(String cmd)
{
// generate cmd-block
ItemStack stack = new ItemStack(Blocks.COMMAND_BLOCK);
NBTTagCompound nbtTagCompound = new NBTTagCompound();
nbtTagCompound.setTag("Command", new NBTTagString(cmd));
stack.writeToNBT(nbtTagCompound);
stack.setTagInfo("BlockEntityTag", nbtTagCompound);
// give cmd-block
if(InventoryUtils.placeStackInHotbar(stack))
ChatUtils.message("Command Block created.");
else
ChatUtils.error("Please clear a slot in your hotbar.");
}
示例9: writeEntityToNBT
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound compound)
{
super.writeEntityToNBT(compound);
NBTTagList nbttaglist = new NBTTagList();
for (ItemStack itemstack : this.armorItems)
{
NBTTagCompound nbttagcompound = new NBTTagCompound();
if (!itemstack.func_190926_b())
{
itemstack.writeToNBT(nbttagcompound);
}
nbttaglist.appendTag(nbttagcompound);
}
compound.setTag("ArmorItems", nbttaglist);
NBTTagList nbttaglist1 = new NBTTagList();
for (ItemStack itemstack1 : this.handItems)
{
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
if (!itemstack1.func_190926_b())
{
itemstack1.writeToNBT(nbttagcompound1);
}
nbttaglist1.appendTag(nbttagcompound1);
}
compound.setTag("HandItems", nbttaglist1);
compound.setBoolean("Invisible", this.isInvisible());
compound.setBoolean("Small", this.isSmall());
compound.setBoolean("ShowArms", this.getShowArms());
compound.setInteger("DisabledSlots", this.disabledSlots);
compound.setBoolean("NoBasePlate", this.hasNoBasePlate());
if (this.hasMarker())
{
compound.setBoolean("Marker", this.hasMarker());
}
compound.setTag("Pose", this.readPoseFromNBT());
}
示例10: writeEntityToNBT
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound tagCompound)
{
super.writeEntityToNBT(tagCompound);
tagCompound.setBoolean("EatingHaystack", this.isEatingHaystack());
tagCompound.setBoolean("ChestedHorse", this.isChested());
tagCompound.setBoolean("HasReproduced", this.getHasReproduced());
tagCompound.setBoolean("Bred", this.isBreeding());
tagCompound.setInteger("Type", this.getHorseType());
tagCompound.setInteger("Variant", this.getHorseVariant());
tagCompound.setInteger("Temper", this.getTemper());
tagCompound.setBoolean("Tame", this.isTame());
tagCompound.setString("OwnerUUID", this.getOwnerId());
if (this.isChested())
{
NBTTagList nbttaglist = new NBTTagList();
for (int i = 2; i < this.horseChest.getSizeInventory(); ++i)
{
ItemStack itemstack = this.horseChest.getStackInSlot(i);
if (itemstack != null)
{
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setByte("Slot", (byte)i);
itemstack.writeToNBT(nbttagcompound);
nbttaglist.appendTag(nbttagcompound);
}
}
tagCompound.setTag("Items", nbttaglist);
}
if (this.horseChest.getStackInSlot(1) != null)
{
tagCompound.setTag("ArmorItem", this.horseChest.getStackInSlot(1).writeToNBT(new NBTTagCompound()));
}
if (this.horseChest.getStackInSlot(0) != null)
{
tagCompound.setTag("SaddleItem", this.horseChest.getStackInSlot(0).writeToNBT(new NBTTagCompound()));
}
}
示例11: writeEntityToNBT
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound compound)
{
super.writeEntityToNBT(compound);
NBTTagList nbttaglist = new NBTTagList();
for (ItemStack itemstack : this.armorItems)
{
NBTTagCompound nbttagcompound = new NBTTagCompound();
if (itemstack != null)
{
itemstack.writeToNBT(nbttagcompound);
}
nbttaglist.appendTag(nbttagcompound);
}
compound.setTag("ArmorItems", nbttaglist);
NBTTagList nbttaglist1 = new NBTTagList();
for (ItemStack itemstack1 : this.handItems)
{
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
if (itemstack1 != null)
{
itemstack1.writeToNBT(nbttagcompound1);
}
nbttaglist1.appendTag(nbttagcompound1);
}
compound.setTag("HandItems", nbttaglist1);
if (this.getAlwaysRenderNameTag() && (this.getCustomNameTag() == null || this.getCustomNameTag().isEmpty()))
{
compound.setBoolean("CustomNameVisible", this.getAlwaysRenderNameTag());
}
compound.setBoolean("Invisible", this.isInvisible());
compound.setBoolean("Small", this.isSmall());
compound.setBoolean("ShowArms", this.getShowArms());
compound.setInteger("DisabledSlots", this.disabledSlots);
compound.setBoolean("NoBasePlate", this.hasNoBasePlate());
if (this.hasMarker())
{
compound.setBoolean("Marker", this.hasMarker());
}
compound.setTag("Pose", this.readPoseFromNBT());
}
示例12: writeEntityToNBT
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound compound)
{
super.writeEntityToNBT(compound);
compound.setBoolean("EatingHaystack", this.isEatingHaystack());
compound.setBoolean("ChestedHorse", this.isChested());
compound.setBoolean("HasReproduced", this.getHasReproduced());
compound.setBoolean("Bred", this.isBreeding());
compound.setInteger("Type", this.getType().getOrdinal());
compound.setInteger("Variant", this.getHorseVariant());
compound.setInteger("Temper", this.getTemper());
compound.setBoolean("Tame", this.isTame());
compound.setBoolean("SkeletonTrap", this.isSkeletonTrap());
compound.setInteger("SkeletonTrapTime", this.skeletonTrapTime);
if (this.getOwnerUniqueId() != null)
{
compound.setString("OwnerUUID", this.getOwnerUniqueId().toString());
}
if (this.isChested())
{
NBTTagList nbttaglist = new NBTTagList();
for (int i = 2; i < this.horseChest.getSizeInventory(); ++i)
{
ItemStack itemstack = this.horseChest.getStackInSlot(i);
if (itemstack != null)
{
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setByte("Slot", (byte)i);
itemstack.writeToNBT(nbttagcompound);
nbttaglist.appendTag(nbttagcompound);
}
}
compound.setTag("Items", nbttaglist);
}
if (this.horseChest.getStackInSlot(1) != null)
{
compound.setTag("ArmorItem", this.horseChest.getStackInSlot(1).writeToNBT(new NBTTagCompound()));
}
if (this.horseChest.getStackInSlot(0) != null)
{
compound.setTag("SaddleItem", this.horseChest.getStackInSlot(0).writeToNBT(new NBTTagCompound()));
}
}
示例13: blacklistHost
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Blacklist an item for a specified host.
* <p/>
* This can be used to prevent certain components to be installed in select
* devices, via the devices class. For example, this is used to prevent
* components that would not be functional in certain devices to be
* installed in those devices, such as graphics cards in micro-controllers.
* <p/>
* The host class is the class of the environment the component would be
* installed in, e.g. {@link li.cil.oc.api.internal.Tablet}.
*
* @param name the name of the component being blacklisted.
* @param host the class of the host to blacklist the component for.
* @param stack the item stack representing the blacklisted component.
*/
public static void blacklistHost(String name, Class host, ItemStack stack) {
final NBTTagCompound nbt = new NBTTagCompound();
nbt.setString("name", name);
nbt.setString("host", host.getName());
final NBTTagCompound stackNbt = new NBTTagCompound();
stack.writeToNBT(stackNbt);
nbt.setTag("item", stackNbt);
FMLInterModComms.sendMessage(MOD_ID, "blacklistHost", nbt);
}