mojira.dev

I have looked in the Minecraft Source Code and found a Error/Problem in the Speed Calculation.

This stand in the obfuscated Code from the Minecraft Client (1.7.4):

float f1 = this.bm.a(paramahz);
if (f1 > 1.0F) { //Higher than 1.0F
	int j = aem.c(this);
	abu localabu = this.bm.h();

	if ((j > 0) && (localabu != null)) {
		float f2 = j * j + 1;
		
		if ((localabu.b(paramahz)) || (f1 > 1.0F)) { //<--- Here is the Error
			f1 += f2;
		else
			f1 += f2 * 0.08F;
		}
	}
}

The float f1 is always higher then 1.0F.

Here is the problem too: https://github.com/Bukkit/mc-dev/blob/master/net/minecraft/server/EntityHuman.java#L511
And here: https://github.com/Bukkit/CraftBukkit/blob/master/src/main/java/net/minecraft/server/EntityHuman.java#L593

Comments 7

Can you please explain how the issue affects vanilla Minecraft and whether it is still an issue in 14w07a?

In 14w07a is the Bug avaible, too.

This haven't Effects to Singleplayer or other things.
But Mojang added the Line and it make nothing.
Why is then the Line in the Code, when it make nothing?

If there is no affected functionality in any way, it is not a bug. Dead code happens, or stubbed out code for that matter.

Franz, please also keep in mind that what you are looking at is not the source code, but a decmpiled version of the code. What you are seeing may look completely different then how the code actually appears.

Confirmed.

float var3 = this.bm.a(var1);
if(var3 > 1.0F) {
   int var4 = aem.c(this);
   abu var5 = this.bm.h();
   if(var4 > 0 && var5 != null) {
      float var6 = (float)(var4 * var4 + 1);
      if(!var5.b(var1) && var3 <= 1.0F) {
         var3 += var6 * 0.08F;
      } else {
         var3 += var6;
      }
   }
}

Decompiled with Fernflower

Although he is viewing obfuscated code, It is 75% similar in most cases to real code. Same goes with .NET coding languages.

And this is what caused the efficiency problems.

The proper way of solving it is realizing that f1>1.0f is true and thus there is no if/else statement needed.

That took me some bisecting to find this commit =)

Franz Reiter

Nathan Adams

Confirmed

Minecraft 1.7.4

Minecraft 14w32a

Retrieved