private void HandleMcpeInventoryContent(McpeInventoryContent message)
 {
     if (message.inventoryId == 0x00)
     {
         _inventory = message.input;
     }
 }
Beispiel #2
0
        public override void HandleMcpeInventoryContent(McpeInventoryContent message)
        {
            Inventory inventory = null;

            if (message.inventoryId == 0x00)
            {
                if (BaseClient.WorldReceiver?.GetPlayerEntity() is Player player)
                {
                    inventory = player.Inventory;
                }
            }

            if (inventory == null)
            {
                return;
            }

            for (var index = 0; index < message.input.Count; index++)
            {
                var slot = message.input[index];

                var usedIndex = index;

                if (ItemFactory.TryGetItem(slot.Id, slot.Metadata, out Item item))
                {
                    item.Count           = slot.Count;
                    inventory[usedIndex] = item;
                }
                else
                {
                    Log.Warn($"Failed to set slot: {index} Id: {slot.Id}:{slot.Metadata}");
                }
            }
        }
        private void HandleMcpeInventoryContent(McpeInventoryContent message)
        {
            if (message.inventoryId == 0x00)
            {
                _inventory = message.input;

                if (message.input.Count > 0)
                {
                    lock (_lastItem)
                    {
                        var item = message.input.FirstOrDefault(x => x.Count > 0);

                        if (item != null && item is not ItemAir && item.Count > 0)
                        {
                            _lastItem = item;
                            _resetEventInventorySlot.Set();
                        }
                    }
                }
            }
        }
Beispiel #4
0
        public void Open(Player player)
        {
            if (!_horse.IsTamed)
            {
                return;
            }

            player.SetOpenInventory(this);

            McpeUpdateEquipment equ = McpeUpdateEquipment.CreateObject();

            equ.entityId   = _horse.EntityId;
            equ.windowId   = 2;
            equ.windowType = 12;

            Nbt nbt = new Nbt
            {
                NbtFile = new NbtFile
                {
                    BigEndian = false,
                    UseVarInt = true,
                    RootTag   = GetNbt()
                }
            };

            equ.namedtag = nbt;

            player.SendPacket(equ);

            McpeInventoryContent containerSetContent = McpeInventoryContent.CreateObject();

            containerSetContent.inventoryId = 2;
            containerSetContent.input       = new ItemStacks()
            {
                Slot0,
                Slot1
            };
            player.SendPacket(containerSetContent);
        }
Beispiel #5
0
        public override void HandleMcpeInventoryContent(McpeInventoryContent message)
        {
            Log.Debug($"Set container content on Window ID: 0x{message.inventoryId:x2}, Count: {message.input.Count}");

            if (Client.IsEmulator)
            {
                return;
            }

            ItemStacks slots = message.input;

            if (message.inventoryId == 0x79)
            {
                string fileName = Path.GetTempPath() + "Inventory_0x79_" + Guid.NewGuid() + ".txt";
                Client.WriteInventoryToFile(fileName, slots);
            }
            else if (message.inventoryId == 0x00)
            {
                string fileName = Path.GetTempPath() + "Inventory_0x00_" + Guid.NewGuid() + ".txt";
                Client.WriteInventoryToFile(fileName, slots);
            }
        }
 public void HandleMcpeInventoryContent(McpeInventoryContent message)
 {
 }
 public abstract void HandleMcpeInventoryContent(McpeInventoryContent message);
        public void OpenInventory(Player player)
        {
            //Log.Info("Command Executed!");
            player.SendMessage("Opening Chest...");

            /*BlockCoordinates coords = (BlockCoordinates) player.KnownPosition;
             * coords.Y = 0;*/
            BlockCoordinates coords = new BlockCoordinates(0);

            //Block past = player.Level.GetBlock(coords);

            McpeUpdateBlock chest = Package <McpeUpdateBlock> .CreateObject();

            chest.blockId              = 54;
            chest.coordinates          = coords;
            chest.blockMetaAndPriority = 0 & 15;
            player.SendPackage(chest);

            ChestBlockEntity blockEntity = new ChestBlockEntity {
                Coordinates = coords
            };
            NbtCompound compound = blockEntity.GetCompound();

            compound["CustomName"] = new NbtString("CustomName", "§5§k--§r §l§o§2Virtual Chest§r §5§k--§r");
            //player.Level.SetBlockEntity(blockEntity);
            McpeBlockEntityData chestEntity = Package <McpeBlockEntityData> .CreateObject();

            chestEntity.namedtag = new Nbt
            {
                NbtFile = new NbtFile
                {
                    BigEndian = false,
                    UseVarInt = true,
                    RootTag   = compound
                }
            };
            chestEntity.coordinates = coords;
            player.SendPackage(chestEntity);

            //player.OpenInventory(coords);
            Inventory inventory = new Inventory(0, blockEntity, 1, new NbtList())
            {
                Type      = 0,
                WindowsId = 10
            };

            //inventory.InventoryChange += new Action<Player, MiNET.Inventory, byte, Item>(player.OnInventoryChange);
            inventory.AddObserver(player);
            McpeContainerOpen mcpeContainerOpen = Package <McpeContainerOpen> .CreateObject(1L);

            mcpeContainerOpen.windowId               = inventory.WindowsId;
            mcpeContainerOpen.type                   = inventory.Type;
            mcpeContainerOpen.coordinates            = coords;
            mcpeContainerOpen.unknownRuntimeEntityId = 1L;
            player.SendPackage((Package)mcpeContainerOpen);
            McpeInventoryContent inventoryContent = Package <McpeInventoryContent> .CreateObject(1L);

            inventoryContent.inventoryId = (uint)inventory.WindowsId;
            inventoryContent.input       = inventory.Slots;
            player.SendPackage((Package)inventoryContent);
        }
Beispiel #9
0
 public override void HandleMcpeInventoryContent(McpeInventoryContent message)
 {
 }