# How exactly does melon/pumpkin growth work?

Often, when people discuss automatic melon/pumpkin farm designs on reddit or similar places, a question pops up:

Does pushing a block into the air block the melon/pumpkin will grow into reset the growth timer?

If the answer to this is yes, a badly set up timer can severely limit the production rate of your melon/pumpkin farm by resetting the growth all the time.

From a code perspective, this would mean that the game is looking at the air blocks surrounding a stem continuously, updating a growth timer somewhere when a random tick update hits the stem (or the air block?), which I guess is possible. It could also imagine it to pick a direction first and only check that block, but I don't know, which brings me to the question:

How exactly does melon/pumpkin growth work? What are the specific steps the game code runs, and how does it interact with the world? An answer based on decompiled code would be ideal, but extensive testing might also reveal the game's logic.

The following is based on the source decompiled via 1.9 ModCoderPack.

The current growth stage of the stem is saved as its metadata value. You can view this value via the F3 menu. The image shows a stem partway into its growth, via the age blockstate:

This value increments by random chance via random ticks rather than an internal timer. The following is the random chance condition, provided the light level above the stem is 9 or higher:

rand.nextInt((int)(25.0F / growthChance) + 1) == 0


If a random value generated from 25 divided by the "growth chance", and after being floored has 1 added, is equal to 0, then the crop has the ability to either grow taller or grow a melon/pumpkin, depending on its growth stage.

The value for growthChance is obtained using the same function that all crops use, being the existence and hydration of surrounding farmland and nearby crops. The wiki details the long list of conditions here.

For example, provided the following arrangement:

The growthChance will always be 4.0, which means a random value between 0 and 7 is chosen. If the random value is 0, then the crop is ready to grow.

If its growth stage (metadata value) is 6 or lower, it will increase by 1, visually increasing the height of the stem. Nothing else will happen and no other checks are made.

If the growth stage is 7, then one random location surrounding the stem will be chosen. If that location is air and the block below that is grass, farmland, or dirt, then a new melon/pumkin block will be placed. If those conditions fail, then nothing happens and it must receive another random tick to attempt placing another block.

If the growth stage is 7 while the blockstate facing is not "up", and it's facing a respective melon/pumpkin block, then a new melon/pumpkin block cannot grow.

As such, the growth timer will not reset by placing a block where a melon/pumking can grow since there is technically not a timer at all. But a badly-timed placement of a block could prevent potential growth should the stem receive a random tick update at that same moment. There would be no way to detect it and no way to prevent it, short of making sure you remove any impeding blocks as soon as possible to reduce the chance of a clash.

From a technical perspective, it is very possible that a melon could successfully grow twice in quick succession (as quick as twice in 2 ticks), but it is not probable.

• I've heard that if you have multiple stems adjacent to the same empty square, a pumpkin/melon will "attach" all adjacent stems (not just the one it grew from) and stop them from growing, even if they have other empty squares in other directions. I'm not sure if it's true or not, it's just what I've heard (they do "attach" visually, what I'm not sure of is whether this is a visual artifact or affects growth). Your post doesn't discuss this issue at all. – Random832 Apr 25 '16 at 17:18
• @Random832 That is correct. After the random chance succeeds while the growth stage is 7, it checks if the stem is facing 'horizontally' before attempting to place a new block. If it's pointing into a melon/pumpkin block, it will skip attempting to place a new one. – Skylinerw Apr 25 '16 at 17:56
• can a melon stem be "attached" in this way by a pumpkin block or vice versa? – Random832 Apr 25 '16 at 17:59
• @Random832 Nope, has to be a melon stem with a melon block or a pumpkin stem with a pumpkin block. – Skylinerw Apr 25 '16 at 18:06