Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Introduction

Verified against Minecraft 26.3

Java Minecraft is one codebase that runs as two programs. The server is the world: a loop that ticks twenty times a second, owns every chunk, entity and block, and decides what they are — save a few things it takes from your client once it has checked them, chief among them where the player you control, and anything it steers, stands. The client is a window, a loop that draws frames as fast as vsync or the frame-rate limit allow, and a copy of the world it is told about — which it will happily change on its own and be overruled about. It ticks too, nought to ten times inside each frame, catching its own copy up to the same twenty-a-second clock and dropping any tick owed beyond ten. They talk over a real Netty connection even when both run in the same process — in singleplayer the connection never touches a socket, but the packets are real, and an IntegratedServer is a MinecraftServer with the client half attached rather than absent. The split is behind some of the first things a player notices: the client predicts and the server overrules; a chunk exists on the server long before the client is sent it; a sword swing is a packet, a hit is a reply.

flowchart TD
    subgraph Client["Render thread"]
        MC["Minecraft: a frame, 0 to 10 ticks in it"]
        CL["ClientLevel: the copy it is told about"]
    end
    subgraph Netty["Netty event loop"]
        Conn["Connection: socket or in-process"]
    end
    subgraph Server["Server thread"]
        MS["MinecraftServer: a tick every 50 ms"]
        SL["ServerLevel: the world, one per dimension"]
    end
    subgraph Pool["Worker-Main-n"]
        W["generation, lighting, meshing"]
    end
    MC --> CL
    MS --> SL
    MC -- "what the player did" --> Conn
    Conn -- "what the world became" --> CL
    Conn <--> SL
    W -. "chunks" .-> SL
    W -. "meshes" .-> MC

The two programs and the four threads they run on: the client and the server each own their copy of the world and talk through the connection, and the worker pool hands its results back, dotted, to whichever of them asked.

The whole thing is 7,301 source files and about 740,000 lines of Java 25. Just under a third of those lines is client-only; the rest ships in both jars, and the picture below is the split — orange is the client’s, blue is everything the dedicated server also ships, and the hatched boxes are the packages Part I’s what this book skips tours, most of them what this book leaves out.

The 26.3 jar as a treemap of packages: area is lines of decompiled source, colour is which jar ships the package, hatching marks the packages what this book skips tours net/minecraft/world — 2715 classes, 313,098 lines, shared net/minecraft/world/level — 1418 classes, 151,146 lines, shared level 151,146 net/minecraft/world/entity — 727 classes, 110,760 lines, shared entity 110,760 net/minecraft/world/item — 323 classes, 30,661 lines, shared item 30,661 net/minecraft/world/inventory — 64 classes, 7,152 lines, shared inventory 7,152 net/minecraft/world/phys — 28 classes, 3,036 lines, shared phys net/minecraft/world/attribute — 30 classes, 1,936 lines, shared net/minecraft/world — 25 classes, 1,686 lines, shared net/minecraft/world/scores — 16 classes, 1,442 lines, shared net/minecraft/world/effect — 20 classes, 1,306 lines, shared net/minecraft/world/damagesource — 12 classes, 936 lines, shared net/minecraft/world/ticks — 14 classes, 869 lines, shared net/minecraft/world/waypoints — 9 classes, 677 lines, shared net/minecraft/world/timeline — 5 classes, 446 lines, shared net/minecraft/world/clock — 11 classes, 390 lines, shared net/minecraft/world/flag — 7 classes, 356 lines, shared net/minecraft/world/food — 6 classes, 299 lines, shared world 42% net/minecraft/client — 1891 classes, 176,818 lines, client-only net/minecraft/client/gui — 445 classes, 59,594 lines, client-only gui 59,594 net/minecraft/client/renderer — 715 classes, 50,649 lines, client-only renderer 50,649 net/minecraft/client/model — 268 classes, 12,712 lines, client-only model 12,712 net/minecraft/client/multiplayer — 63 classes, 11,303 lines, client-only multiplayer 11,303 net/minecraft/client — 41 classes, 10,821 lines, client-only (itself) 10,821 net/minecraft/client/resources — 110 classes, 8,326 lines, client-only resources 8,326 net/minecraft/client/particle — 88 classes, 6,839 lines, client-only particle 6,839 net/minecraft/client/data — 28 classes, 6,189 lines, client-only — toured in what this book skips data 6,189 net/minecraft/client/sounds — 17 classes, 2,174 lines, client-only sounds net/minecraft/client/player — 11 classes, 2,072 lines, client-only player net/minecraft/client/telemetry — 18 classes, 1,221 lines, client-only — toured in what this book skips net/minecraft/client/server — 6 classes, 885 lines, client-only net/minecraft/client/color — 17 classes, 879 lines, client-only net/minecraft/client/tutorial — 10 classes, 671 lines, client-only net/minecraft/client/main — 4 classes, 523 lines, client-only net/minecraft/client/animation — 23 classes, 509 lines, client-only net/minecraft/client/searchtree — 8 classes, 505 lines, client-only net/minecraft/client/input — 8 classes, 304 lines, client-only net/minecraft/client/quickplay — 3 classes, 284 lines, client-only net/minecraft/client/entity — 4 classes, 228 lines, client-only net/minecraft/client/profiling — 2 classes, 81 lines, client-only net/minecraft/client/waypoints — 2 classes, 49 lines, client-only client 24% net/minecraft/util — 735 classes, 54,700 lines, shared net/minecraft/util/datafix — 411 classes, 27,048 lines, shared — toured in what this book skips datafix 27,048 net/minecraft/util — 93 classes, 12,767 lines, shared (itself) 12,767 net/minecraft/util/profiling — 70 classes, 4,265 lines, shared — toured in what this book skips profiling 4,265 net/minecraft/util/filefix — 57 classes, 3,553 lines, shared — toured in what this book skips filefix net/minecraft/util/parsing — 29 classes, 1,879 lines, shared net/minecraft/util/debug — 19 classes, 1,348 lines, shared net/minecraft/util/worldupdate — 6 classes, 958 lines, shared net/minecraft/util/thread — 9 classes, 842 lines, shared net/minecraft/util/valueproviders — 19 classes, 707 lines, shared net/minecraft/util/eventlog — 4 classes, 459 lines, shared net/minecraft/util/random — 4 classes, 374 lines, shared net/minecraft/util/debugchart — 8 classes, 199 lines, shared net/minecraft/util/context — 4 classes, 181 lines, shared net/minecraft/util/monitoring — 2 classes, 120 lines, shared util 7% net/minecraft/server — 432 classes, 53,789 lines, shared net/minecraft/server/commands — 111 classes, 13,357 lines, shared commands 13,357 net/minecraft/server/level — 42 classes, 12,166 lines, shared level 12,166 net/minecraft/server/network — 29 classes, 5,566 lines, shared network 5,566 net/minecraft/server — 27 classes, 5,153 lines, shared (itself) 5,153 net/minecraft/server/packs — 57 classes, 5,122 lines, shared packs 5,122 net/minecraft/server/jsonrpc — 65 classes, 4,118 lines, shared — toured in what this book skips jsonrpc 4,118 net/minecraft/server/players — 19 classes, 2,770 lines, shared players net/minecraft/server/dedicated — 7 classes, 1,811 lines, shared net/minecraft/server/dialog — 35 classes, 885 lines, shared net/minecraft/server/rcon — 9 classes, 837 lines, shared — toured in what this book skips net/minecraft/server/permissions — 12 classes, 402 lines, shared net/minecraft/server/chase — 3 classes, 354 lines, shared net/minecraft/server/notifications — 5 classes, 343 lines, shared net/minecraft/server/bossevents — 3 classes, 328 lines, shared net/minecraft/server/gui — 4 classes, 310 lines, shared net/minecraft/server/waypoints — 2 classes, 180 lines, shared net/minecraft/server/advancements — 2 classes, 87 lines, shared server 7% net/minecraft/network — 416 classes, 23,319 lines, shared net/minecraft/network/protocol — 298 classes, 12,872 lines, shared protocol 12,872 net/minecraft/network/chat — 63 classes, 4,799 lines, shared chat 4,799 net/minecraft/network — 42 classes, 3,590 lines, shared net/minecraft/network/codec — 7 classes, 1,533 lines, shared net/minecraft/network/syncher — 6 classes, 525 lines, shared network 3% com/mojang/renderpearl — 146 classes, 18,659 lines, client-only com/mojang/renderpearl/backend — 76 classes, 13,866 lines, client-only backend 13,866 com/mojang/renderpearl/frontend — 12 classes, 2,876 lines, client-only frontend com/mojang/renderpearl/api — 53 classes, 1,879 lines, client-only api com/mojang/renderpearl/util — 4 classes, 34 lines, client-only com/mojang/renderpearl — 1 classes, 4 lines, client-only renderpearl net/minecraft/data — 174 classes, 16,849 lines, shared net/minecraft/data/worldgen — 64 classes, 6,016 lines, shared — toured in what this book skips worldgen 6,016 net/minecraft/data/loot — 21 classes, 3,023 lines, shared — toured in what this book skips loot 3,023 net/minecraft/data/recipes — 20 classes, 2,507 lines, shared — toured in what this book skips net/minecraft/data/tags — 29 classes, 1,756 lines, shared — toured in what this book skips tags net/minecraft/data — 10 classes, 1,272 lines, shared — toured in what this book skips net/minecraft/data/advancements — 10 classes, 896 lines, shared — toured in what this book skips net/minecraft/data/info — 8 classes, 518 lines, shared — toured in what this book skips net/minecraft/data/structures — 5 classes, 473 lines, shared — toured in what this book skips net/minecraft/data/registries — 5 classes, 325 lines, shared — toured in what this book skips net/minecraft/data/metadata — 2 classes, 63 lines, shared — toured in what this book skips data 2% com/mojang/realmsclient — 137 classes, 14,701 lines, client-only com/mojang/realmsclient/gui — 46 classes, 7,091 lines, client-only — toured in what this book skips gui 7,091 com/mojang/realmsclient/client — 19 classes, 2,643 lines, client-only — toured in what this book skips client com/mojang/realmsclient/dto — 43 classes, 1,986 lines, client-only — toured in what this book skips dto com/mojang/realmsclient — 4 classes, 1,492 lines, client-only — toured in what this book skips com/mojang/realmsclient/util — 20 classes, 1,425 lines, client-only — toured in what this book skips util com/mojang/realmsclient/exception — 5 classes, 64 lines, client-only — toured in what this book skips realmsclient net/minecraft/commands — 124 classes, 13,229 lines, shared net/minecraft/commands/arguments — 73 classes, 9,017 lines, shared arguments 9,017 net/minecraft/commands — 14 classes, 1,921 lines, shared net/minecraft/commands/synchronization — 12 classes, 905 lines, shared net/minecraft/commands/execution — 18 classes, 756 lines, shared net/minecraft/commands/functions — 7 classes, 630 lines, shared commands 2% net/minecraft/core — 123 classes, 12,359 lines, shared net/minecraft/core — 39 classes, 5,499 lines, shared (itself) 5,499 net/minecraft/core/component — 32 classes, 3,067 lines, shared net/minecraft/core/registries — 14 classes, 1,525 lines, shared net/minecraft/core/dispenser — 14 classes, 1,098 lines, shared net/minecraft/core/particles — 21 classes, 863 lines, shared net/minecraft/core/cauldron — 3 classes, 307 lines, shared core 2% com/mojang/blaze3d — 86 classes, 10,437 lines, client-only com/mojang/blaze3d/platform — 26 classes, 4,382 lines, client-only com/mojang/blaze3d/vertex — 14 classes, 2,322 lines, client-only vertex com/mojang/blaze3d/audio — 12 classes, 1,013 lines, client-only — toured in what this book skips com/mojang/blaze3d/systems — 5 classes, 773 lines, client-only com/mojang/blaze3d/framegraph — 3 classes, 437 lines, client-only com/mojang/blaze3d/font — 7 classes, 432 lines, client-only com/mojang/blaze3d/pipeline — 5 classes, 366 lines, client-only com/mojang/blaze3d — 5 classes, 289 lines, client-only com/mojang/blaze3d/buffers — 3 classes, 228 lines, client-only com/mojang/blaze3d/resource — 6 classes, 195 lines, client-only blaze3d 1% net/minecraft/nbt — 43 classes, 7,791 lines, shared net/minecraft/nbt — 36 classes, 7,279 lines, shared (itself) 7,279 net/minecraft/nbt/visitors — 7 classes, 512 lines, shared nbt 1% net/minecraft/advancements — 115 classes, 7,647 lines, shared net/minecraft/advancements/predicates — 53 classes, 3,450 lines, shared net/minecraft/advancements/triggers — 49 classes, 2,816 lines, shared net/minecraft/advancements — 13 classes, 1,381 lines, shared net/minecraft/gametest — 48 classes, 5,756 lines, shared net/minecraft/gametest/framework — 46 classes, 5,737 lines, shared net/minecraft/gametest — 2 classes, 19 lines, shared net/minecraft/sounds — 6 classes, 2,124 lines, shared net/minecraft/sounds — 6 classes, 2,124 lines, shared sounds net/minecraft/tags — 29 classes, 1,874 lines, shared net/minecraft/tags — 29 classes, 1,874 lines, shared tags net/minecraft — 19 classes, 1,665 lines, shared net/minecraft — 19 classes, 1,665 lines, shared net/minecraft/references — 5 classes, 1,483 lines, shared net/minecraft/references — 5 classes, 1,483 lines, shared — toured in what this book skips net/minecraft/resources — 12 classes, 1,473 lines, shared net/minecraft/resources — 12 classes, 1,473 lines, shared com/mojang/math — 10 classes, 1,054 lines, shared com/mojang/math — 10 classes, 1,054 lines, shared math net/minecraft/stats — 10 classes, 874 lines, shared net/minecraft/stats — 10 classes, 874 lines, shared — toured in what this book skips net/minecraft/gizmos — 15 classes, 569 lines, shared net/minecraft/gizmos — 15 classes, 569 lines, shared — toured in what this book skips net/minecraft/recipebook — 3 classes, 351 lines, shared net/minecraft/locale — 3 classes, 247 lines, shared net/minecraft/realms — 4 classes, 203 lines, client-only in both jars client only hatched: toured in what this book skips 741,069 lines, 7301 classes — area is lines of decompiled source
The two jars. Every box is a package, its area is lines of decompiled source; the atlas walks through it. Click to enlarge.

The four boxes of the first picture are the four threads that carry nearly all of it — the Render thread, which is also the client’s game thread; the Server thread; the Netty event loop; and a shared worker pool, whose threads are named Worker-Main-n — and the first lecture of the book, Anatomy, is those four threads and the two loops.

How the book is read

This site is the notes for a video lecture series, and that is why it keeps saying watched where a book would say read. One system page is one lecture; the page stands alone and nothing on it leans on the video to make sense, but the order, the scenarios and the figures are all built for someone who will eventually be shown them. The site is that series in three tiers, and the sidebar is its table of contents.

Parts are watched in order. Thirteen of them, I to XIII, each a system: the anatomy of the two programs, the foundations they are both built out of, the server, the world, blocks, entities, items, the player, networking, the client, rendering, world generation, and commands. Each opens on a landing page that argues what its part claims about its system, says what shape the part is, names the parts it assumes and what it uses each of them for, lists its pages in the order to watch them, says where the part stops, and says which Reference pages the part reads. A page is one lecture’s notes: it follows one scenario through the system (a player walks east across a chunk boundary; a server is clicked in the list) and its figure is the artefact — a sequence diagram whose lanes are class names, a state machine, a flowchart of a decision. Every diagram enlarges on click. Each part only assumes the ones before it, and the lecture map says where that is not quite true. The picture below is the whole of that, drawn as the line it nearly is: the parts in watch order, and a solid arc from a part to each part that assumes it. The two dependencies the whole book leans on, whether or not a landing page lists them — Part I for the threads, Part II for codecs and registries — keep their boxes and the one arc each along the spine but have the rest of theirs left off, because those would reach almost every box, and the two dashed arcs are the only places a part assumes a later one, each cut on purpose rather than solved by reordering.

The thirteen parts in watch order; an arc on the right is a part another part assumes, an arc on the left is one of the two places a part assumes a later one Part I · AnatomyI · Anatomy Part II · FoundationsII · Foundations Part III · The serverIII · The server Part IV · The worldIV · The world Part V · BlocksV · Blocks Part VI · EntitiesVI · Entities Part VII · Items and inventoriesVII · Items and inventories Part VIII · The playerVIII · The player Part IX · NetworkingIX · Networking Part X · The clientX · The client Part XI · RenderingXI · Rendering Part XII · World generationXII · World generation Part XIII · Commands and data packsXIII · Commands and data packs I → II: Part II assumes Part I II → III: Part III assumes Part II III → IV: Part IV assumes Part III IV → V: Part V assumes Part IV V → VI: Part VI assumes Part V VII → VIII: Part VIII assumes Part VII IX → X: Part X assumes Part IX X → XI: Part XI assumes Part X III → V: Part V assumes Part III IV → VI: Part VI assumes Part IV V → VII: Part VII assumes Part V VI → VIII: Part VIII assumes Part VI III → VI: Part VI assumes Part III VI → IX: Part IX assumes Part VI VII → X: Part X assumes Part VII III → VII: Part VII assumes Part III VI → X: Part X assumes Part VI IX → XIII: Part XIII assumes Part IX III → VIII: Part VIII assumes Part III V → X: Part X assumes Part V III → IX: Part IX assumes Part III VII → XIII: Part XIII assumes Part VII IV → XI: Part XI assumes Part IV IV → XII: Part XII assumes Part IV III → XIII: Part XIII assumes Part III IV ⇢ III: Part III assumes Tickets and loading, Environment attributes and timelines, cut on purpose Tickets and loading Environment attributes and timelines X ⇢ V: Part V assumes Prediction and acknowledgement, cut on purpose Prediction and acknowledgement

The thirteen parts top to bottom in watch order; an arc on the right runs from a part to one that assumes it, always downward, and the two dashed arcs on the left are the only places a part assumes a later one, each labelled with the pages it needs.

Maps are looked at once. The atlas is four views of the decompile — where the code is, where the mass is, what everything imports and what extends what. Each view’s figure and its table are regenerated on every deploy, so their numbers are re-derived each time; the prose around them is written by hand from those tables, or from the tree where no table holds a number, and is re-read when the version moves. It is the “where is everything” answer a newcomer wants before any system page makes sense.

Reference is looked up. Twenty-three pages, of which these are the ones a reader reaches for first: the glossary, the naming drift table, a class index that answers “which page talks about ChunkMap”, the diagram lanes and the threads. Thirteen of the twenty-three are rewritten from the decompile or from the corpus on every deploy, so their rows are re-derived each time; the other ten are hand-kept, and the shelf’s own front page says which is which. The rule for what belongs here is would a viewer pause the video to read this.

For agents, the whole site is one file: llms-full.txt, regenerated on every deploy.

The rules the book keeps

Names, never code. A page names classes, methods, fields and packages so that anyone with the decompiled source can find them in a minute, and explains what they own, when they run and how they interact. It never reproduces the source — not a method body, not a snippet. Anyone who needs the code decompiles the game themselves, which is also the line Mojang’s mappings licence draws.

Mojang’s names. Every game identifier is Mojang’s official mapping, which the decompile uses. Fabric’s Yarn names differ; where a modder would not recognise a class under its official name, the Yarn name is noted once. Names have moved since 1.21 — even since 1.21.11, Lightmap was LightTexture and RedstoneWireBlock was RedStoneWireBlock — and the naming drift table is the translation.

Newest version only. Every page that describes the game says in its header which release it was verified against, or for a generated view which release it was generated from, and the book’s is 26.3. There are no version-difference sections, and the only “in 1.x this was” on a system page is the For a 1.21-era reader note at its foot. When a release lands, every page is re-read against it, and until a page has been, its header still names the release it was checked against.

Verified means tested. Every backticked name on every written page, and every class name of more than one word and every member named with its class or its lane inside a diagram, is checked against the decompile of the release the page’s header names before the site publishes, every diagram is parsed by the same mermaid the site ships, every lane in every diagram is checked against the one key the whole book uses, and every link and anchor between pages is checked to land. A page that fails any of those does not go up, and neither does a change that puts the landing pages, the sidebar, the lecture map, the dependency figure and the Reference shelf’s own index of who uses it out of step with each other. That is a narrow guarantee, and it is worth stating narrowly: it proves the names are real in that release, not that the sentence around them is true. The sentences are what the passes are for. The book has been fact-checked against the decompile three times — as drafted, after the pages were restructured into the book you are reading, and again for this release — and a page written after the first check has had every check since. The first two times every page checked had something wrong on it, and the third found errors again in every part. What is left is a correction waiting to be filed, and the repository is where to file it.

How the system works, not how the code reads. Object-level: this class owns that state, this call happens on that thread, this packet is sent then. Never line-level. Code makes boring video and dates fast.

What this book skips

Most of what the treemap hatches is left out, and it falls into three kinds. Code that is version differences by definition — save migration, the util/datafix and util/filefix trees — which rule three excludes on sight. Code that is not the game — Realms, telemetry, the profiler, the management server, RCON, the data generators. And code that is the game’s bookkeeping rather than its behaviour — statistics, player reporting, and a package of id constants nobody will recognise. What this book skips, the second lecture of Part I, draws that boundary honestly — what each thing is, how big, whether the dedicated server ships it, and the two or three class names to start at if you need it anyway — so a viewer knows the edge of the map before investing in thirteen parts. It also tours three things that are not skipped and are only surprising for where they live: the OpenAL backend, which sits in Blaze3D beside the window and RenderSystem rather than in the client’s sound package; the recipe book, which sits in the statistics package and belongs to Part VII; and the debug-drawing API every debug renderer in the game is now written against.

Unofficial, and free to reuse

This is an independent description of how the game works. It is not endorsed by, sponsored by or associated with Mojang Studios or Microsoft, and Minecraft is a trademark of Mojang Synergies AB.

The book is CC BY-SA 4.0: take it, adapt it, teach from it — credit minecraftdocs.dev and keep what you build under the same licence. That covers the writing and the figures, which are the only things here that are anyone’s to license. It does not cover the game, its source, its assets or Mojang’s mappings; none of those are in this book, which is why it names identifiers and never reproduces code. Corrections, and the repository the book is written in, are on GitHub.