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


C# NbtCompound.Add方法代码示例

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


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

示例1: ToNBT

 public override NbtCompound ToNBT()
 {
     NbtCompound c = new NbtCompound();
     Base2NBT(ref c);
     c.Add(new NbtString("EntityId", EntityId));
     c.Add(new NbtShort("Delay", Delay));
     return c;
 }
开发者ID:N3X15,项目名称:MineEdit,代码行数:8,代码来源:MobSpawner.cs

示例2: ToNBT

 public override NbtCompound ToNBT()
 {
     NbtCompound c = new NbtCompound();
     Base2NBT(ref c,GetID());
     c.Add(new NbtByte("Tile", Tile));
     return c;
 }
开发者ID:N3X15,项目名称:MineEdit,代码行数:7,代码来源:FallingSand.cs

示例3: SaveTo

 public void SaveTo(string file)
 {
     var nbt = new NbtFile(file);
     nbt.RootTag = new NbtCompound("");
     var list = new NbtList("servers", NbtTagType.Compound);
     foreach (var server in Servers)
     {
         var compound = new NbtCompound();
         compound.Add(new NbtString("name", server.Name));
         compound.Add(new NbtString("ip", server.Ip));
         compound.Add(new NbtByte("hideAddress", (byte)(server.HideAddress ? 1 : 0)));
         compound.Add(new NbtByte("acceptTextures", (byte)(server.AcceptTextures ? 1 : 0)));
         list.Add(compound);
     }
     nbt.RootTag.Add(list);
     nbt.SaveToFile(file, NbtCompression.None);
 }
开发者ID:seaboy1234,项目名称:Craft.Net,代码行数:17,代码来源:ServerList.cs

示例4: AddingAndRemoving

        public void AddingAndRemoving()
        {
            NbtCompound test = new NbtCompound();

            NbtInt foo =  new NbtInt( "Foo" );

            test.Add( foo );

            // adding duplicate object
            Assert.Throws<ArgumentException>( () => test.Add( foo ) );

            // adding duplicate name
            Assert.Throws<ArgumentException>( () => test.Add( new NbtByte( "Foo" ) ) );

            // adding unnamed tag
            Assert.Throws<ArgumentException>( () => test.Add( new NbtInt() ) );

            // adding null
            Assert.Throws<ArgumentNullException>( () => test.Add( null ) );

            // contains existing name
            Assert.IsTrue( test.Contains( "Foo" ) );

            // contains existing object
            Assert.IsTrue( test.Contains( foo ) );

            // contains non-existent name
            Assert.IsFalse( test.Contains( "Bar" ) );

            // contains existing name / different object
            Assert.IsFalse( test.Contains( new NbtInt( "Foo" ) ) );

            // removing non-existent name
            Assert.IsFalse( test.Remove( "Bar" ) );

            // removing existing name
            Assert.IsTrue( test.Remove( "Foo" ) );

            // removing non-existent name
            Assert.IsFalse( test.Remove( "Foo" ) );

            // re-adding object
            test.Add( foo );

            // removing existing object
            Assert.IsTrue( test.Remove( foo ) );

            // clearing an empty NbtCompound
            Assert.AreEqual( test.Count, 0 );
            test.Clear();

            // re-adding after clearing
            test.Add( foo );
            Assert.AreEqual( test.Count, 1 );

            // clearing a non-empty NbtCompound
            test.Clear();
            Assert.AreEqual( test.Count, 0 );
        }
开发者ID:pdelvo,项目名称:LibNbt2012,代码行数:59,代码来源:CompoundTests.cs

示例5: Write

        public NbtCompound Write() {
            var newCompound = new NbtCompound("Metadata");

            if (Tags == null) 
                return newCompound;

            foreach (NbtTag b in Tags) {
                ((NbtCompound) b.Parent)?.Remove(b);

                newCompound.Add(b);
            }

            return newCompound;
        }
开发者ID:umby24,项目名称:ClassicWorld.Net,代码行数:14,代码来源:ClassicWorld.cs

示例6: Save

        public void Save()
        {
            NbtCompound root = new NbtCompound("base");
            root.Add(new NbtString("fileType", "map"));

            NbtList aList = new NbtList("areas", NbtTagType.Compound);
            foreach(Area alpha in areas) {
                aList.Add(alpha.Save());
            }
            root.Add(aList);

            NbtFile saveFile = new NbtFile(root);
            saveFile.BigEndian = true;
            saveFile.SaveToFile("mapfile.nbt", NbtCompression.None);
        }
开发者ID:RIT-GSD3-Survive,项目名称:Survive,代码行数:15,代码来源:Game1.cs

示例7: Write

        public NbtCompound Write()
        {
            var hcBase = new NbtCompound("Hypercube")
            {
                new NbtString("BuildPerms", BuildPerms),
                new NbtString("ShowPerms", ShowPerms),
                new NbtString("JoinPerms", JoinPerms),
                new NbtInt("SaveInterval", SaveInterval),
                new NbtByte("Physics", Convert.ToByte(Physics)),
                new NbtByte("Building", Convert.ToByte(Building)),
                new NbtByte("History", Convert.ToByte(History))
            };

            if (Motd != null)
                hcBase.Add(new NbtString("MOTD", Motd));

            return hcBase;
        }
开发者ID:umby24,项目名称:Hypercube,代码行数:18,代码来源:HypercubeMap.cs

示例8: Base2NBT

 internal void Base2NBT(ref NbtCompound c,string _id)
 {
     c.Add(new NbtFloat("FallDistance", FallDistance));
     c.Add(new NbtByte("OnGround", OnGround));
     c.Add(new NbtString("id", _id));
     NbtList motion = new NbtList("Motion");
     motion.Tags.AddRange(new NbtDouble[]{
         new NbtDouble("", Motion.X),
         new NbtDouble("", Motion.Y),
         new NbtDouble("", Motion.Z)
     });
     c.Add(motion);
     NbtList pos = new NbtList("Pos");
     pos.Tags.AddRange(new NbtDouble[]{
         new NbtDouble("", Math.IEEERemainder(Pos.X,16)),
         new NbtDouble("", Pos.Y),
         new NbtDouble("", Math.IEEERemainder(Pos.Z,16))
     });
     c.Add(pos);
     c.Add(Rotation.ToNBT());
 }
开发者ID:N3X15,项目名称:MineEdit,代码行数:21,代码来源:Entity.cs

示例9: ToNbt

 public NbtCompound ToNbt()
 {
     var c = new NbtCompound();
     c.Add(new NbtShort("id", Id));
     c.Add(new NbtShort("Damage", Metadata));
     c.Add(new NbtByte("Count", (byte)Count));
     c.Add(new NbtByte("Slot", (byte)Index));
     if (Nbt != null && Nbt.RootTag != null)
     {
         Nbt.RootTag = new NbtCompound("tag");
         c.Add(Nbt.RootTag);
     }
     return c;
 }
开发者ID:ammaraskar,项目名称:Craft.Net,代码行数:14,代码来源:Slot.cs

示例10: SetItem

        public void SetItem(Item item)
        {
            var newItem = new NbtCompound("Item")
            {
                new NbtShort("id", item.Id),
                new NbtShort("Damage", item.Metadata),
                new NbtByte("Count", 1)
            };

            if (item.ExtraData != null)
            {
                var newTag = (NbtTag) item.ExtraData.Clone();
                newTag.Name = "tag";
                newItem.Add(newTag);
            }

            var comp = new NbtCompound(string.Empty)
            {
                new NbtString("id", Id),
                new NbtInt("x", Coordinates.X),
                new NbtInt("y", Coordinates.Y),
                new NbtInt("z", Coordinates.Z),
            };

            comp["Item"] = newItem;
            Compound = comp;
        }
开发者ID:CRBairdUSA,项目名称:MiNET,代码行数:27,代码来源:ItemFrameBlockEntity.cs

示例11: ToNBT

        public override NbtCompound ToNBT()
        {
            NbtCompound c = new NbtCompound();
            Base2NBT(ref c);
            c.Add(new NbtShort("BurnTime",BurnTime));
            c.Add(new NbtShort("CookTime",CookTime));
            NbtList Items = new NbtList("Items");
            for (int i = 0; i < 3; i++)
            {
                if (Slots[i].ID != 0x00)
                {
                    NbtCompound cc = new NbtCompound();

                    cc.Add(new NbtShort("id",Slots[i].ID));
                    cc.Add(new NbtShort("Damage",(short)Slots[i].Damage));
                    cc.Add(new NbtByte("Count",(byte)Slots[i].Count));
                    cc.Add(new NbtByte("Slot", (byte)i));

                    Items.Add(cc);
                }
            }
            c.Add(Items);
            return c;
        }
开发者ID:N3X15,项目名称:MineEdit,代码行数:24,代码来源:Furnace.cs

示例12: AddingAndRemoving

        public void AddingAndRemoving()
        {
            var foo = new NbtInt("Foo");
            var test = new NbtCompound
            {
                foo
            };

            // adding duplicate object
            Assert.Throws<ArgumentException>(() => test.Add(foo));

            // adding duplicate name
            Assert.Throws<ArgumentException>(() => test.Add(new NbtByte("Foo")));

            // adding unnamed tag
            Assert.Throws<ArgumentException>(() => test.Add(new NbtInt()));

            // adding null
            Assert.Throws<ArgumentNullException>(() => test.Add(null));

            // adding tag to self
            Assert.Throws<ArgumentException>(() => test.Add(test));

            // contains existing name/object
            Assert.True(test.Contains("Foo"));
            Assert.True(test.Contains(foo));
            Assert.Throws<ArgumentNullException>(() => test.Contains((string) null));
            Assert.Throws<ArgumentNullException>(() => test.Contains((NbtTag) null));

            // contains non-existent name
            Assert.False(test.Contains("Bar"));

            // contains existing name / different object
            Assert.False(test.Contains(new NbtInt("Foo")));

            // removing non-existent name
            Assert.Throws<ArgumentNullException>(() => test.Remove((string) null));
            Assert.False(test.Remove("Bar"));

            // removing existing name
            Assert.True(test.Remove("Foo"));

            // removing non-existent name
            Assert.False(test.Remove("Foo"));

            // re-adding object
            test.Add(foo);

            // removing existing object
            Assert.Throws<ArgumentNullException>(() => test.Remove((NbtTag) null));
            Assert.True(test.Remove(foo));
            Assert.False(test.Remove(foo));

            // clearing an empty NbtCompound
            Assert.Equal(0, test.Count);
            test.Clear();

            // re-adding after clearing
            test.Add(foo);
            Assert.Equal(1, test.Count);

            // clearing a non-empty NbtCompound
            test.Clear();
            Assert.Equal(0, test.Count);
        }
开发者ID:KenVanGilbergen,项目名称:ken.Minecraft,代码行数:65,代码来源:NbtCompoundTests.cs

示例13: NestedListAndCompoundTest

        public void NestedListAndCompoundTest()
        {
            byte[] data;
            {
                var root = new NbtCompound("Root");
                var outerList = new NbtList("OuterList", NbtTagType.Compound);
                var outerCompound = new NbtCompound();
                var innerList = new NbtList("InnerList", NbtTagType.Compound);
                var innerCompound = new NbtCompound();

                innerList.Add(innerCompound);
                outerCompound.Add(innerList);
                outerList.Add(outerCompound);
                root.Add(outerList);

                var file = new NbtFile(root);
                data = file.SaveToBuffer(NbtCompression.None);
            }
            {
                var file = new NbtFile();
                long bytesRead = file.LoadFromBuffer(data, 0, data.Length, NbtCompression.None);
                Assert.AreEqual(bytesRead, data.Length);
                Assert.AreEqual(1, file.RootTag.Get<NbtList>("OuterList").Count);
                Assert.AreEqual(null, file.RootTag.Get<NbtList>("OuterList").Get<NbtCompound>(0).Name);
                Assert.AreEqual(1,
                                file.RootTag.Get<NbtList>("OuterList")
                                    .Get<NbtCompound>(0)
                                    .Get<NbtList>("InnerList")
                                    .Count);
                Assert.AreEqual(null,
                                file.RootTag.Get<NbtList>("OuterList")
                                    .Get<NbtCompound>(0)
                                    .Get<NbtList>("InnerList")
                                    .Get<NbtCompound>(0)
                                    .Name);
            }
        }
开发者ID:fragmer,项目名称:fNbt,代码行数:37,代码来源:ListTests.cs

示例14: Save

 public override void Save(string Folder)
 {
     string f = Path.Combine(Folder, "DefaultMapGenerator.dat");
     NbtFile nf = new NbtFile(f);
     nf.RootTag = new NbtCompound("__ROOT__");
     NbtCompound c = new NbtCompound("DefaultMapGenerator");
     c.Add(new NbtByte("GenerateCaves", (byte)(GenerateCaves ? 1 : 0)));
     c.Add(new NbtByte("GenerateDungeons", (byte)(GenerateDungeons ? 1 : 0)));
     c.Add(new NbtByte("GenerateOres", (byte)(GenerateOres ? 1 : 0)));
     c.Add(new NbtByte("GenerateWater", (byte)(GenerateWater ? 1 : 0)));
     c.Add(new NbtByte("HellMode", (byte)(HellMode ? 1 : 0)));
     c.Add(new NbtByte("GenerateTrees", (byte)(GenerateTrees ? 1 : 0)));
     c.Add(new NbtDouble("Frequency", Frequency));
     c.Add(new NbtByte("NoiseQuality", (byte)NoiseQuality));
     c.Add(new NbtInt("OctaveCount", OctaveCount));
     c.Add(new NbtDouble("Lacunarity", Lacunarity));
     c.Add(new NbtDouble("Persistance", Persistance));
     c.Add(new NbtDouble("ContinentNoiseFrequency", ContinentNoiseFrequency));
     c.Add(new NbtDouble("CaveThreshold", CaveThreshold));
     nf.RootTag.Add(c);
     nf.SaveFile(f);
 }
开发者ID:N3X15,项目名称:MineEdit,代码行数:22,代码来源:QuickHillGenerator.cs

示例15: Write

        public NbtCompound Write()
        {
            var BaseCPE = new NbtCompound("CPE");

            if (ClickDistanceVersion > 0)
            {
                var ClickDistanceTag = new NbtCompound("ClickDistance") {
                    new NbtInt("ExtensionVersion", ClickDistanceVersion),
                    new NbtShort("Distance", ClickDistance)
                };

                BaseCPE.Add(ClickDistanceTag);
            }

            if (CustomBlocksVersion > 0)
            {
                var CustomBlocksTag = new NbtCompound("CustomBlocks") {
                    new NbtInt("ExtensionVersion", CustomBlocksVersion),
                    new NbtShort("SupportLevel", CustomBlocksLevel),
                    new NbtByteArray("Fallback", CustomBlocksFallback)
                };

                BaseCPE.Add(CustomBlocksTag);
            }

            if (EnvColorsVersion > 0)
            {
                var EnvColorsTag = new NbtCompound("EnvColors") {
                    new NbtInt("ExtensionVersion", EnvColorsVersion),
                    new NbtCompound("Sky") {
                        new NbtShort("R", SkyColor[0]),
                        new NbtShort("G", SkyColor[1]),
                        new NbtShort("B", SkyColor[2])
                    },
                    new NbtCompound("Cloud") {
                        new NbtShort("R", CloudColor[0]),
                        new NbtShort("G", CloudColor[1]),
                        new NbtShort("B", CloudColor[2])
                    },
                    new NbtCompound("Fog") {
                        new NbtShort("R", FogColor[0]),
                        new NbtShort("G", FogColor[1]),
                        new NbtShort("B", FogColor[2])
                    },
                    new NbtCompound("Ambient") {
                        new NbtShort("R", AmbientColor[0]),
                        new NbtShort("G", AmbientColor[1]),
                        new NbtShort("B", AmbientColor[2])
                    },
                    new NbtCompound("Sunlight") {
                        new NbtShort("R", SunlightColor[0]),
                        new NbtShort("G", SunlightColor[1]),
                        new NbtShort("B", SunlightColor[2])
                    }
                };

                BaseCPE.Add(EnvColorsTag);
            }

            if (EnvMapAppearanceVersion > 0)
            {
                var EnvAppearanceTag = new NbtCompound("EnvMapAppearance") {
                    new NbtInt("ExtensionVersion",EnvMapAppearanceVersion),
                    new NbtString("TextureURL",TextureURL),
                    new NbtByte("SideBlock",SideBlock),
                    new NbtByte("EdgeBlock", EdgeBlock),
                    new NbtShort("SideLevel", SideLevel)
                };

                BaseCPE.Add(BaseCPE);
            }

            if (BaseCPE.Tags.Count() > 0)
                return BaseCPE;
            else
                return null;
        }
开发者ID:headdetect,项目名称:MCForge6-Vanilla,代码行数:77,代码来源:ClassicWorld.cs


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