All contributions

PaperMC/Paper

Paper

A performance-focused Minecraft server that fixes gameplay and mechanics inconsistencies. It keeps its changes to the game code as patches on the Minecraft sources.

Language
Java
GitHub stars
12,832
Merged changes
1
Project site
papermc.io

What we changed

With a large respawn radius, set by the respawn_radius game rule, players respawn anywhere in the whole square, not only in its first rows on the Z axis.

What this work shows

  • Modular arithmetic and coprime strides
  • Patches on Minecraft server code
  • Integer overflow in Java
What was broken

Respawns only landed in part of the square

The respawn_radius game rule defines a square around the spawn point. PlayerSpawnFinder capped both the number of attempts and the range of candidate positions at 1024, so from radius 16 up the candidates only covered the first rows of the square on the Z axis, and with a large radius players always respawned close to the lowest Z value.

How we fixed it

Sampling from the whole square

Candidates are now drawn from the whole area of the square, and the cap only applies to the number of attempts. The stride is chosen to be coprime with the area, because the old value of 17 divides some areas, such as 51 by 51, and the index is computed as a long so it cannot overflow an int.

#14390

Merged change 1

  1. #14390 Fix respawn radius only covering part of the square Merged 31 October 2026

What it taught us

A modular arithmetic bug can show up only at large setting values, so the edges of the range have to be tested too. We made the fix in a project maintained as patches on someone else's source code.

More about this technology: Java

Other projects we write code for

Describe your project.

A free quote comes back within an hour during working hours.