本文整理汇总了C#中Craft.Net.Common.MinecraftStream.ReadVarInt方法的典型用法代码示例。如果您正苦于以下问题:C# MinecraftStream.ReadVarInt方法的具体用法?C# MinecraftStream.ReadVarInt怎么用?C# MinecraftStream.ReadVarInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Craft.Net.Common.MinecraftStream
的用法示例。
在下文中一共展示了MinecraftStream.ReadVarInt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadPacket
public NetworkMode ReadPacket(MinecraftStream stream, NetworkMode mode, PacketDirection direction)
{
ProtocolVersion = stream.ReadVarInt();
ServerHostname = stream.ReadString();
ServerPort = stream.ReadUInt16();
NextState = (NetworkMode)stream.ReadVarInt();
return NextState;
}
示例2: ReadPacket
public NetworkMode ReadPacket(MinecraftStream stream, NetworkMode mode, PacketDirection direction)
{
if (direction == PacketDirection.Clientbound)
EntityId = stream.ReadVarInt();
else
EntityId = stream.ReadInt32();
var animation = stream.ReadUInt8();
if (direction == PacketDirection.Clientbound)
{
switch (animation)
{
case 0: Animation = AnimationType.SwingArm; break;
case 1: Animation = AnimationType.Damage; break;
case 2: Animation = AnimationType.LeaveBed; break;
case 3: Animation = AnimationType.EatFood; break;
case 4: Animation = AnimationType.CriticalEffect; break;
case 5: Animation = AnimationType.MagicCriticalEffect; break;
case 104: Animation = AnimationType.Crouch; break;
case 105: Animation = AnimationType.Uncrouch; break;
}
}
else
{
switch (animation)
{
case 0: Animation = AnimationType.NoAnimation; break;
case 1: Animation = AnimationType.SwingArm; break;
case 2: Animation = AnimationType.Damage; break;
case 3: Animation = AnimationType.LeaveBed; break;
case 5: Animation = AnimationType.EatFood; break;
case 6: Animation = AnimationType.CriticalEffect; break;
case 7: Animation = AnimationType.MagicCriticalEffect; break;
case 104: Animation = AnimationType.Crouch; break;
case 105: Animation = AnimationType.Uncrouch; break;
}
}
return mode;
}