I wonder which mojangsta has wrote this?

Did I missed something here? (and yeah I was messing around)

/*net.minecraft.network.NetHandlerPlayServer @ 239 */
if (this.hasMoved){
   this.field_175090_f = this.networkTickCount;
   /*Other Code and no modification on hasmoved found */
   /* @ 284 */
   if (this.hasMoved){
      this.lastPosX = this.playerEntity.posX;
      this.lastPosY = this.playerEntity.posY;
      this.lastPosZ = this.playerEntity.posZ;
  /*Other Code*/

Umm. Are you okay? Do you need someone to talk to?

Ferus hugs you Everything will be okay.


I am okay. I just got a mental breakdown while reading that code. But everything is fine now.
Just wondering how long that would have been in minecraft… .

That’s what happens when decompiling bytecode, decompilers have to make a ‘best guess’ as to what the source code was. I can pretty much guarantee it’s not like that on Mojang’s source code.


It would be sad if it was. Such a tragedy…

The bytecode for these 2 if() statements must be there in bytecode - decompilers don’t generate java code from non-existing bytecode.
The only difference I can think of could be:

//the code in the first if() statement

Even if obfuscator modifies something - it would most likely optimize instead of adding reduntant code.

OK, looks like it is in the bytecode then. Ran javap -l -c NetHandlerPlayServer.class and scanned through, it does a few checks on the field. Maybe it is in the source, or the obfuscator is doing something.

     751: aload_0
     752: getfield      #5                  // Field hasMoved:Z
     755: ifne          759
     758: return

Indeed whoops. I rechecked it. And somewhere very much hidden I found this.

public void setPlayerLocation(double x, double y, double z, float yaw, float pitch, Set relativeSet)
   this.hasMoved = false;
   /*Other Code */

It calls it once, when the player is riding something. Sorry, I should catch some :zzz:… .

Really interesting.

Taken from the source generated by MCP for 1.8 (comments are added by me to provide some context):

//The below line is number 231
if (packetIn.func_149466_j())
    var9 = var11 * var11 + var13 * var13 + var15 * var15;

    if (!this.hasMoved && var9 < 0.25D)
        this.hasMoved = true;

if (this.hasMoved)
    this.field_175090_f = this.networkTickCount;
    double var19;
    double var21;
    double var23;

//And this goes on'

If you’re wondering, no, hasMoved is not referenced after I cut off the code block.