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.
Answer
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
{
j1--;
}
if(i1 == 1) // South
{
j1++;
}
if(i1 == 2) // East
{
k1--;
}
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.
Attribution
Source : Link , Question Author : Raven Dreamer , Answer Author : Raven Dreamer