mojira.dev
MC-313692

Guardian's rotation desyncs when on ground

When guardian is on ground, the server and client disagrees on its rotation.

Analysis based on the decompiled Guardian#aiStep method, comments added by me:

} else if (this.onGround()) {
    // Usage of random which is different across the server and client.
	this.addDeltaMovement((this.random.nextFloat() * 2.0F - 1.0F) * 0.4F, 0.5, (this.random.nextFloat() * 2.0F - 1.0F) * 0.4F);
	this.setYRot(this.random.nextFloat() * 360.0F);
	this.setOnGround(false);
	this.needsSync = true;
 }

Comments 2

I tested with a repeating command block with

execute as @e[type=guardian,distance=..40] at @s anchored eyes run particle minecraft:end_rod ^ ^ ^2

and summoning a guardian on land, and there do seem to be cases where the particles do not appear at the end of the blue arrow rendered with entity hitboxes enabled, but this does does not only occur when the guardian is on the ground. Is there a better way to observe the issue?

Using a debugger and placing a logging breakpoint after the setYRot method call does display the discrepancy. Given the following "Id: " + this.id + " | Client: " + this.level().isClientSide + " | Tick: " + this.tickCount + " | Rot: " + this.getYRot()

We get the following output:

Id: 187 | Client: false | Tick: 322 | Rot: 122.171555
Id: 187 | Client: true | Tick: 322 | Rot: 319.79752
Id: 187 | Client: false | Tick: 334 | Rot: 235.2275
Id: 187 | Client: true | Tick: 334 | Rot: 259.97562
Id: 187 | Client: false | Tick: 346 | Rot: 31.906464
Id: 187 | Client: true | Tick: 346 | Rot: 315.58832
Id: 187 | Client: false | Tick: 358 | Rot: 102.64818
Id: 187 | Client: true | Tick: 358 | Rot: 168.47925
Id: 187 | Client: false | Tick: 370 | Rot: 354.91754
Id: 187 | Client: true | Tick: 370 | Rot: 275.07355
Id: 187 | Client: false | Tick: 382 | Rot: 24.94038
Id: 187 | Client: true | Tick: 382 | Rot: 146.61577
Id: 187 | Client: false | Tick: 394 | Rot: 358.0292
Id: 187 | Client: true | Tick: 394 | Rot: 46.137577
Id: 187 | Client: false | Tick: 406 | Rot: 31.776258
Id: 187 | Client: true | Tick: 406 | Rot: 85.55972
Id: 187 | Client: false | Tick: 418 | Rot: 294.13773
Id: 187 | Client: true | Tick: 418 | Rot: 221.11632
Id: 187 | Client: false | Tick: 427 | Rot: 105.61234
Id: 187 | Client: true | Tick: 427 | Rot: 297.79526
Id: 187 | Client: false | Tick: 439 | Rot: 278.1148
Id: 187 | Client: true | Tick: 439 | Rot: 112.6875
Id: 187 | Client: false | Tick: 451 | Rot: 190.96646
Id: 187 | Client: true | Tick: 451 | Rot: 54.067238

For example on tick 322, the server assigned the guardian rotation of 122.171555 and where the client set it to a 319.79752.

isokissa3

(Unassigned)

Unconfirmed

26.3, 26.4 Pre-Release 2

Retrieved