u/Jimxor

▲ 2 r/MinecraftHelp+1 crossposts

[java] (26.1.2) Why does this wheat not plant?

When I stand on a field of nothing but grass_block and execute the following function:

fill \~-1 \~ \~1 \~1 \~ \~1 air

fill \~-1 \~-1 \~1 \~1 \~-1 \~1 farmland\[moisture=7\]

fill \~-1 \~ \~1 \~1 \~ \~1 wheat\[age=7\]

three wheat blocks appear: southwest, south and southeast of my feet as I would expect.

But if I stand one block north of a tree trunk, the wheat blocks to the southwest and southeast still appear but instead of the wheat to the south, there are wheat and seed item entities floating atop the farmland where the tree trunk once stood. Of 28 trials, this failure rate was 100%

If I insert 16 pairs of the following unrelated commands between the air and farmland commands (just to cause a delay):

fill \~ \~10 \~ \~31 \~41 \~31 glass

fill \~ \~10 \~ \~31 \~41 \~31 air

I get 27 failures out of 27 trials or, again, a 100% failure rate.

With 32 pairs of dummy fills, I get 3 failures out of 26 trials or a 12% failure rate.

With 35 pairs of dummy fills, I get 3 failures out of 27 trials or an 11% failure rate.

With 36 pairs of dummy fills, I get 2 failures out of 112 trials or a 2% failure rate.

With 37 or more pairs of dummy fills, I get 0 failures out of >28 trials or a 0% failure rate.

I vaguely recall first encountering this problem shortly after functions were introduced.

I've been able to work around this phenomenon by adding useful code instead of those dummy fill commands so that isn't the problem.

My problem is that throughout my programming career, I've been able to rely on the fact that computers are deterministic and so it is guaranteed that each command will complete before the next command begins. Yet in this experiment it appears that the first air-filling command can sometimes have an unintended residual impact on subsequent commands.

My real question is: Is this an artifact of Minecraft being multithreaded and running on a multicore processor?

reddit.com
u/Jimxor — 5 days ago