예제 #1
0
        private Packet CreatePe(byte messageId, ReadOnlyMemory <byte> buffer)
        {
            Packet packet = null;

            try
            {
                switch (messageId)
                {
                case 111:     //Fixes entity delta
                    packet = new EntityDelta();
                    break;

                //The following are only here so we can join.
                case 49:
                    packet = new InventoryContent();
                    break;

                case 31:
                    packet = new MobEquipment();
                    break;

                case 122:
                    packet = new BiomeDefinitionList();
                    break;

                case 119:
                    packet = new AvailableEntityIdentifiers();
                    break;

                case 32:
                    packet = new MobArmorEquipment();
                    break;

                case 50:
                    packet = new InventorySlot();
                    break;

                case 7:
                    packet = new McpeResourcePackStack();
                    break;

                case 39:
                    packet = new McpeSetEntityData();
                    break;
                }

                packet?.Decode(buffer);
            }
            catch (Exception ex)
            {
                if (messageId != 39)
                {
                    //    Log.Error(ex, $"Processing error: {ex.ToString()}");
                }
            }

            return(packet);
        }
예제 #2
0
        private Packet CreatePe(byte messageId, ReadOnlyMemory <byte> buffer)
        {
            Packet packet = null;

            try
            {
                switch (messageId)
                {
                //  case 0x07:
                //      packet = new McpeResourcePackStack();
                //      break;
                case 0x0c:
                    packet = new AddPlayer();
                    break;

                //The following are only here so we can join.
                //  case 0x1F:
                //    packet = new MobEquipment();
                //  break;
                case 0x20:
                    packet = new MobArmorEquipment();

                    break;

                case 0x27:
                    packet = new SetEntityData();
                    break;

                case 0x31:
                    packet = new InventoryContent();
                    break;

                case 0x32:
                    packet = new InventorySlot();
                    break;

                case 0x6f:     //Fixes entity delta
                    packet = new EntityDelta();
                    break;

                case 0x77:
                    packet = new AvailableEntityIdentifiers();
                    break;

                case 0x7a:
                    packet = new BiomeDefinitionList();
                    break;
                }

                packet?.Decode(buffer);
            }
            catch (Exception ex)
            {
                //  if (messageId != 0x31)
                {
                    Log.Error(ex, $"Processing error: {ex.ToString()}");
                }
            }

            return(packet);
        }