Skip to content

Commit

Permalink
fix(crash): avoid a possible movement-fix crash
Browse files Browse the repository at this point in the history
With the changes to eneity teleports, Mojang now attempts to clear any
recorded movement packets, but this can lead to a NoSuchElementException
being thrown at the server which crashes the game entirely.
  • Loading branch information
gabizou committed Mar 8, 2025
1 parent 7ea90f4 commit b039b78
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,9 @@ public abstract class EntityMixin implements EntityBridge, PlatformEntityBridge,
@Shadow @javax.annotation.Nullable public PortalProcessor portalProcess;
@Shadow public abstract boolean save(final CompoundTag $$0);
@Shadow public abstract Level level();
// @formatter:on

@Shadow @Final private List movementThisTick;
// @formatter:on


private boolean impl$isConstructing = true;
Expand Down Expand Up @@ -734,7 +735,16 @@ public void stopRiding() {
original.call(block, world, pos, state, entity);
this.impl$lastCollidedBlockPos = pos;
}
}

@Inject(method = "removeLatestMovementRecordingBatch", at = @At("HEAD"), cancellable = true)
private void impl$catchEmptyRemoval(CallbackInfo ci) {
// This prevents a no element exception leading to a crash. It is highly possible that
// this is a bug, but whether it's from Vanilla or Sponge, I'm not certain. It's also possible
// this can be triggered by a rogue client missending packets, leading to a player being
if (this.movementThisTick.isEmpty()) {
ci.cancel();
}
}

@WrapOperation(method = "lambda$checkInsideBlocks$0",
Expand Down

0 comments on commit b039b78

Please sign in to comment.