Esempio n. 1
0
        public void GameMode(Player player, int gameMode)
        {
            if (gameMode == 1)
            {
                player.Inventory.Slots.Clear();

                player.Inventory.Slots.AddRange(InventoryUtils.CreativeInventoryItems);
            }

            //player.GameMode = (GameMode) gameMode;

            player.SendPackage(new McpeStartGame
            {
                seed      = -1,
                generator = 1,
                gamemode  = gameMode,
                entityId  = player.EntityId,
                spawnX    = (int)player.Level.SpawnPoint.X,
                spawnY    = (int)player.Level.SpawnPoint.Y,
                spawnZ    = (int)player.Level.SpawnPoint.Z,
                x         = player.KnownPosition.X,
                y         = player.KnownPosition.Y,
                z         = player.KnownPosition.Z
            });

            {
                McpeContainerSetContent creativeContent = McpeContainerSetContent.CreateObject();
                creativeContent.windowId   = (byte)0x79;
                creativeContent.slotData   = player.Inventory.GetSlots();
                creativeContent.hotbarData = player.Inventory.GetHotbar();
                player.SendPackage(creativeContent);
            }

            player.Level.BroadcastMessage(string.Format("{0} changed to game mode {1}.", player.Username, gameMode), type: MessageType.Raw);
        }
Esempio n. 2
0
        public void SetInventorySlot(int slot, short itemId, byte amount = 1, short metadata = 0)
        {
            Slots[slot] = new ItemStack(itemId, amount, metadata);

            var containerSetContent = McpeContainerSetContent.CreateObject();

            containerSetContent.windowId   = 0;
            containerSetContent.slotData   = GetSlots();
            containerSetContent.hotbarData = GetHotbar();
            Player.SendPackage(containerSetContent);
        }
Esempio n. 3
0
        public override void HandleMcpeContainerSetSlot(McpeContainerSetSlot message)
        {
            if (message.item.Id == Inventory.Slots[message.slot].Id)
            {
                if (message.item.Count == Inventory.Slots[message.slot].Count)
                {
                    return;
                }
            }
            if (Level is xCoreLevel)
            {
                if (!(((xCoreLevel)Level).Status == Status.Start))
                {
                    base.HandleMcpeContainerSetSlot(message);
                }
                else
                {
                    if (message.hotbarslot == 0)
                    {
                        McpeContainerSetContent strangeContent = McpeContainerSetContent.CreateObject();
                        strangeContent.windowId     = (byte)0x7b;
                        strangeContent.entityIdSelf = EntityId;
                        strangeContent.slotData     = new ItemStacks();
                        strangeContent.hotbarData   = new MetadataInts();
                        SendPackage(strangeContent);

                        McpeContainerSetContent inventoryContent = McpeContainerSetContent.CreateObject();
                        inventoryContent.windowId     = (byte)0x00;
                        inventoryContent.entityIdSelf = EntityId;
                        inventoryContent.slotData     = Inventory.GetSlots();
                        inventoryContent.hotbarData   = Inventory.GetHotbar();
                        SendPackage(inventoryContent);

                        McpeMobEquipment order = McpeMobEquipment.CreateObject();
                        order.runtimeEntityId = EntityManager.EntityIdSelf;
                        order.item            = message.item;
                        order.selectedSlot    = (byte)message.selectedSlot;                      // Selected hotbar slot
                        order.slot            = (byte)message.slot;
                        SendPackage(order);
                        //SendPlayerInventory();
                    }
                    return;
                }
            }
            else
            {
                if (message.hotbarslot == 0)
                {
                    McpeContainerSetContent strangeContent = McpeContainerSetContent.CreateObject();
                    strangeContent.windowId     = (byte)0x7b;
                    strangeContent.entityIdSelf = EntityId;
                    strangeContent.slotData     = new ItemStacks();
                    strangeContent.hotbarData   = new MetadataInts();
                    SendPackage(strangeContent);

                    McpeContainerSetContent inventoryContent = McpeContainerSetContent.CreateObject();
                    inventoryContent.windowId     = (byte)0x00;
                    inventoryContent.entityIdSelf = EntityId;
                    inventoryContent.slotData     = Inventory.GetSlots();
                    inventoryContent.hotbarData   = Inventory.GetHotbar();
                    SendPackage(inventoryContent);
                }
                return;
            }
            base.HandleMcpeContainerSetSlot(message);
        }