本文整理汇总了C#中System.IO.BinaryWriter.WriteNetwork方法的典型用法代码示例。如果您正苦于以下问题:C# BinaryWriter.WriteNetwork方法的具体用法?C# BinaryWriter.WriteNetwork怎么用?C# BinaryWriter.WriteNetwork使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.BinaryWriter
的用法示例。
在下文中一共展示了BinaryWriter.WriteNetwork方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateHandshakePacket
public static byte[] CreateHandshakePacket(string username)
{
byte[] buffer;
BinaryWriter writer = new BinaryWriter(new MemoryStream());
writer.Write((byte)MCPacketOpcodes.Handshake);
writer.WriteNetwork(username);
buffer = new byte[writer.BaseStream.Position];
writer.BaseStream.Position = 0;
writer.BaseStream.Read(buffer, 0, buffer.Length);
writer.Close();
writer.Dispose();
return buffer;
}
示例2: CreateDisconnectPacket
public static byte[] CreateDisconnectPacket(string message)
{
byte[] buffer;
BinaryWriter writer = new BinaryWriter(new MemoryStream());
writer.Write((byte)MCPacketOpcodes.Disconnect);
writer.WriteNetwork(message);
buffer = new byte[writer.BaseStream.Position];
writer.BaseStream.Position = 0;
writer.BaseStream.Read(buffer, 0, buffer.Length);
writer.Close();
writer.Dispose();
return buffer;
}
示例3: CreateArmAnimationPacket
public static byte[] CreateArmAnimationPacket(int id, bool animate)
{
byte[] buffer;
BinaryWriter writer = new BinaryWriter(new MemoryStream());
writer.Write((byte)MCPacketOpcodes.ArmAnimation);
writer.WriteNetwork(id);
writer.Write(animate);
buffer = new byte[writer.BaseStream.Position];
writer.BaseStream.Position = 0;
writer.BaseStream.Read(buffer, 0, buffer.Length);
writer.Close();
writer.Dispose();
return buffer;
}
示例4: CreatePlayerPositionPacket
public static byte[] CreatePlayerPositionPacket(double x, double y, double stance, double z, bool ground)
{
byte[] buffer;
BinaryWriter writer = new BinaryWriter(new MemoryStream());
writer.Write((byte)MCPacketOpcodes.PlayerPosition);
writer.WriteNetwork(x);
writer.WriteNetwork(y);
writer.WriteNetwork(stance);
writer.WriteNetwork(z);
writer.Write(ground);
buffer = new byte[writer.BaseStream.Position];
writer.BaseStream.Position = 0;
writer.BaseStream.Read(buffer, 0, buffer.Length);
writer.Close();
writer.Dispose();
return buffer;
}
示例5: CreatePlayerLookPacket
public static byte[] CreatePlayerLookPacket(float yaw, float pitch, bool ground)
{
byte[] buffer;
BinaryWriter writer = new BinaryWriter(new MemoryStream());
writer.Write((byte)MCPacketOpcodes.PlayerLook);
writer.WriteNetwork(yaw);
writer.WriteNetwork(pitch);
writer.Write(ground);
buffer = new byte[writer.BaseStream.Position];
writer.BaseStream.Position = 0;
writer.BaseStream.Read(buffer, 0, buffer.Length);
writer.Close();
writer.Dispose();
return buffer;
}
示例6: CreatePlayerInventoryPacket
public static byte[] CreatePlayerInventoryPacket(MCInventoryType type, MCItem[] items)
{
byte[] buffer;
BinaryWriter writer = new BinaryWriter(new MemoryStream());
writer.Write((byte)MCPacketOpcodes.PlayerInventory);
writer.WriteNetwork((int)type);
writer.WriteNetwork((short)items.Length);
foreach (MCItem item in items)
{
writer.WriteNetwork((short)item.Type);
if (item.Type != MCBlockType.None)
{
writer.Write(item.Count);
writer.WriteNetwork(item.Health);
}
}
buffer = new byte[writer.BaseStream.Position];
writer.BaseStream.Position = 0;
writer.BaseStream.Read(buffer, 0, buffer.Length);
writer.Close();
writer.Dispose();
return buffer;
}
示例7: CreatePlayerHoldingPacket
public static byte[] CreatePlayerHoldingPacket(int id, short item)
{
byte[] buffer;
BinaryWriter writer = new BinaryWriter(new MemoryStream());
writer.Write((byte)MCPacketOpcodes.HoldSwitch);
writer.WriteNetwork(id);
writer.WriteNetwork(item);
buffer = new byte[writer.BaseStream.Position];
writer.BaseStream.Position = 0;
writer.BaseStream.Read(buffer, 0, buffer.Length);
writer.Close();
writer.Dispose();
return buffer;
}
示例8: CreatePlayerDiggingPacket
public static byte[] CreatePlayerDiggingPacket(byte status, int x, byte y, int z, byte face)
{
byte[] buffer;
BinaryWriter writer = new BinaryWriter(new MemoryStream());
writer.Write((byte)MCPacketOpcodes.BlockDig);
writer.Write(status);
writer.WriteNetwork(x);
writer.Write(y);
writer.WriteNetwork(z);
writer.Write(face);
buffer = new byte[writer.BaseStream.Position];
writer.BaseStream.Position = 0;
writer.BaseStream.Read(buffer, 0, buffer.Length);
writer.Close();
writer.Dispose();
return buffer;
}
示例9: CreateLoginPacket
public static byte[] CreateLoginPacket(string username, string password)
{
byte[] buffer;
BinaryWriter writer = new BinaryWriter(new MemoryStream());
writer.Write((byte)MCPacketOpcodes.Login);
writer.WriteNetwork(2); // Protocol version
writer.WriteNetwork(username);
writer.WriteNetwork(password);
buffer = new byte[writer.BaseStream.Position];
writer.BaseStream.Position = 0;
writer.BaseStream.Read(buffer, 0, buffer.Length);
writer.Close();
writer.Dispose();
return buffer;
}