예제 #1
0
    public void OnCreativeInventoryAction(IMinecraftUser user, IMinecraftPacket packet)
    {
        short slot = (short)(packet.ReadInt16() - RedstoneContants.PlayerInventoryHotbarOffset);
        // item slot structure
        bool present = packet.ReadBoolean();

        if (present)
        {
            int         itemId     = packet.ReadVarInt32();
            byte        itemCount  = packet.ReadByte();
            NbtCompound itemExtras = packet.ReadNbtCompound();

            _logger.LogInformation($"Item with id: {itemId} (x{itemCount}) set at slot {slot}");
            user.Player.HotBar.SetItem(slot, itemId, itemCount);
        }
        else
        {
            _logger.LogInformation($"Clearing item slot '{slot}'");
            user.Player.HotBar.ClearItem(slot);
        }
    }