In Java Edition Minecraft there isn’t a built-in feature to connect an Xbox or PS4/5 controller to the game, fortunately for controller lovers, there is a way to connect the controller through steam.
Step 1: Download Steam
For new players and beginners, Steam is a gaming platform where gamers can play, download, discuss, create, and keep track of their games. Here is a link to download steam. The install button is displayed on the home page in the top right corner. Follow the steps Steam provides, open the application, and create an account.
Step 2: Add Minecraft to the Steam Library
Once Step 1 is finished, open up the steam application, and click library. In the bottom left corner there will be a button called "Add a Game." From this button there will be a drop down menu, click "Add a Non-Steam Game." Browse through the computer files for Minecraft Launcher and click on it. Java Edition Minecraft should now be added to the Steam Library.
Step 3: Entering Big Picture Mode
On the Steam Home Library page, in the top right corner between the profile drop-down menu and the minimize button, there will be a button called "Big Picture Mode." Click on this and a steam logo animation will appear, and it will also make Steam full screen.
Step 4: Controller Settings
At this point, plug in the preferred controller to the PC. From there, in the top right corner, click on the settings icon. In settings, click on "Controller Settings."
Inside "Controller Settings" is a plethora of options for different types of console controllers. Select the preferred controller type and make sure the computer detects the controller below the menu. After selecting the controller, go back into the steam library (stay in big picture mode.)
Step 5: Open Manage Shortcut
After entering the Steam Library, open up the Minecraft game. There will be two options under Minecraft, click the bottom one "Manage Shortcut." Inside controller options and configurations are available, make sure to set up the player's preferred controls. When finished configuring, open the Minecraft Launcher from Steam and have fun!