Redundant awaitingPositionFromClient check in handleMoveVehicle
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 12.7k
- Forks
- 3.5k
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 11
Description
Expected behavior
this kinda confused me until i realized its paper logic bug.
...
//ServerGamePacketListenerImpl.handleMoveVehicle()
} else if (!this.updateAwaitingTeleport() && this.player.hasClientLoaded()) {
Entity rootVehicle = this.player.getRootVehicle();
// Paper start - Don't allow vehicle movement from players while teleporting
if (this.awaitingPositionFromClient != null || this.player.isImmobile() || rootVehicle.isRemoved()) { // ensuring awaitingPositionFromClient is null
return;
}
// Paper end - Don't allow vehicle movement from players while teleporting
...
as you can see we are ensuring awaitingPositionFromClient is null, but it was already just checked inside this.updateAwaitingTeleport(), which will only return false if awaitingPositionFromClient is null
private boolean updateAwaitingTeleport() {
if (this.awaitingPositionFromClient != null) {
if (false && this.tickCount - this.awaitingTeleportTime > 20) { // Paper - this will greatly screw with clients with > 1000ms RTT
this.awaitingTeleportTime = this.tickCount;
this.teleport(
this.awaitingPositionFromClient.x,
this.awaitingPositionFromClient.y,
this.awaitingPositionFromClient.z,
this.player.getYRot(),
this.player.getXRot()
);
}
this.allowedPlayerTicks = 20; // CraftBukkit
return true;
} else {
this.awaitingTeleportTime = this.tickCount;
return false; // returns false here, right after this.awaitingPositionFromClient == null
}
}
...
//ServerGamePacketListenerImpl.handleMoveVehicle()
} else if (!this.updateAwaitingTeleport() && this.player.hasClientLoaded()) { // needs to return false in order to proceed
Entity rootVehicle = this.player.getRootVehicle();
...
Paper version
daddcf67420e92ce1eba27949f3c847a92ffab14
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch and the handleMoveVehicle() and updateAwaitingTeleport() entry points shown in the issue. Confirm the control flow around awaitingPositionFromClient, then verify the redundant check is gone and the project’s relevant checks pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- networking
- Issue type
- Refactor
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100