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.
This wasn't a 1.9 change, but types have to be lowercase now: giant
instead of Giant
. A full list is here.
If you want to activate a line of command blocks conditionally, put a testing command (testfor
, testforblock
, testforblocks
or anything else that can succeed or fail) into a repeating command block and place another repeating command block, this one conditional, so that its back faces the first command block (because that's how "conditional" works). A normal straight line of command blocks also works. Then you just continue normally with chain command blocks, they don't have to be conditional (but can be if you want to make them depend on the previous one).
How this works: The first repeating command block tests the condition in every tick, the second repeating command block checks for the success of the first one every tick, but only runs if the first one was successful and only then it also activates the chain command blocks in front of it.
For the future: Please only ask one question per question. I've answered both now because the first one is really trivial.
Best Answer
/execute if blocks
works somewhat like a test version of/clone
. The first two sets of coordinates represent the start and end of a rectangular prism for the source area, and the 3rd represents the lower northwest corner of another rectangular prism the same size as the first one. If typing a/clone
command using these coordinates will return a "No blocks cloned" because every block is the same, then the conditional argument returns a YES.Even NBT data has to match for the conditional to count! This means you can test if a chest's contents matches the contents of a template chest by using:
The all/masked option represents whether to ignore air blocks in the source region. If set to
all
, all air blocks in the source region have to be air blocks in the destination region.If set to
masked
, air blocks in the source region are ignored in the destination, and can be anything and will still count.If test passes, the command will return a number equal to the number of blocks evaluated. This includes the total volume of the source region, minus air blocks if set to
masked
mode.If test fails, returns 0.
Anything but 0 will mean your command at
run
will be executed, and if your conditional returns 0 the command won't execute.Here are some examples. The source is on the left, the test is right, I am facing north. The command used is shown on screen in the chat box, as well as the result from it in the chat. Additionally, the images' hover texts contain additional explanation to the results you see. In order to detect if all blocks in a certain area are a certain block ID, you don't give the command a block ID directly, you give it a template area to compare with the area to test for.
In this case, to solve the problem detailed in your question, you can use
/execute if blocks
, just make the following modifications:/execute if blocks
, choose one corner of this template area.Learn more about
/execute
on the Minecraft Wiki!