Java 类net.minecraft.nbt.NBTTagList 实例源码

项目:CustomWorldGen    文件:TileEntityDispenser.java   
public void readFromNBT(NBTTagCompound compound)
{
    super.readFromNBT(compound);

    if (!this.checkLootAndRead(compound))
    {
        NBTTagList nbttaglist = compound.getTagList("Items", 10);
        this.stacks = 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.stacks.length)
            {
                this.stacks[j] = ItemStack.loadItemStackFromNBT(nbttagcompound);
            }
        }
    }

    if (compound.hasKey("CustomName", 8))
    {
        this.customName = compound.getString("CustomName");
    }
}
项目:MeeCreeps    文件:PortalTileEntity.java   
@Override
public void readFromNBT(NBTTagCompound compound) {
    super.readFromNBT(compound);
    timeout = compound.getInteger("timeout");
    portalSide = EnumFacing.VALUES[compound.getByte("portalSide")];
    BlockPos pos = BlockPos.fromLong(compound.getLong("pos"));
    int dim = compound.getInteger("dim");
    EnumFacing side = EnumFacing.VALUES[compound.getByte("side")];
    other = new TeleportDestination("", dim, pos, side);
    NBTTagList list = compound.getTagList("bl", Constants.NBT.TAG_COMPOUND);
    blackListed.clear();
    for (int i = 0 ; i < list.tagCount() ; i++) {
        NBTTagCompound tc = list.getCompoundTagAt(i);
        UUID uuid = new UUID(tc.getLong("m"), tc.getLong("l"));
        blackListed.add(uuid);
    }
}
项目:BaseClient    文件:TileEntityBanner.java   
/**
 * Removes all the banner related data from a provided instance of ItemStack.
 */
public static void removeBannerData(ItemStack stack)
{
    NBTTagCompound nbttagcompound = stack.getSubCompound("BlockEntityTag", false);

    if (nbttagcompound != null && nbttagcompound.hasKey("Patterns", 9))
    {
        NBTTagList nbttaglist = nbttagcompound.getTagList("Patterns", 10);

        if (nbttaglist.tagCount() > 0)
        {
            nbttaglist.removeTag(nbttaglist.tagCount() - 1);

            if (nbttaglist.hasNoTags())
            {
                stack.getTagCompound().removeTag("BlockEntityTag");

                if (stack.getTagCompound().hasNoTags())
                {
                    stack.setTagCompound((NBTTagCompound)null);
                }
            }
        }
    }
}
项目:Backmemed    文件:PotionUtils.java   
public static void addCustomPotionEffectToList(@Nullable NBTTagCompound tag, List<PotionEffect> effectList)
{
    if (tag != null && tag.hasKey("CustomPotionEffects", 9))
    {
        NBTTagList nbttaglist = tag.getTagList("CustomPotionEffects", 10);

        for (int i = 0; i < nbttaglist.tagCount(); ++i)
        {
            NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);
            PotionEffect potioneffect = PotionEffect.readCustomPotionEffectFromNBT(nbttagcompound);

            if (potioneffect != null)
            {
                effectList.add(potioneffect);
            }
        }
    }
}
项目:DecompiledMinecraft    文件:EntityMinecartContainer.java   
/**
 * (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);
        }
    }
}
项目:pnc-repressurized    文件:DateEventHandler.java   
public static void spawnFirework(World world, double x, double y, double z) {
    ItemStack rocket = new ItemStack(Items.FIREWORKS);

    ItemStack itemstack1 = getFireworkCharge();

    NBTTagCompound nbttagcompound = new NBTTagCompound();
    NBTTagCompound nbttagcompound1 = new NBTTagCompound();
    NBTTagList nbttaglist = new NBTTagList();

    if (itemstack1 != null && itemstack1.getItem() == Items.FIREWORK_CHARGE && itemstack1.hasTagCompound() && itemstack1.getTagCompound().hasKey("Explosion")) {
        nbttaglist.appendTag(itemstack1.getTagCompound().getCompoundTag("Explosion"));
    }

    nbttagcompound1.setTag("Explosions", nbttaglist);
    nbttagcompound1.setByte("Flight", (byte) 2);
    nbttagcompound.setTag("Fireworks", nbttagcompound1);

    rocket.setTagCompound(nbttagcompound);

    EntityFireworkRocket entity = new EntityFireworkRocket(world, x, y, z, rocket);
    world.spawnEntity(entity);
}
项目:pnc-repressurized    文件:InventoryPneumaticInventoryItem.java   
/**
 * Writes a NBT Node with inventory.
 */
public void writeToNBT() {
    NBTTagList itemList = new NBTTagList();
    for (int i = 0; i < getSizeInventory(); i++) {
        if (!getStackInSlot(i).isEmpty()) {
            NBTTagCompound slotEntry = new NBTTagCompound();
            slotEntry.setByte("Slot", (byte) i);
            getStackInSlot(i).writeToNBT(slotEntry);
            itemList.appendTag(slotEntry);
        }
    }
    // save content in Inventory->Items
    NBTTagCompound inventory = new NBTTagCompound();
    inventory.setTag("Items", itemList);
    NBTUtil.setCompoundTag(armorStack, "UpgradeInventory", inventory);
    NBTUtil.removeTag(armorStack, "Inventory");
}
项目:pnc-repressurized    文件:ContainerRemote.java   
private static Set<String> getRelevantVariableNames(@Nonnull ItemStack remote) {
    Set<String> variables = new HashSet<>();
    NBTTagCompound tag = remote.getTagCompound();
    if (tag != null) {
        NBTTagList tagList = tag.getTagList("actionWidgets", 10);
        for (int i = 0; i < tagList.tagCount(); i++) {
            NBTTagCompound widgetTag = tagList.getCompoundTagAt(i);
            variables.add(widgetTag.getString("variableName"));
            variables.add(widgetTag.getString("enableVariable"));
            TextVariableParser parser = new TextVariableParser(widgetTag.getString("text"));
            parser.parse();
            variables.addAll(parser.getRelevantVariables());
        }
    }
    return variables;
}
项目:Never-Enough-Currency    文件:InventoryItem.java   
/**
 * A custom method to read our inventory from an ItemStack's NBT compound
 */
public void readFromNBT(NBTTagCompound compound) {
    if ("".equals(uniqueID)) {
        // try to read unique ID from NBT
        uniqueID = compound.getString("uniqueID");
        // if it's still "", assign a new one:
        if ("".equals(uniqueID)) {
            uniqueID = UUID.randomUUID().toString();
        }
    }

    NBTTagList items = compound.getTagList("ItemInventory", Constants.NBT.TAG_COMPOUND);

    for (int i = 0; i < items.tagCount(); ++i) {
        NBTTagCompound item = items.getCompoundTagAt(i);
        int slot = item.getInteger("Slot");

        if (slot >= 0 && slot < getSizeInventory()) {
            inventory.set(slot, new ItemStack(item));
        }
    }
}
项目:ElementalElaboration    文件:TileKTWithInventory.java   
public  void readFromNBT(NBTTagCompound tagCompound)
{
    super.readFromNBT(tagCompound);
    NBTTagList tagList = tagCompound.getTagList("Items", 10);
    this.inventory = new ItemStack[this.getSizeInventory()];

    for(int i = 0; i < tagList.tagCount(); ++i)
    {
        NBTTagCompound tempTagCompound = tagList.getCompoundTagAt(i);
        byte slot = tempTagCompound.getByte("Slot");

        if(slot >= 0 && slot < this.inventory.length)
        {
            this.setInventorySlotContents(slot, ItemStack.loadItemStackFromNBT(tempTagCompound));
        }
    }

    if(tagCompound.hasKey("CustomName", 8))
    {
        this.customName = tagCompound.getString("CustomName");
    }
}
项目:BaseClient    文件:TileEntityHopper.java   
public void writeToNBT(NBTTagCompound compound)
{
    super.writeToNBT(compound);
    NBTTagList nbttaglist = new NBTTagList();

    for (int i = 0; i < this.inventory.length; ++i)
    {
        if (this.inventory[i] != null)
        {
            NBTTagCompound nbttagcompound = new NBTTagCompound();
            nbttagcompound.setByte("Slot", (byte)i);
            this.inventory[i].writeToNBT(nbttagcompound);
            nbttaglist.appendTag(nbttagcompound);
        }
    }

    compound.setTag("Items", nbttaglist);
    compound.setInteger("TransferCooldown", this.transferCooldown);

    if (this.hasCustomName())
    {
        compound.setString("CustomName", this.customName);
    }
}
项目:pnc-repressurized    文件:RemoteLayout.java   
public RemoteLayout(ItemStack remote, int guiLeft, int guiTop) {
    NBTTagCompound tag = remote.getTagCompound();
    if (tag != null) {
        NBTTagList tagList = tag.getTagList("actionWidgets", 10);
        for (int i = 0; i < tagList.tagCount(); i++) {
            NBTTagCompound widgetTag = tagList.getCompoundTagAt(i);
            String id = widgetTag.getString("id");
            Class<? extends ActionWidget> clazz = registeredWidgets.get(id);
            try {
                ActionWidget widget = clazz.newInstance();
                widget.readFromNBT(widgetTag, guiLeft, guiTop);
                actionWidgets.add(widget);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
项目:BaseClient    文件:InventoryEnderChest.java   
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;
}
项目:Backmemed    文件:StructureStart.java   
public NBTTagCompound writeStructureComponentsToNBT(int chunkX, int chunkZ)
{
    NBTTagCompound nbttagcompound = new NBTTagCompound();
    nbttagcompound.setString("id", MapGenStructureIO.getStructureStartName(this));
    nbttagcompound.setInteger("ChunkX", chunkX);
    nbttagcompound.setInteger("ChunkZ", chunkZ);
    nbttagcompound.setTag("BB", this.boundingBox.toNBTTagIntArray());
    NBTTagList nbttaglist = new NBTTagList();

    for (StructureComponent structurecomponent : this.components)
    {
        nbttaglist.appendTag(structurecomponent.createStructureBaseNBT());
    }

    nbttagcompound.setTag("Children", nbttaglist);
    this.writeToNBT(nbttagcompound);
    return nbttagcompound;
}
项目:Backmemed    文件:ScoreboardSaveData.java   
protected void readScores(NBTTagList nbt)
{
    for (int i = 0; i < nbt.tagCount(); ++i)
    {
        NBTTagCompound nbttagcompound = nbt.getCompoundTagAt(i);
        ScoreObjective scoreobjective = this.theScoreboard.getObjective(nbttagcompound.getString("Objective"));
        String s = nbttagcompound.getString("Name");

        if (s.length() > 40)
        {
            s = s.substring(0, 40);
        }

        Score score = this.theScoreboard.getOrCreateScore(s, scoreobjective);
        score.setScorePoints(nbttagcompound.getInteger("Score"));

        if (nbttagcompound.hasKey("Locked"))
        {
            score.setLocked(nbttagcompound.getBoolean("Locked"));
        }
    }
}
项目:CustomWorldGen    文件:ItemEnchantedBook.java   
/**
 * allows items to add custom lines of information to the mouseover description
 */
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced)
{
    super.addInformation(stack, playerIn, tooltip, advanced);
    NBTTagList nbttaglist = this.getEnchantments(stack);

    if (nbttaglist != null)
    {
        for (int i = 0; i < nbttaglist.tagCount(); ++i)
        {
            int j = nbttaglist.getCompoundTagAt(i).getShort("id");
            int k = nbttaglist.getCompoundTagAt(i).getShort("lvl");

            if (Enchantment.getEnchantmentByID(j) != null)
            {
                tooltip.add(Enchantment.getEnchantmentByID(j).getTranslatedName(k));
            }
        }
    }
}
项目:StructPro    文件:Blueprint.java   
/**
 * Write to schematic tags
 * @return Control tag
 */
private NBTTagCompound getSchematic() {
    NBTTagCompound tag = new NBTTagCompound();
    tag.setString("Materials", "Alpha");
    tag.setShort("Width", (short) getWidth());
    tag.setShort("Height", (short) getHeight());
    tag.setShort("Length", (short) getLength());
    tag.setByteArray("AddBlocks", new byte[0]);
    byte[] blocksID = new byte[getBlocks().length];
    for (int i = 0; i < getBlocks().length; ++i) {
        blocksID[i] = (byte) getBlock(i);
    }
    tag.setByteArray("Blocks", blocksID);
    tag.setByteArray("AddBlocks", getAddBlocks(getBlocks()));
    tag.setByteArray("Data", getMetas());
    NBTTagList tileEntities = new NBTTagList();
    for (NBTTagCompound tile : getTiles()) {
        if (tile != null) {
            tileEntities.appendTag(tile);
        }
    }
    tag.setTag("TileEntities", tileEntities);
    return tag;
}
项目:Firma    文件:AnvilTileEntity.java   
@Override
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
    super.writeToNBT(nbt);

    NBTTagList list = new NBTTagList();
    for (int i = 0; i < this.getSizeInventory(); ++i) {
        if (this.getStackInSlot(i) != null) {
            NBTTagCompound stackTag = new NBTTagCompound();
            stackTag.setByte("Slot", (byte) i);
            this.getStackInSlot(i).writeToNBT(stackTag);
            list.appendTag(stackTag);
        }
    }
    nbt.setTag("Items", list);

    if (this.hasCustomName()) {
        nbt.setString("CustomName", this.getCustomName());
    }
    return nbt;
}
项目:StructPro    文件:Tiles.java   
/**
 * Load inventory data from NBT tag
 * @param inventory Target inventory
 * @param tag tag to load
 * @param seed Loading seed
 */
private static void load(IInventory inventory, NBTTagCompound tag, long seed) {
    if (tag == null || !Configurator.NATIVE_LOOT) {
        return;
    }
    Random random = new Random(seed);
    NBTTagList items = tag.getTagList("Items", Constants.NBT.TAG_COMPOUND);
    for (int i = 0; i < items.tagCount() && i < inventory.getSizeInventory(); ++i) {
        NBTTagCompound stackTag = items.getCompoundTagAt(i);
        String itemName = stackTag.getString("id").replaceAll(".*:", "");
        itemName = itemName.isEmpty() ? String.valueOf(stackTag.getShort("id")) : itemName;
        Pattern iPattern = Pattern.compile(Pattern.quote(itemName), Pattern.CASE_INSENSITIVE);
        UItem item = Utils.select(UItems.items.select(iPattern), random.nextLong());
        byte count = items.getCompoundTagAt(i).getByte("Count");
        int damage = items.getCompoundTagAt(i).getShort("Damage");
        int slot = stackTag.hasKey("Slot", Constants.NBT.TAG_BYTE) ? stackTag.getByte("Slot") : i;
        slot = (slot < 0 || slot >= inventory.getSizeInventory()) ? i : slot;
        if (item != null && count > 0 && UItems.getPossibleMeta(item).contains(damage)) {
            inventory.setInventorySlotContents(slot, new UItemStack(item, count, damage).getItemStack());
        }
    }
}
项目:CustomWorldGen    文件:ItemStackHandler.java   
@Override
public NBTTagCompound serializeNBT()
{
    NBTTagList nbtTagList = new NBTTagList();
    for (int i = 0; i < stacks.length; i++)
    {
        if (stacks[i] != null)
        {
            NBTTagCompound itemTag = new NBTTagCompound();
            itemTag.setInteger("Slot", i);
            stacks[i].writeToNBT(itemTag);
            nbtTagList.appendTag(itemTag);
        }
    }
    NBTTagCompound nbt = new NBTTagCompound();
    nbt.setTag("Items", nbtTagList);
    nbt.setInteger("Size", stacks.length);
    return nbt;
}
项目:Backmemed    文件:EntityArmorStand.java   
/**
 * Saves the pose to an NBTTagCompound.
 */
private void writePoseToNBT(NBTTagCompound tagCompound)
{
    NBTTagList nbttaglist = tagCompound.getTagList("Head", 5);
    this.setHeadRotation(nbttaglist.hasNoTags() ? DEFAULT_HEAD_ROTATION : new Rotations(nbttaglist));
    NBTTagList nbttaglist1 = tagCompound.getTagList("Body", 5);
    this.setBodyRotation(nbttaglist1.hasNoTags() ? DEFAULT_BODY_ROTATION : new Rotations(nbttaglist1));
    NBTTagList nbttaglist2 = tagCompound.getTagList("LeftArm", 5);
    this.setLeftArmRotation(nbttaglist2.hasNoTags() ? DEFAULT_LEFTARM_ROTATION : new Rotations(nbttaglist2));
    NBTTagList nbttaglist3 = tagCompound.getTagList("RightArm", 5);
    this.setRightArmRotation(nbttaglist3.hasNoTags() ? DEFAULT_RIGHTARM_ROTATION : new Rotations(nbttaglist3));
    NBTTagList nbttaglist4 = tagCompound.getTagList("LeftLeg", 5);
    this.setLeftLegRotation(nbttaglist4.hasNoTags() ? DEFAULT_LEFTLEG_ROTATION : new Rotations(nbttaglist4));
    NBTTagList nbttaglist5 = tagCompound.getTagList("RightLeg", 5);
    this.setRightLegRotation(nbttaglist5.hasNoTags() ? DEFAULT_RIGHTLEG_ROTATION : new Rotations(nbttaglist5));
}
项目:CustomWorldGen    文件:StructureStart.java   
public NBTTagCompound writeStructureComponentsToNBT(int chunkX, int chunkZ)
{
    if (MapGenStructureIO.getStructureStartName(this) == null) // This is just a more friendly error instead of the 'Null String' below
    {
        throw new RuntimeException("StructureStart \"" + this.getClass().getName() + "\" missing ID Mapping, Modder see MapGenStructureIO");
    }
    NBTTagCompound nbttagcompound = new NBTTagCompound();
    nbttagcompound.setString("id", MapGenStructureIO.getStructureStartName(this));
    nbttagcompound.setInteger("ChunkX", chunkX);
    nbttagcompound.setInteger("ChunkZ", chunkZ);
    nbttagcompound.setTag("BB", this.boundingBox.toNBTTagIntArray());
    NBTTagList nbttaglist = new NBTTagList();

    for (StructureComponent structurecomponent : this.components)
    {
        nbttaglist.appendTag(structurecomponent.createStructureBaseNBT());
    }

    nbttagcompound.setTag("Children", nbttaglist);
    this.writeToNBT(nbttagcompound);
    return nbttagcompound;
}
项目:BaseClient    文件:TileEntityDispenser.java   
public void readFromNBT(NBTTagCompound compound)
{
    super.readFromNBT(compound);
    NBTTagList nbttaglist = compound.getTagList("Items", 10);
    this.stacks = 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.stacks.length)
        {
            this.stacks[j] = ItemStack.loadItemStackFromNBT(nbttagcompound);
        }
    }

    if (compound.hasKey("CustomName", 8))
    {
        this.customName = compound.getString("CustomName");
    }
}
项目:BaseClient    文件:ItemBanner.java   
/**
 * allows items to add custom lines of information to the mouseover description
 */
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced)
{
    NBTTagCompound nbttagcompound = stack.getSubCompound("BlockEntityTag", false);

    if (nbttagcompound != null && nbttagcompound.hasKey("Patterns"))
    {
        NBTTagList nbttaglist = nbttagcompound.getTagList("Patterns", 10);

        for (int i = 0; i < nbttaglist.tagCount() && i < 6; ++i)
        {
            NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
            EnumDyeColor enumdyecolor = EnumDyeColor.byDyeDamage(nbttagcompound1.getInteger("Color"));
            TileEntityBanner.EnumBannerPattern tileentitybanner$enumbannerpattern = TileEntityBanner.EnumBannerPattern.getPatternByID(nbttagcompound1.getString("Pattern"));

            if (tileentitybanner$enumbannerpattern != null)
            {
                tooltip.add(StatCollector.translateToLocal("item.banner." + tileentitybanner$enumbannerpattern.getPatternName() + "." + enumdyecolor.getUnlocalizedName()));
            }
        }
    }
}
项目:morefurnaces    文件:TileEntityIronFurnace.java   
@Override
public NBTTagCompound writeToNBT(NBTTagCompound nbtTagCompound)
{
    super.writeToNBT(nbtTagCompound);
    nbtTagCompound.setShort("BurnTime", (short) furnaceBurnTime);
    NBTTagList cookList = new NBTTagList();
    for (int i = 0; i < furnaceCookTime.length; i++)
    {
        NBTTagCompound tag = new NBTTagCompound();
        tag.setByte("Id", (byte) i);
        tag.setInteger("Time", furnaceCookTime[i]);
        cookList.appendTag(tag);
    }

    nbtTagCompound.setTag("CookTimes", cookList);

    nbtTagCompound.setByte("facing", facing);
    nbtTagCompound.setBoolean("isActive", isActive);

    NBTTagCompound nbt = itemHandler.serializeNBT();
    nbtTagCompound.setTag("Items", nbt.getTag("Items"));
    nbtTagCompound.setInteger("Size", nbt.getInteger("Size"));

    return nbtTagCompound;
}
项目:DecompiledMinecraft    文件:ItemEnchantedBook.java   
/**
 * allows items to add custom lines of information to the mouseover description
 */
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced)
{
    super.addInformation(stack, playerIn, tooltip, advanced);
    NBTTagList nbttaglist = this.getEnchantments(stack);

    if (nbttaglist != null)
    {
        for (int i = 0; i < nbttaglist.tagCount(); ++i)
        {
            int j = nbttaglist.getCompoundTagAt(i).getShort("id");
            int k = nbttaglist.getCompoundTagAt(i).getShort("lvl");

            if (Enchantment.getEnchantmentById(j) != null)
            {
                tooltip.add(Enchantment.getEnchantmentById(j).getTranslatedName(k));
            }
        }
    }
}
项目:CustomWorldGen    文件:EntityTippedArrow.java   
/**
 * (abstract) Protected helper method to write subclass entity data to NBT.
 */
public void writeEntityToNBT(NBTTagCompound compound)
{
    super.writeEntityToNBT(compound);

    if (this.potion != PotionTypes.EMPTY && this.potion != null)
    {
        compound.setString("Potion", ((ResourceLocation)PotionType.REGISTRY.getNameForObject(this.potion)).toString());
    }

    if (!this.customPotionEffects.isEmpty())
    {
        NBTTagList nbttaglist = new NBTTagList();

        for (PotionEffect potioneffect : this.customPotionEffects)
        {
            nbttaglist.appendTag(potioneffect.writeCustomPotionEffectToNBT(new NBTTagCompound()));
        }

        compound.setTag("CustomPotionEffects", nbttaglist);
    }
}
项目:BaseClient    文件:TileEntityBanner.java   
/**
 * Removes all the banner related data from a provided instance of ItemStack.
 */
public static void removeBannerData(ItemStack stack)
{
    NBTTagCompound nbttagcompound = stack.getSubCompound("BlockEntityTag", false);

    if (nbttagcompound != null && nbttagcompound.hasKey("Patterns", 9))
    {
        NBTTagList nbttaglist = nbttagcompound.getTagList("Patterns", 10);

        if (nbttaglist.tagCount() > 0)
        {
            nbttaglist.removeTag(nbttaglist.tagCount() - 1);

            if (nbttaglist.hasNoTags())
            {
                stack.getTagCompound().removeTag("BlockEntityTag");

                if (stack.getTagCompound().hasNoTags())
                {
                    stack.setTagCompound((NBTTagCompound)null);
                }
            }
        }
    }
}
项目:BaseClient    文件:ItemWritableBook.java   
/**
 * this method returns true if the book's NBT Tag List "pages" is valid
 */
public static boolean isNBTValid(NBTTagCompound nbt)
{
    if (nbt == null)
    {
        return false;
    }
    else if (!nbt.hasKey("pages", 9))
    {
        return false;
    }
    else
    {
        NBTTagList nbttaglist = nbt.getTagList("pages", 8);

        for (int i = 0; i < nbttaglist.tagCount(); ++i)
        {
            String s = nbttaglist.getStringTagAt(i);

            if (s == null)
            {
                return false;
            }

            if (s.length() > 32767)
            {
                return false;
            }
        }

        return true;
    }
}
项目:DecompiledMinecraft    文件:StructureOceanMonument.java   
public void readFromNBT(NBTTagCompound tagCompound)
{
    super.readFromNBT(tagCompound);

    if (tagCompound.hasKey("Processed", 9))
    {
        NBTTagList nbttaglist = tagCompound.getTagList("Processed", 10);

        for (int i = 0; i < nbttaglist.tagCount(); ++i)
        {
            NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);
            this.field_175791_c.add(new ChunkCoordIntPair(nbttagcompound.getInteger("X"), nbttagcompound.getInteger("Z")));
        }
    }
}
项目:DecompiledMinecraft    文件:StructureMineshaftPieces.java   
protected void writeStructureToNBT(NBTTagCompound tagCompound)
{
    NBTTagList nbttaglist = new NBTTagList();

    for (StructureBoundingBox structureboundingbox : this.roomsLinkedToTheRoom)
    {
        nbttaglist.appendTag(structureboundingbox.toNBTTagIntArray());
    }

    tagCompound.setTag("Entrances", nbttaglist);
}
项目:BaseClient    文件:EntityArmorStand.java   
/**
 * (abstract) Protected helper method to write subclass entity data to NBT.
 */
public void writeEntityToNBT(NBTTagCompound tagCompound)
{
    super.writeEntityToNBT(tagCompound);
    NBTTagList nbttaglist = new NBTTagList();

    for (int i = 0; i < this.contents.length; ++i)
    {
        NBTTagCompound nbttagcompound = new NBTTagCompound();

        if (this.contents[i] != null)
        {
            this.contents[i].writeToNBT(nbttagcompound);
        }

        nbttaglist.appendTag(nbttagcompound);
    }

    tagCompound.setTag("Equipment", nbttaglist);

    if (this.getAlwaysRenderNameTag() && (this.getCustomNameTag() == null || this.getCustomNameTag().length() == 0))
    {
        tagCompound.setBoolean("CustomNameVisible", this.getAlwaysRenderNameTag());
    }

    tagCompound.setBoolean("Invisible", this.isInvisible());
    tagCompound.setBoolean("Small", this.isSmall());
    tagCompound.setBoolean("ShowArms", this.getShowArms());
    tagCompound.setInteger("DisabledSlots", this.disabledSlots);
    tagCompound.setBoolean("NoGravity", this.hasNoGravity());
    tagCompound.setBoolean("NoBasePlate", this.hasNoBasePlate());

    if (this.func_181026_s())
    {
        tagCompound.setBoolean("Marker", this.func_181026_s());
    }

    tagCompound.setTag("Pose", this.readPoseFromNBT());
}
项目:Solar    文件:PacketHelper.java   
public static void syncQuantumToAll() {
    NBTTagCompound compound = new NBTTagCompound();
    NBTTagList tags = new NBTTagList();
    QuantumHandler.getEntanglements().forEach((uuid, stacks) -> {
        NBTTagCompound tag = new NBTTagCompound();
        NBTTagList list = new NBTTagList();
        stacks.forEach(stack -> list.appendTag(stack.writeToNBT(new NBTTagCompound())));
        tag.setTag("list", list);
        tag.setUniqueId("uuid", uuid);
        tags.appendTag(tag);
    });
    compound.setTag("tags", tags);
    PacketHandler.NETWORK.sendToAll(new ServerToClientPacket(PacketHandler.Q_SYNC_ALL, compound));
}
项目:BaseClient    文件:VillageCollection.java   
/**
 * reads in data from the NBTTagCompound into this MapDataBase
 */
public void readFromNBT(NBTTagCompound nbt)
{
    this.tickCounter = nbt.getInteger("Tick");
    NBTTagList nbttaglist = nbt.getTagList("Villages", 10);

    for (int i = 0; i < nbttaglist.tagCount(); ++i)
    {
        NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);
        Village village = new Village();
        village.readVillageDataFromNBT(nbttagcompound);
        this.villageList.add(village);
    }
}
项目:DecompiledMinecraft    文件:MobSpawnerBaseLogic.java   
public void writeToNBT(NBTTagCompound nbt)
{
    String s = this.getEntityNameToSpawn();

    if (!StringUtils.isNullOrEmpty(s))
    {
        nbt.setString("EntityId", s);
        nbt.setShort("Delay", (short)this.spawnDelay);
        nbt.setShort("MinSpawnDelay", (short)this.minSpawnDelay);
        nbt.setShort("MaxSpawnDelay", (short)this.maxSpawnDelay);
        nbt.setShort("SpawnCount", (short)this.spawnCount);
        nbt.setShort("MaxNearbyEntities", (short)this.maxNearbyEntities);
        nbt.setShort("RequiredPlayerRange", (short)this.activatingRangeFromPlayer);
        nbt.setShort("SpawnRange", (short)this.spawnRange);

        if (this.getRandomEntity() != null)
        {
            nbt.setTag("SpawnData", this.getRandomEntity().nbtData.copy());
        }

        if (this.getRandomEntity() != null || this.minecartToSpawn.size() > 0)
        {
            NBTTagList nbttaglist = new NBTTagList();

            if (this.minecartToSpawn.size() > 0)
            {
                for (MobSpawnerBaseLogic.WeightedRandomMinecart mobspawnerbaselogic$weightedrandomminecart : this.minecartToSpawn)
                {
                    nbttaglist.appendTag(mobspawnerbaselogic$weightedrandomminecart.toNBT());
                }
            }
            else
            {
                nbttaglist.appendTag(this.getRandomEntity().toNBT());
            }

            nbt.setTag("SpawnPotentials", nbttaglist);
        }
    }
}
项目:Backmemed    文件:SharedMonsterAttributes.java   
/**
 * Creates an NBTTagList from a BaseAttributeMap, including all its AttributeInstances
 */
public static NBTTagList writeBaseAttributeMapToNBT(AbstractAttributeMap map)
{
    NBTTagList nbttaglist = new NBTTagList();

    for (IAttributeInstance iattributeinstance : map.getAllAttributes())
    {
        nbttaglist.appendTag(writeAttributeInstanceToNBT(iattributeinstance));
    }

    return nbttaglist;
}
项目:Backmemed    文件:ItemBanner.java   
public static ItemStack func_190910_a(EnumDyeColor p_190910_0_, @Nullable NBTTagList p_190910_1_)
{
    ItemStack itemstack = new ItemStack(Items.BANNER, 1, p_190910_0_.getDyeDamage());

    if (p_190910_1_ != null && !p_190910_1_.hasNoTags())
    {
        itemstack.func_190925_c("BlockEntityTag").setTag("Patterns", p_190910_1_.copy());
    }

    return itemstack;
}
项目:uniquecrops    文件:UCUtils.java   
public static NBTTagList getServerTaglist(int id) {

    MinecraftServer ms = FMLCommonHandler.instance().getMinecraftServerInstance();
    if (ms == null)
        return null;
    EntityPlayer player = (EntityPlayer)ms.getEntityWorld().getEntityByID(id);
    if (player != null) {
        NBTTagCompound tag = player.getEntityData();
        if (tag.hasKey(GrowthSteps.TAG_GROWTHSTAGES)) 
        {
            return tag.getTagList(GrowthSteps.TAG_GROWTHSTAGES, 10);
        }
    }
    return null;
}
项目:Solar    文件:WorldQuantumData.java   
@Override
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
    NBTTagList list = new NBTTagList();
    getEntanglements().forEach((uuid, itemStacks) -> {
        NBTTagList stackList = new NBTTagList();
        itemStacks.forEach(stack -> stackList.appendTag(stack.writeToNBT(new NBTTagCompound())));
        NBTTagCompound nbt = new NBTTagCompound();
        nbt.setUniqueId("key", uuid);
        nbt.setTag("list", stackList);
        list.appendTag(nbt);
    });
    compound.setTag(QuantumHandler.NBT_TAG, list);
    return compound;
}
项目:pnc-repressurized    文件:HeatExchangerLogic.java   
@Override
public void writeToNBT(NBTTagCompound tag) {
    tag.setDouble("temperature", temperature);
    NBTTagList tagList = new NBTTagList();
    for (HeatBehaviour behaviour : behaviours) {
        NBTTagCompound t = new NBTTagCompound();
        t.setString("id", behaviour.getId());
        behaviour.writeToNBT(t);
        tagList.appendTag(t);
    }
    tag.setTag("behaviours", tagList);
}