All work

Open source

Patching the Minecraft server itself with SportPaper

Patches to SportPaper and Magnet, the Paper server forks behind Stratus, Walrus and Avicus, from faster chunk unloading to a live knockback command.

Open source · Stratus, Walrus and Avicus · 2016 – 2021

The problem

Competitive Minecraft networks run an old version of the game for its combat, and the stock server for that version is slow and missing APIs a network needs. The fix is to fork the server, but you can’t commit to decompiled game code directly. The changes live as an ordered stack of patches applied on top of it.

What I built

Around 25 patches across the three forks, including:

  1. Upstreamfetch, remap, decompile
  2. Base repoinit
  3. git amapi, then server patches
  4. BuildMaven + paperclip
  5. Rebuildcommits back into patches

The build and two of the patches

A sketch of the idea, not the production code.

./sportpaper build:
    git submodule update; remap(mc.jar); decompile(); init()
    for dir in [api, server]:
        git reset --hard upstream
        for patch in sorted(patches/dir): git am --3way patch
    mvn install; paperclip -> server.jar

# speed up chunk unloading
unload_queue = LongOpenHashSet()
fn get_chunk_at(x, z):
    chunk = load(x, z)
    unload_queue.remove(key(x, z))        # O(1), and only once the chunk is there
    return chunk

# always tick worlds when asked to
should_tick = config.tick_empty_worlds or world.has_players()

Why it matters

When the server is the bottleneck, plugin code can only do so much. Patching the server let us fix the problem where it actually was.

Stack

Links