Pumpkins and Melons were added to Minecraft back in Beta before it was even officially released. Since very early on (think back to when Redstone was first released), players have been trying to find easy, efficient ways to harvest them. Before Observers, block updates were not detected automatically, so farming them automatically required extensive knowledge and manipulation of the game mechanics. Thankfully, that's not necessary anymore!
How to Make an Automatic Pumpkin / Melon Farm in Minecraft
We're going to walk you through the steps to make a simple, automatic, and efficient farm for Melons and Pumpkins. Once you've built this farm, it requires no upkeep apart from collecting the melons once they're ready. This farm was originally planned and presented by Youtuber Shulkercraft! It's a straightforward process, albeit a bit expensive when it comes to resources. Let's get started!
Step One: Get the Resources
Shown above are the resources you'll need to need to make this melon/pumpkin farm. If you wish to make a pumpkin farm, replace the 40 melon seeds in the image above with 40 pumpkin seeds. Alternatively, you can make a combination of 20 melon and 20 pumpkin seeds to make a farm that harvests both of them almost equally!
With this farm, you need plenty of rails, pistons, and observer blocks. You'll rarely be able to make an automatic farm without these. The reason you need so many pistons and observer blocks is that melons and pumpkins grow into blocks that must be smashed rather than produce that can be broken and moved by water.
Step Two: Dig the Hole
This hole was dug on a Superflat world, but you'll likely be digging this on a survival world with normal world generation, so it likely won't be as clean cut. The main part of the hole in the above image is 10 x 9 x 2 blocks. On one of the sides that is nine squares long, you'll be digging out extra space for the collection system. The layers of this extra space follow this pattern from top to bottom: 3 * 2, 2 * 2, 1 * 2. In the 1 * 2 space, you'll place the two chests. This is where your harvest melons will show up.
Step Three: Place the Hoppers and Torches
Usually, you will not see Void when you place the Redstone Torches. The only reason you see it in the screenshot above is that the farm in this guide is being built on a Superflat world, so there is limited space available. When facing the hole from the Chest, you want to place two hoppers in front of the chests.
Then, walk over two blocks and dig a hole across the bottom of the farm. This hole will be 1 * 10 * 2 blocks, as shown in the image above. You may place the Redstone Torches however you please, so long as they're placed on the bottom layer in this hole. After that, you'll need to dig another hole 1 * 1 * 2 blocks against the wall five blocks away from the hoppers and place a Redstone Torch on the bottom layer. If you need help, follow the image above.
Step Four: Build the Rails
Once you've placed the Redstone Torches, cover them up with blocks so the hole is even. At this point, you will be adding the rails for the Minecart to ride and collect any loose melons or pumpkins. Follow the outline in the image above. Above the blocks with Redstone Torches underneath, you will place Powered Rails. This makes the Hopper Minecart continue to go around and collect Melon Slices and Pumpkins and drop them off in the Hoppers when it rolls over them.
Step Five: Place the water
This step is crucial but easy. Cover the rails entirely with Dirt. Leave a hole in the middle of the main square, and place the Slab you have at the bottom half of that hole. Then, fill the top half with water. Follow the image above for guidance.
Step Six: Till and Plant
Now that your collection system is finished, you need to start building the farm. Using your hoe, till the Dirt blocks in the checkerboard pattern shown above. Directly above the water and slab block, place the Glowstone. This will be a light source for your melons to continue to grow at night.
If you don't know where to start, this step is easiest to follow if you start from the Glowstone block. In every direction, skip a block and till the next block. Build your checkerboard pattern in an 8 * 8 square from here. Once you have finished tilling, place a melon or pumpkin seed in every piece of tilled land.
Step Seven: Place the Pistons
These next to steps are a bit tricky, as you have to place them a certain way to make sure the Pistons are oriented correctly. You need to place a piston above every block that is not tilled and planted. To do this, you must build a temporary ceiling above the farm three blocks above the tilled ground. Note: Build this canopy three blocks above the ground itself, not the plants or Glowstone.
After you do this, it's time to place the Pistons. You must crouch and slowly approach each piece of dirt you wish to place a Piston. You must face up at the bottom of the Dirt block, aim your crosshair at the corner closest to you, then place the Piston. The image above shows you exactly how to do this.
Once you have finished, your farm should look like the image shown above. It will be a checkerboard pattern of Piston blocks, but opposite placement of the plants. These Pistons will smash the pumpkins and melons when they grow onto the block beneath them.
Step Eight: Place the Observers
This part is also tricky and must be followed precisely for the Observers to be oriented correctly. In between every Piston is an empty space above the tilled Dirt. From above the farm, look down between the Pistons at the plants below. Move your crosshair to be on the top of the hitbox of the plant. Place the Observer. Use the image above as an example of where your crosshair should be. Place an Observer above every plant. These Observers will detect when a Pumpkin or Melon block has grown.
Step Nine: Place the Redstone Dust
You must place Redstone dust on every Observer. The Observer acts as a power source and triggers the Redstone Dust when it detects a plant block has grown. The activated Redstone Dust will power the Pistons next to that Observer, assuring that at least one of them will crush the Pumpkin or Melon block and turn it into an item drop.
Step Ten: Place a Border, and Wait
Placing a border is crucial because it makes sure that the Pumpkin and Melon stems on the farm's outer edge don't accidentally produce blocks outside of the farm. If this happens, those plants can't be harvested. From this point, you just wait for your stems to grow and start producing blocks. When the blocks are detected and smashed, they drop the items collected by the Hopper Minecart running below them. Once collected, the Hopper Minecart will eventually roll over the rails above the Hoppers, dispensing them into the collection Chests. Genius!
There you have it! You now have an automatic Melon and Pumpkin farm!