paaracetamol / kyklophobia

Beta Minecraft, again

Beta-era Minecraft rebuilt in Python, with lighting and LAN multiplayer.

kyklophobia in game: a player on a hill among oak trees with a full hotbar

kyklophobia / README.md

The idea Beta Minecraft, rebuilt in Python.

After the terminal version I wanted the real thing: classic beta terrain, proper lighting and friends on the same world over the network.

The heavy parts (terrain, lighting and meshing) are compiled with numba, so Python only has to orchestrate. Not affiliated with Mojang.

Run it Python 3.11 or newer.

The first launch is slow on purpose: numba compiles the generator, the light baker and the mesher, then caches them per world, so every launch after that is fast.

make run            # client
make server         # headless server

# or by hand
python3.11 launch.py
python3.11 server.py --host 0.0.0.0 --port 25250 \
                     --world default --seed 12345 --max-players 20

Voxels One 16-bit number per block.

A chunk is a 16 × 128 × 16 array of uint16. Light lives in two separate uint8 arrays of the same shape, one for sky and one for blocks.

bit  15  14 13 12 11 10  9 8 7 6 5 4 3 2 1 0
     F   S  S  S  S  S   I I I I I I I I I I
     |   \___________/   \_________________/
     |    5b state         10b block id (1024 ids)
     placed by a player

Generation From noise to a mesh on the GPU.

  • Climate and biome on a coarse grid, one sample every 4 blocks
  • A density field, interpolated up to the full chunk
  • Caves carved where two 3D noise shells intersect, kept away from water
  • Surface per biome, sea level, badlands bands and ice
  • Light baked with a flood fill, then the mesher writes position, light and UV per vertex
  • Meshes are uploaded on the main thread within a few milliseconds per frame

Multiplayer The server owns the world.

A custom protocol over TCP: one byte of opcode and a little-endian payload. The server keeps a circle of chunks around each player and streams them zlib-compressed, about 2.4 KB per chunk.

Commands run on both client and server, with Minecraft-style selectors like @a, @p and @s[...].

Built on a laptop

Developed and tested on a Lenovo IdeaPad L340 with a 9th gen i7 and a GTX 1050. Render distances above 14 saturate the chunk builder.

Screenshots. Straight from the repo.

kyklophobia landscape
kyklophobia landscape
kyklophobia terrain with lighting
kyklophobia terrain with lighting
kyklophobia world view
kyklophobia world view
Thumbnail of I Made Minecraft in Python, AGAIN? | Terrain, Light & Multiplayer

Watch the devlog. 1,789 views.

I Made Minecraft in Python, AGAIN? | Terrain, Light & Multiplayer

Watch on YouTube
powered bypolyot.net