示例#1
0
		public void Write(Nbt nbt)
		{
			var file = nbt.NbtFile;
			file.BigEndian = false;

			Write(file.SaveToBuffer(NbtCompression.None));
		}
示例#2
0
		public void BlockEntityTest()
		{
			NbtFile file = new NbtFile();
			file.BigEndian = false;
			var compound = file.RootTag = new NbtCompound(string.Empty);
			compound.Add(new NbtString("Text1", "first line"));
			compound.Add(new NbtString("Text2", "second line"));
			compound.Add(new NbtString("Text3", "third line"));
			compound.Add(new NbtString("Text4", "forth line"));
			compound.Add(new NbtString("id", "Sign"));
			compound.Add(new NbtInt("x", 6));
			compound.Add(new NbtInt("y", 6));
			compound.Add(new NbtInt("z", 6));

			Console.WriteLine(file.ToString());

			Nbt nbt = new Nbt();
			nbt.NbtFile = file;
			McpeTileEntityData message = new McpeTileEntityData()
			{
				x = 6,
				y = 6,
				z = 6,
				namedtag = nbt
			};

			Assert.NotNull(message.Encode());
			Console.WriteLine(ByteArrayToString(message.Encode()));

			var b = new byte[]
			{
				0xb8, 0x00, 0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x00, 0x06, 0x0a, 0x00, 0x00, 0x08, 0x02,
				0x00, 0x49, 0x64, 0x04, 0x00, 0x53, 0x69, 0x67, 0x6e, 0x03, 0x01, 0x00, 0x78, 0x06, 0x00,
				0x00, 0x00, 0x03, 0x01, 0x00, 0x79, 0x06, 0x00, 0x00, 0x00, 0x03, 0x01, 0x00, 0x7a, 0x06,
				0x00, 0x00, 0x00, 0x08, 0x05, 0x00, 0x54, 0x65, 0x78, 0x74, 0x31, 0x0a, 0x00, 0x66, 0x69,
				0x72, 0x73, 0x74, 0x20, 0x6c, 0x69, 0x6e, 0x65, 0x08, 0x05, 0x00, 0x54, 0x65, 0x78, 0x74,
				0x32, 0x0b, 0x00, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x20, 0x6c, 0x69, 0x6e, 0x65, 0x08,
				0x05, 0x00, 0x54, 0x65, 0x78, 0x74, 0x33, 0x0a, 0x00, 0x74, 0x68, 0x69, 0x72, 0x64, 0x20,
				0x6c, 0x69, 0x6e, 0x65, 0x08, 0x05, 0x00, 0x54, 0x65, 0x78, 0x74, 0x34, 0x0a, 0x00, 0x66,
				0x6f, 0x72, 0x74, 0x68, 0x20, 0x6c, 0x69, 0x6e, 0x65, 0x00,
			};
		}