Do you always spawn on sand?

In a recent Yogscast video it was mentioned that you always spawn on sand in a new world, is this true?


As of 1.8, you do not always spawn on sand. I'm afraid I don't have source code to post, but in all of several worlds I made, I did not spawn on sand.


LATER:

This is my first foray into decompiling, but if I understand this right, the new initial spawn code does not mention sand at all.

public static void getInitialSpawnLocation()
    {
        scheduledTickTreeSet = a(scheduledTickTreeSet, "stat.useItem", 0x1020000, MovementInputFromOptions.m.length, 32000);
        scheduledTickSet = b(scheduledTickSet, "stat.breakItem", 0x1030000, MovementInputFromOptions.m.length, 32000);
        field_1019_F = true;
        setSpawnLocation();
    }

setSpawnLocation is much bigger and filled with fun statements like

Iterator iterator1 = OpenGlCapsChecker.a().b().values().iterator();

So I thought it best not to post it. Nonetheless, I saw no mention of sand in it either. I checked both World.java and WorldProvider.java. The code posted by yatima2975 does not appear to exist any longer.


Note: As of 1.8, you do not always spawn on sand.


Yes, you do always spawn on sand. Here's a few snippets of the source (decompiled by MCP):

From World.java,here's the function that gets called when opening a world:

protected void func_25098_c() {
    findingSpawnPoint = true;
    int i = 0;
    byte byte0 = 64;
    int j;
    for (j = 0; !worldProvider.canCoordinateBeSpawn(i, j);) {
        i += rand.nextInt(64) - rand.nextInt(64);
        j += rand.nextInt(64) - rand.nextInt(64)
    }

    worldInfo.setSpawn(i, byte0, j);
    findingSpawnPoint = false;
}

From WorldProvider, the relevant function called:

public boolean canCoordinateBeSpawn(int i, int j) {
    int k = worldObj.getFirstUncoveredBlock(i, j);
    return k == Block.sand.blockID;
}

So, when Minecraft starts setting the spawn point, it begins at X/Z 0/0 and moves the point around randomly (with steps of at most 64 in the cardinal directions), until the topmost block at the spawn point is sand.

As to why this happens to be near sea-level (most of the time), I'm not sure, probably sand has a higher chance of generating there.


Using purely anecdotal evidence: Yes

I have just created 10 new worlds and every single one of them has been on sand (and near water).

This is probably due to the idea that you wash ashore on an island at the start of the game.


I have been trying about ~20 times, and in all of those worlds i spawned on sand, and near to a water source. However, if you use a seed in the seed generator such as 3666440496532277820, you will spawn in a dungeon (cobblestone/mossy cobblestone)