public SpawnNamedEntityPacket(MinecraftClient client)
 {
     EntityId = client.Entity.Id;
     PlayerName = client.Username;
     Position = client.Entity.Position;
     Yaw = client.Entity.Yaw;
     Pitch = client.Entity.Pitch;
     CurrentItem = 0; // TODO
     Metadata = client.Entity.Metadata;
 }
示例#2
0
 public static bool TryReadMetadata(byte[] buffer, ref int offset, int length, out MetadataDictionary value)
 {
     value = new MetadataDictionary();
     while (buffer[offset] != 127)
     {
         byte key = buffer[offset];
         byte type = (byte)((key & 0xE0) >> 5);
         byte index = (byte)(key & 0x1F);
         var entryType = entryTypes[type];
         value[index] = (MetadataEntry)Activator.CreateInstance(entryType, index);
         if (!value[index].TryReadEntry(buffer, ref offset, length))
             return false;
         if (offset >= buffer.Length)
             return false;
     }
     offset++;
     return true;
 }