本文整理匯總了C#中System.IO.BinaryReader.ReadNetworkInt32方法的典型用法代碼示例。如果您正苦於以下問題:C# BinaryReader.ReadNetworkInt32方法的具體用法?C# BinaryReader.ReadNetworkInt32怎麽用?C# BinaryReader.ReadNetworkInt32使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.IO.BinaryReader
的用法示例。
在下文中一共展示了BinaryReader.ReadNetworkInt32方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: NBT_List
public NBT_List(BinaryReader reader, string name)
{
Name = name;
m_Items = new List<INamedBinaryTag>();
NBT_Type type = (NBT_Type)reader.ReadByte();
int len = reader.ReadNetworkInt32();
EntryType = type;
// this loop can be optimized by actually switching first then looping, but THAT'S UGLY
// AND I DON'T LIKE UGLY CODE, EVEN IF IT'S FASTER
for (int i = 0; i < len; i++)
{
switch (type)
{
case NBT_Type.Byte:
m_Items.Add(new NBT_Byte(reader));
break;
case NBT_Type.ByteArray:
m_Items.Add(new NBT_ByteArray(reader));
break;
case NBT_Type.Compound:
m_Items.Add(new NBT_Compound(reader));
break;
case NBT_Type.Double:
m_Items.Add(new NBT_Double(reader));
break;
case NBT_Type.End: // Highly unprobable but protocol doesn't exclude it
m_Items.Add(new NBT_End());
break;
case NBT_Type.Float:
m_Items.Add(new NBT_Float(reader));
break;
case NBT_Type.Int:
m_Items.Add(new NBT_Int(reader));
break;
case NBT_Type.List:
m_Items.Add(new NBT_List(reader));
break;
case NBT_Type.Long:
m_Items.Add(new NBT_Long(reader));
break;
case NBT_Type.Short:
m_Items.Add(new NBT_Short(reader));
break;
case NBT_Type.String:
m_Items.Add(new NBT_String(reader));
break;
}
}
}
示例2: ParseMobSpawn
private void ParseMobSpawn(BinaryReader reader)
{
HandleMobSpawn(reader.ReadNetworkInt32(), reader.ReadByte(), reader.ReadNetworkInt32(), reader.ReadNetworkInt32(), reader.ReadNetworkInt32(), reader.ReadByte(), reader.ReadByte());
}
示例3: ParseMapChunk
private void ParseMapChunk(BinaryReader reader)
{
int x = reader.ReadNetworkInt32();
short y = reader.ReadNetworkInt16();
int z = reader.ReadNetworkInt32();
byte size_x = reader.ReadByte();
byte size_y = reader.ReadByte();
byte size_z = reader.ReadByte();
int size = reader.ReadNetworkInt32();
if (reader.BaseStream.Position + size > reader.BaseStream.Length) // Like omg BinaryReader won't throw exceptions
throw new EndOfStreamException("Reader has reached end of stream."); // if you read past the end of the stream :@
byte[] data = Compression.DecompressZLib(reader.ReadBytes(size));
// parse data block
size_x++;
size_y++;
size_z++;
// wat to do here... hmm
MCBlock[, ,] blockdata = new MCBlock[size_x, size_y, size_z];
BinaryReader parser = new BinaryReader(new MemoryStream(data));
byte[] blocks = parser.ReadBytes(size_x * size_y * size_z);
byte[] metadatas = new byte[blocks.Length];
byte[] lights = new byte[blocks.Length];
byte[] skylights = new byte[blocks.Length];
for (int i = 0; i < blocks.Length; i += 2)
{
byte metadata = parser.ReadByte();
metadatas[i] = (byte)((metadata >> 4) & 0xF);
metadatas[i + 1] = (byte)(metadata & 0xF);
}
for (int i = 0; i < blocks.Length; i += 2)
{
byte light = parser.ReadByte();
lights[i] = (byte)((light >> 4) & 0xF);
lights[i + 1] = (byte)(light & 0xF);
}
for (int i = 0; i < blocks.Length; i += 2)
{
byte skylight = parser.ReadByte();
skylights[i] = (byte)((skylight >> 4) & 0xF);
skylights[i + 1] = (byte)(skylight & 0xF);
}
for (int iX = 0; iX < size_x; iX++)
{
for (int iY = 0; iY < size_y; iY++)
{
for (int iZ = 0; iZ < size_z; iZ++)
{
int index = iY + (iZ * size_y) + (iX * size_y * size_z);
blockdata[iX, iY, iZ] = new MCBlock();
blockdata[iX, iY, iZ].Type = (MCBlockType)blocks[index];
blockdata[iX, iY, iZ].MetaData = metadatas[index];
blockdata[iX, iY, iZ].Light = lights[index];
blockdata[iX, iY, iZ].SkyLight = skylights[index];
}
}
}
HandleMapChunk(x, y, z, blockdata);
}
示例4: ParseLogin
private void ParseLogin(BinaryReader reader)
{
HandleLogin(reader.ReadNetworkInt32(), reader.ReadNetworkString(), reader.ReadNetworkString());
}
示例5: ParseHoldSwitch
private void ParseHoldSwitch(BinaryReader reader)
{
HandleHoldSwitch(reader.ReadNetworkInt32(), reader.ReadNetworkInt16());
}
示例6: ParseEntityTeleport
private void ParseEntityTeleport(BinaryReader reader)
{
HandleEntityTeleport(reader.ReadNetworkInt32(), reader.ReadNetworkInt32(), reader.ReadNetworkInt32(), reader.ReadNetworkInt32(), reader.ReadByte(), reader.ReadByte());
}
示例7: NBT_ByteArray
public NBT_ByteArray(BinaryReader reader, string name)
{
Name = name;
Value = reader.ReadBytes(reader.ReadNetworkInt32());
}
示例8: ParseRelativeEntityMoveLook
private void ParseRelativeEntityMoveLook(BinaryReader reader)
{
HandleRelativeEntityMoveLook(reader.ReadNetworkInt32(), reader.ReadByte(), reader.ReadByte(), reader.ReadByte(), reader.ReadByte(), reader.ReadByte());
}
示例9: ParseCollectItem
private void ParseCollectItem(BinaryReader reader)
{
HandleCollectItem(reader.ReadNetworkInt32(), reader.ReadNetworkInt32());
}
示例10: ParseBlockChange
private void ParseBlockChange(BinaryReader reader)
{
HandleBlockChange(reader.ReadNetworkInt32(), reader.ReadByte(), reader.ReadNetworkInt32(), reader.ReadByte(), reader.ReadByte());
}
示例11: ParseArmAnimation
private void ParseArmAnimation(BinaryReader reader)
{
HandleArmAnimation(reader.ReadNetworkInt32(), reader.ReadBoolean());
}
示例12: ParseAddVehicle
private void ParseAddVehicle(BinaryReader reader)
{
HandleAddVehicle(reader.ReadNetworkInt32(), reader.ReadByte(), reader.ReadNetworkInt32(), reader.ReadNetworkInt32(), reader.ReadNetworkInt32());
}
示例13: ParsePlayerInventory
protected void ParsePlayerInventory(BinaryReader reader)
{
int type = reader.ReadNetworkInt32();
short count = reader.ReadNetworkInt16();
List<MCItem> items = new List<MCItem>();
for (int i = 0; i < count; i++)
{
short itemid = reader.ReadNetworkInt16();
if (itemid == -1)
items.Add(new MCItem(-1, 0, 0));
else
items.Add(new MCItem(itemid, reader.ReadByte(), reader.ReadNetworkInt16()));
}
HandlePlayerInventory(type, count, items);
}
示例14: ParseMultiBlockChange
protected void ParseMultiBlockChange(BinaryReader reader)
{
int x = reader.ReadNetworkInt32();
int z = reader.ReadNetworkInt32();
short size = reader.ReadNetworkInt16();
List<MCBlockTransform> changes = new List<MCBlockTransform>();
Vector3D[] relativepos = new Vector3D[size];
byte[] blocks = new byte[size];
byte[] metadatas = new byte[size];
for (short i = 0; i < size; i++)
{
short xyz = reader.ReadNetworkInt16();
int xpos = (xyz >> 12) & 0xF;
int zpos = (xyz >> 8) & 0xF;
int ypos = xyz & 0xFF;
relativepos[i] = new Vector3D(xpos, ypos, zpos);
}
for (short i = 0; i < size; i++)
blocks[i] = reader.ReadByte();
for (short i = 0; i < size; i++)
metadatas[i] = reader.ReadByte();
for (short i = 0; i < size; i++)
changes.Add(new MCBlockTransform(relativepos[i], blocks[i], metadatas[i]));
HandleMultiBlockChange(x, z, size, changes);
}
示例15: NBT_Int
public NBT_Int(BinaryReader reader, string name)
{
Name = name;
Value = reader.ReadNetworkInt32();
}