• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# NbtCompound类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: TileEntity

 /// <summary>
 /// Load a TileEntity's basic values (call via base() in all inheriting files)
 /// </summary>
 /// <param name="c"></param>
 public TileEntity(NbtCompound c)
 {
     orig = c;
     Pos = new Vector3i(
         c.Get<NbtInt>("x").Value,
         c.Get<NbtInt>("z").Value,
         c.Get<NbtInt>("y").Value);
     id = c.Get<NbtString>("id").Value;
 }
开发者ID:herpit,项目名称:MineEdit,代码行数:13,代码来源:TileEntity.cs


示例17: Write

 public NbtCompound Write()
 {
     var Base = new NbtCompound("MCForge")
     {
         new NbtByte("perbuild", perbuild),
         new NbtByte("pervisit", pervisit)
     };
     return Base;
 }
开发者ID:headdetect,项目名称:MCForge6-Vanilla,代码行数:9,代码来源:Level.cs


示例18: Save

        public void Save()
        {
            //Create nbt file
            var file = new NbtFile();
            var data = new NbtCompound() {Name = "Data"};

           
            file.RootTag.Add(data);
        }
开发者ID:Myvar,项目名称:Anvil.Net,代码行数:9,代码来源:AnvilMap.cs


示例19: ToNBT

 public override NbtCompound ToNBT()
 {
     NbtCompound c = new NbtCompound();
     Base2NBT(ref c,GetID());
     c.Tags.Add(new NbtShort("Health", Health));
     c.Tags.Add(new NbtShort("HurtTime", HurtTime));
     c.Tags.Add(new NbtShort("AttackTime", AttackTime));
     c.Tags.Add(new NbtShort("DeathTime", DeathTime));
     return c;
 }
开发者ID:herpit,项目名称:MineEdit,代码行数:10,代码来源:LivingEntity.cs


示例20: Area

 public Area(NbtCompound cmpd)
 {
     name = cmpd.Get<NbtString>("name").Value;
     NbtList ground = cmpd.Get<NbtList>("ground");
     foreach(NbtCompound alpha in ground) {
         int x = alpha.Get<NbtByte>("x").Value;
         int y = alpha.Get<NbtByte>("y").Value;
         platformMap.Add(new Point(x, y));
     }
     Map.portalsToProcess[this] = cmpd.Get<NbtList>("portal").ToArray<NbtCompound>().ToList<NbtCompound>();
 }
开发者ID:RIT-GSD3-Survive,项目名称:Survive,代码行数:11,代码来源:Area.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# NeedPaintHandler类代码示例发布时间:2022-05-24
下一篇:
C# NavigationParameters类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap