mojira.dev
MC-44944

"0" is not handled as a valid seed

If you enter the digit "0" as seed code, it's handled as if there is no seed chosen, so a random one is picked. The seed can be set to "0" be deleting all generated chunks and changing the seed inside of the level.dat file.

Comments

dynamic

Still present in 1.8.1-pre5

Erik Broes

Limitation of how seeds work, setting it to 0 doesn't work so nicely 😃

marcono1234

Confirmed for

  • 15w49b

Grum, that is not correct it should rather be "Limitation of how we made seeds to work"

In /Client/src/net/minecraft/client/gui/GuiCreateWorld.java (MCP 1.8 name) you can clearly see that the reason for this is if (var5 != 0L) and there is very likely no reason for that, instead it creates other bugs like MC-94025

long var2 = (new Random()).nextLong();
String var4 = this.field_146335_h.getText();

if (!StringUtils.isEmpty(var4))
{
	try
	{
		long var5 = Long.parseLong(var4);

		if (var5 != 0L)
		{
			var2 = var5;
		}
	}
	catch (NumberFormatException var7)
	{
		var2 = (long)var4.hashCode();
	}
}
marcono1234

So is there any reason for that?

Torabi

Did you look for where the seed value is actually used, and how it is used? It's fed directly to Java.util.Random.Random() in net.minecraft.world.gen.ChunkProviderGenerate.ChunkProviderGenerate(), and looking at the algorithm it uses, that probably doesn't produce a useful sequence.

marcono1234

You are right, I am sorry 😞
Based on MC-94025 I assumed that there is no problem.
Are you sure that somewhere the next(int bits) method is called with the seed as bits? I only see the seed being used as seed for the random generators.

[Mod] redstonehelper

Don't the generators use them?

marcono1234

Yes all other values are based on the seed. While next(0) would return 0, using for example nextLong() produces a "random" number based on the seed. As the seed is set the "random" number will always be the same for the same seed (see also Java Random Numbers Using a Seed).

Torabi

The RNG object is passed into various other functions, which call nextLong() and nextInt() on it. Unless you actually understand the generator code, and can make a compelling argument that there's no need to exclude 0, then I don't think you're going to make much headway here. So far, you haven't told us anything we don't already know.

marcono1234

I made a compelling argument by writing this comment. You pretended as if new Random(0L).nextLong() would be the same as new Random().next(0). If this is not what you meant than your comment is wrong.

[Mod] redstonehelper

Someone posted some text seeds that turned into 0 when used. These work fine, don't they?

Torabi

I made one using "tainsntoh" and flew around for a bit. Very little land near the spawn area, but I'm sure there are other seeds like that. Traveled to the nether, no obvious problems or crashes. We'll just have to see if a Mojangsta has a more detailed answer for us, or if perhaps they resolved whatever problem there was before without realizing it.

Regardless, @unknown, as the word "compelling" is defined, you don't get to decide whether or not your own arguments are compelling, here or anywhere else. You don't understand either my comment, or how random numbers are generated in Java, despite all the functions and their algorithms being present on the page I linked. nextLong() and nextInt() both call next(), which takes the number of desired bits as an argument, not the seed. I skipped the details on the assumption that you would either be able to follow the argument, or that you'd realize you were in over your head. Arguing from a position of ignorance just wastes everyone's time. Doing so while acting like you know better than everyone else is irritating.

marcono1234

You are right, I do not know very much about this topic and I misunderstood you by thinking you meant the next(int bits) method is directly called somewhere with the seed as parameter.
However after looking at how this method works 0 should be a valid seed and create a valid sequence:

When the Random object is created the seed is set to: (seed ^ 0x5DEECE66DL) & ((1L << 48) - 1)
With 0L as seed the result is 0x5DEECE66DL

Each time the next method is called the seed is set to: (seed * 0x5DEECE66DL + 0xBL) & ((1L << 48) - 1)
With 0x5DEECE66DL as start value, the next seed value would be 0xBB20B4600A74L.
There is no reason why 0 should cause any problems but if you see any let me know 🙂

Erik Broes

We've now defined '0' as special. It will indicate a random seed. Many games use 0 as 'random' or 'infinite' or 'do not care' flag when providing options.

marcono1234

Are you sure you really want to leave it this way?

You can still get 0 as seed value with for example the string "tainsntoh". People will only complain and create new reports. Additionally new Random().nextLong() could produce 0 as well.

Torabi

MC-94025 has been reopened to deal with the consequences of strings that hash to 0 such as "tainsntoh".

marcono1234

Can you please create a "relates to" link to MC-94025

ampolive

This no longer happens (MC-209001).

muzikbike

Does 22w03a "fix" this?

Lukas Spanier

Erik Broes

Confirmed

world

Minecraft 1.7.4, Minecraft 14w02c, Minecraft 1.7.9, Minecraft 14w21b, Minecraft 1.8, Minecraft 1.8.1-pre3, Minecraft 1.8.1-pre5, Minecraft 15w33b, Minecraft 15w33c

Retrieved