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


C# NbtCompound类代码示例

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


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

示例1: SetCompound

 public override void SetCompound(NbtCompound compound)
 {
     Line1 = GetTextValue(compound, "Text1");
     Line2 = GetTextValue(compound, "Text2");
     Line3 = GetTextValue(compound, "Text3");
     Line4 = GetTextValue(compound, "Text4");
 }
开发者ID:LiveMC,项目名称:SharpMC,代码行数:7,代码来源:SignTileEntity.cs

示例2: UpdateTileEntityPacket

 public UpdateTileEntityPacket(Vector3 position, TileEntityAction action, NbtCompound data)
 {
     Data = new NbtFile();
     Data.RootTag = data;
     Position = position;
     Action = action;
 }
开发者ID:Imperceptus,项目名称:Craft.Net,代码行数:7,代码来源:UpdateTileEntityPacket.cs

示例3: ErrorTest

        public void ErrorTest()
        {
            var root = new NbtCompound("root");
            byte[] testData = new NbtFile(root).SaveToBuffer(NbtCompression.None);

            // creating NbtReader without a stream, or with a non-readable stream
            Assert.Throws<ArgumentNullException>(() => new NbtReader(null));
            Assert.Throws<ArgumentException>(() => new NbtReader(new NonReadableStream()));

            // corrupt the data
            testData[0] = 123;
            var reader = new NbtReader(new MemoryStream(testData));

            // attempt to use ReadValue when not at value
            Assert.Throws<InvalidOperationException>(() => reader.ReadValue());
            reader.CacheTagValues = true;
            Assert.Throws<InvalidOperationException>(() => reader.ReadValue());

            // attempt to read a corrupt stream
            Assert.Throws<NbtFormatException>(() => reader.ReadToFollowing());

            // make sure we've properly entered the error state
            Assert.IsTrue(reader.IsInErrorState);
            Assert.IsFalse(reader.HasName);
            Assert.Throws<InvalidReaderStateException>(() => reader.ReadToFollowing());
            Assert.Throws<InvalidReaderStateException>(() => reader.ReadListAsArray<int>());
            Assert.Throws<InvalidReaderStateException>(() => reader.ReadToNextSibling());
            Assert.Throws<InvalidReaderStateException>(() => reader.ReadToDescendant("derp"));
            Assert.Throws<InvalidReaderStateException>(() => reader.ReadAsTag());
            Assert.Throws<InvalidReaderStateException>(() => reader.Skip());
        }
开发者ID:johndpalm,项目名称:fNbt,代码行数:31,代码来源:NbtReaderTests.cs

示例4: ToNBT

 public override NbtCompound ToNBT()
 {
     NbtCompound c = new NbtCompound();
     Base2NBT(ref c);
     c.Tags.Add(Inventory.ToNBT());
     return c;
 }
开发者ID:herpit,项目名称:MineEdit,代码行数:7,代码来源:Chest.cs

示例5: LoadEntity

 public static McEntity LoadEntity(NbtCompound entity)
 {
     if (entity["id"] != null && entity["id"] is NbtString)
     {
         switch (((NbtString) entity["id"]).Value.ToLower())
         {
             case "mob":
                 McEntityMob mob = new McEntityMob();
                 mob.LoadEntity(entity);
                 return mob;
             case "item":
                 McEntityItem item = new McEntityItem();
                 item.LoadEntity(entity);
                 return item;
             case "localplayer":
                 McEntityLocalPlayer player = new McEntityLocalPlayer();
                 player.LoadEntity(entity);
                 return player;
             default:
                 Console.WriteLine("Unknown Entity: {0}", ((NbtString) entity["id"]).Value);
                 break;
         }
     }
     return null;
 }
开发者ID:aphistic,项目名称:libminecraft,代码行数:25,代码来源:McEntityLoader.cs

示例6: FurnaceBlockEntity

        public FurnaceBlockEntity()
            : base("Furnace")
        {
            UpdatesOnTick = true;

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

            NbtList items = (NbtList) Compound["Items"];
            for (byte i = 0; i < 3; i++)
            {
                items.Add(new NbtCompound()
                {
                    new NbtByte("Count", 0),
                    new NbtByte("Slot", i),
                    new NbtShort("id", 0),
                    new NbtByte("Damage", 0),
                });
            }
        }
开发者ID:shishir333,项目名称:MiNET,代码行数:26,代码来源:FurnaceBlockEntity.cs

示例7: SkippingLists

 public void SkippingLists()
 {
     {
         var file = new NbtFile(TestFiles.MakeListTest());
         byte[] savedFile = file.SaveToBuffer(NbtCompression.None);
         file.LoadFromBuffer(savedFile, 0, savedFile.Length, NbtCompression.None,
                             tag => tag.TagType != NbtTagType.List);
         Assert.AreEqual(0, file.RootTag.Count);
     }
     {
         // Check list-compound interaction
         NbtCompound comp = new NbtCompound("root") {
             new NbtCompound("compOfLists") {
                 new NbtList("listOfComps") {
                     new NbtCompound {
                         new NbtList("emptyList", NbtTagType.Compound)
                     }
                 }
             }
         };
         var file = new NbtFile(comp);
         byte[] savedFile = file.SaveToBuffer(NbtCompression.None);
         file.LoadFromBuffer(savedFile, 0, savedFile.Length, NbtCompression.None,
                             tag => tag.TagType != NbtTagType.List);
         Assert.AreEqual(1, file.RootTag.Count);
     }
 }
开发者ID:fragmer,项目名称:fNbt,代码行数:27,代码来源:TagSelectorTests.cs

示例8: SetCompound

 public override void SetCompound(NbtCompound compound)
 {
     Text1 = GetTextValue(compound, "Text1");
     Text2 = GetTextValue(compound, "Text2");
     Text3 = GetTextValue(compound, "Text3");
     Text4 = GetTextValue(compound, "Text4");
 }
开发者ID:WilliamGao1,项目名称:MiNET,代码行数:7,代码来源:Sign.cs

示例9: ToNBT

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

示例10: 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

示例11: ToNBT

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

示例12: LivingEntity

 public LivingEntity(NbtCompound c)
 {
     SetBaseStuff(c);
     Health = (c["Health"] as NbtShort).Value;
     HurtTime = (c["HurtTime"] as NbtShort).Value;
     AttackTime = (c["AttackTime"] as NbtShort).Value;
     DeathTime = (c["DeathTime"] as NbtShort).Value;
 }
开发者ID:herpit,项目名称:MineEdit,代码行数:8,代码来源:LivingEntity.cs

示例13: ToNBT

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

示例14: Read

        public NbtCompound Read(NbtCompound metadata) {
            Tags = new NbtTag[metadata.Tags.Count()];
            metadata.CopyTo(Tags, 0);

            foreach (NbtTag b in Tags) 
                metadata.Remove(b);

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

示例15: TileEntity

 /// <summary>
 /// Load a TileEntity's basic values (call via base() in all inheriting files)
 /// </summary>
 /// <param name="CX">Chunk X Coordinate</param>
 /// <param name="CY">Chunk Y Coordinate</param>
 /// <param name="CS">Chunk horizontal scale</param>
 /// <param name="c">TileEntity's NbtCompound.</param>
 public TileEntity(int CX,int CY,int CS,NbtCompound c)
 {
     Pos = new Vector3i(
         c.Get<NbtInt>("x").Value,
         c.Get<NbtInt>("y").Value,
         c.Get<NbtInt>("z").Value);
     ID = (c["id"] as NbtString).Value;
     orig = c;
 }
开发者ID:N3X15,项目名称:MineEdit,代码行数:16,代码来源:TileEntity.cs


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