right. you've got your invincible fort and all your items are safe. but raiders have destroyed your farm!
Luckily I have an answer for that! (what would you do without me)
To get your melon just do this. get some grass and place it like in the picture with some water next to it.
then add a redstone block/redstone torch (anything that'll give off a redstone signal) connect a repeater to it.
add hoppers along the sides to collect the melon. (also make it so the repeater is on top of a hopper) and add a piston like so. make sure that the melon can only be placed on the grass block. then if you've built it correctly you'll have melon for days! Thanks for reading!