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

VIII · The player

Verified against Minecraft 26.2 · Part VIII · The one entity a human is steering: what it is made of, when it runs, and the four things it does that the rest of the world does differently.

Everything in Parts IV to VII happens to the world. This part is about the one object in it that argues back. A player is an entity like any other — same base class, same tick, same synched data — and then almost every rule is bent for it: it is ticked twice instead of once, it is the only thing the server simulates and then contradicts, its inventory reports seven slots it does not store and aliases an eighth, and its melee combat has three separate entry points of which the famous one is the least interesting. A player recognises the part by the friction: the snap back after a laggy jump, the swing that does more damage if you wait, the food bar that empties from sprinting and not from walking, the effect timer that keeps counting while the connection is down.

The shape of the part

Part VIII is a trunk and four branches. Two pages say what a player is and when it runs; everything after them is one thing a player does, and they are independent of each other — except the spear, which is the sword swing’s sequel and should not be watched before it.

flowchart TD
    PA["Player anatomy — what a player is made of"]
    TT["The two-phase tick — when it runs, and what is thrown away"]
    IM["Input to movement — walking, and being believed"]
    SS["The sword swing — one integer, and a number rebuilt"]
    SP["The spear — the same hit, twice, neither through Player.attack"]
    HE["Hunger and experience — two bars the server owns"]
    SE["Status effects — a list of things happening to you"]
    PA -- "eight classes, forty-three slots" --> TT
    TT -- "phase two is where the player acts" --> IM
    TT --> SS
    TT --> HE
    TT --> SE
    SS -- "and two other melee paths" --> SP

Before you start

Part VI is the hard prerequisite, and two of its pages in particular. Entity anatomy, because a player is a LivingEntity with three rungs added on the server and four on the client, and this part never re-teaches the base; and authority, because every page here rests on it — a Player is client-authoritative on both sides, which is why the server’s own answer for your movement is thrown away in favour of the number you sent it. If you watch one page from another part first, watch that one.

Then the server tick and the level tick, because half this part’s timing claims are about which phase something ran in — including the fact that a player’s own physics run after every level has finished. Players and sessions owns how a ServerPlayer comes to exist at all. And Part VII for the inventory this part stops at the edge of: using an item in particular, because the spear is an item you use.

Watch in this order

  1. Player anatomy — the vocabulary page: eight classes, two game-mode objects, forty-three slots. There is an abstract class between LivingEntity and PlayerAvatar — with no instance fields at all, and the main-hand item is not stored anywhere: it is the selected hotbar slot, aliased.
  2. The two-phase tick — one player, one tick, twice. The connection records where you are, runs the whole physics pipeline, and then puts you back: the server keeps the velocity and throws the position away.
  3. Input to movement — W is pressed. A movement key held for less than a tick never happened, sending move packets faster makes the anti-cheat stricter, and the packet that reports your key presses cannot move you but can move a minecart.
  4. The sword swing — left-click on a pig. The attack packet carries one integer and the server rebuilds the rest, applying the cooldown twice in two different shapes and multiplying the mace’s fall bonus by the critical hit.
  5. The spear — the 26.2 combat change, and the part’s most surprising lecture. Two components on one item: a stab whose packet has no target in it, and a charge whose damage comes from closing speed and which ignores the attack cooldown entirely.
  6. Hunger and experience — two bars the server owns outright. Walking costs exactly zero exhaustion, and not one of the named thresholds in the file the system is built on is read by anything — FoodData writes every number as a literal instead.
  7. Status effects — the part’s closer, and the cleanest statement of the server/client split in the book: the client never runs a single one of an effect’s hooks, only counts it down — and an infinite effect is never re-sent, because −1 never satisfies the re-send test.

Watched as lectures, one and two are the pair to keep together, and four and five are the other pair. Six and seven can be watched in either order, or skipped and returned to.

Reference this part uses

Attributes, because reach, attack damage, attack speed, sweeping ratio and knockback are all attributes — and attack damage and knockback, the two that decide what a hit is worth, are not synced to the client at all. Packets for the movement, attack and health packets by name. Data components for the components that make an item a weapon — eight of them on a spear. Then game rules, level data and rules and diagram lanes.

The part stops where the player stops being a player: how a hit is resolved once it lands is damage and death in Part VI, what your client is told about everyone else is what the client is told in Part IX, and the ledger behind the block you already saw break is prediction and acknowledgement in Part X.


Rules: names, never code · how the system works, not how the code reads · newest version only · every backticked name passes tools/verify_names.py.