I'd like to do some fancy-schmancy redstone shenanigans exploiting the fact that melon blocks growing into a square can hold a charge (and thus complete a circuit). Is the direction they spawn the melon truly random?

I did a small-scale test, and got 3/4 melons spawning in the same direction. I don't want to pronounce Melons to be non-random though, as it's still a very small sample size.

enter image description here

  • 1
    I'm curious, are you trying to utilize the (possible) randomness or to eliminate it?
    – Fambida
    Oct 4, 2011 at 4:44
  • 8
    @Fambida Utilize it. I want to make Schrödinger's Cow. Obviously, if I can't get two equally random possibilities, the cow can't be simultaneously dead and alive. Oct 4, 2011 at 4:54
  • 2
    @ Raven That's assuming that dead or alive is two separate states instead of a continuum. Assuming that there's a bias towards one direction you could still have a mostly dead somewhat alive cow or a mostly alive somewhat dead cow. Or you could wire the input through multiple potential melons so that the bias is canceled out.
    – Fambida
    Oct 4, 2011 at 5:12
  • 1
    So you ban the minecraft-enderman tag, but create the melon-mechanics tag? Care to explain yourself before I cry mod abuse? :P Oct 4, 2011 at 16:46
  • 1
    I vote for the melon-mechanics tag to be reinstated.
    – lily
    Oct 27, 2011 at 23:09

1 Answer 1


I think I found the code that chooses where the melon grows. (All comments added by me.)

int i1 = random.nextInt(4);
int j1 = i;  // Assuming j1 and k1 are the horizontal axes...
int k1 = k;
if(i1 == 0)  // North
if(i1 == 1) // South
if(i1 == 2) // East
if(i1 == 3) // West
    k1++; // or somthing like that, anyway.
if(world.getBlockId(j1, j, k1) == 0 && world.getBlockId(j1, j - 1, k1) == Block.tilledField.blockID)  // Make sure the targeted block is empty and below it is farmland...
    world.setBlockWithNotify(j1, j, k1, field_35297_a.blockID); // Place a melon.

It appears to depend on how random random.nextInt(4) is.

  • Excellent sleuthing! This looks like it is random then. Possibly also, you're more likely to grow a melon when you have 4 tilled blocks surrounding it? Oct 4, 2011 at 22:25
  • Damn. Now I really want to pour through the rest of the Minecraft code. Oct 4, 2011 at 22:38
  • 1
    @Raven Dreamer, what makes you so sure it really is random? 4, 4, 4, 4, 4 ... would be a perfectly valid sequence.
    – Cyclops
    Oct 4, 2011 at 22:59
  • 2
    @Cyclops - that's a problem with any program using java's rand library, though. Oct 4, 2011 at 23:12
  • @RavenDreamer Glad I could help. :) The code appears to select a location, then check if it's tilled, only spawning if it is. So you are more likely to grow a melon if all 4 surrounding tiles are farmland. Oct 4, 2011 at 23:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .