<!-- https://minecraftdocs.dev/systems/player/ — this page as markdown. The book's index: https://minecraftdocs.dev/llms.txt; the whole book in one file: https://minecraftdocs.dev/llms-full.txt -->

# VIII · The player

> Verified against **Minecraft 26.3** · Part VIII · The entity a human plays as: what it is made of, when it runs, and the five 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. You meet it as 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 — and every one of those is the same
thing showing through. A player is an entity like any other, with the same
base class, the same tick and the same synched data, and then almost every
rule is bent for it: it is ticked twice instead of once, its inventory
reports seven slots it does not store, its melee combat has three separate
entry points of which the famous one is the least interesting, and the server
simulates its movement in full every tick and then throws the answer away.
**The server is not allowed to be right about the player** — nor about
anything a player steers, which borrows the player's authority — and this part
is the cost of that.

## 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. The inventory has no lecture of
its own and does not need one: Part VII stops at the slot, and the container
those slots sit in is a section of *player anatomy*, because what is
interesting about it is that seven of its forty-three slots are somewhere
else. So the shape is a trunk of two pages, four branches that do not depend
on one another, and one sequel — which is what the figure numbers.

```mermaid
flowchart TD
    PA["1 · Player anatomy — eight classes, forty-three slots"]
    TT["2 · The two-phase tick — when it runs, and what is thrown away"]
    IM["3 · Input to movement — walking, and being believed"]
    SS["4 · The sword swing — one integer, and a number rebuilt"]
    SP["5 · The spear — two more melee paths"]
    HE["6 · Hunger and experience — two bars the server owns"]
    SE["7 · Status effects — a list of things happening to you"]
    PA --> TT
    TT --> IM
    TT --> SS
    TT --> HE
    TT --> SE
    SS -- "its sequel" --> SP
```

*The trunk and its four branches, numbered to the watch order: an arrow means
the page below assumes the page above, and the four leaving the two-phase
tick are independent of one another, so the labelled edge is the only order
this part insists on beyond the trunk.*

## Before you start

[Part VI](../entities/README) is the hard prerequisite, and two of its
pages in particular. [Entity
anatomy](../entities/entity-anatomy#the-tree-and-the-class-that-was-inserted-into-it),
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](../entities/authority#five-predicates-and-the-final-one-the-other-four-hang-off)**,
because every page here rests on it — a `Player` is client-authoritative on
*both* sides, and 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. Three more of Part VI's are assumed
rather than re-taught: [attributes](../entities/attributes#forty-numbers-every-one-of-them-clamped),
because the reach and base numbers of an ordinary swing are attributes; [synched entity
data](../entities/synched-entity-data#nineteen-slots-and-where-the-numbers-come-from);
and [movement and collision](../entities/movement-and-collision#the-tick),
the pipeline *input to movement* feeds and never repeats.

Then [the server tick](../server/server-tick#where-a-players-own-tick-actually-happens)
and [the level tick](../server/server-level-tick#every-entity-and-then-its-riders),
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](../server/players-and-sessions#preparing-a-place-to-stand) owns
how a `ServerPlayer` comes to exist at all, and how the session it belongs to
ends. From [Part VII](../items/README), [using an
item](../items/using-an-item#the-two-paths-side-by-side), because the
spear's charge is an item you *use* and the meal in *hunger and experience*
is that same machinery from the eater's end.

## Watch in this order

1. [Player anatomy](player-anatomy) — the vocabulary page: eight
   classes, two game-mode objects, forty-three slots. There is a rung between
   `LivingEntity` and `Player` — `Avatar` — with no instance state at all,
   shared with a posable dummy; and the main-hand item has no storage of its
   own, being the selected hotbar slot seen through the equipment container a
   horse also has.
2. [The two-phase tick](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](input-to-movement) — W is pressed. A held movement
   key pressed and released between two ticks never happened, flooding the server
   with move packets 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](the-sword-swing) — left-click on a pig. The attack
   packet carries one integer and the server rebuilds the rest, charging the
   hit against a cooldown twice in two different shapes — quadratically on the
   base damage, linearly on the enchantment bonus — and multiplying the mace's
   fall bonus by the critical hit.
5. [The spear](the-spear) — 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](hunger-and-experience) — two bars the server
   owns outright. Walking costs exactly zero exhaustion; a full bar with
   saturation left heals up to eight times faster than one at eighteen; and the
   experience packet watches the *total*, so every mutation that moves only
   your level has to poison the last-sent value by hand.
7. [Status effects](status-effects) — the part's closer, and its cleanest
   statement of the server/client split: the client runs none of an effect's
   behaviour — it counts the effect down, draws it, and reads it for its own
   movement. The server corrects that countdown by testing whether the
   remaining duration divides by six hundred, so the periodic correction never
   reaches an infinite effect, whose duration is −1.

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.

## Where the part stops

Part VIII is the smallest part of the book with a system in it (only Part I
is smaller, and Part I is two pages about the program the rest run inside
and what the book leaves out) —
**32 files and 8,460 lines** in `world/entity/player`,
`world/food`, `ServerPlayer` and `client/player` — and the coverage question
has an almost trivial answer here:
**1% of the part's lines are named on no page in the book**. A player is a small object
surrounded by large ones, so the interesting borders are not the ones inside
these packages but the ones just outside them.

Upward, the part starts at `Avatar` rather than at `Entity`: `Avatar` sits
in Part VI's package and is explained here, beside the `Mannequin` — the
posable dummy that shares the rung, and the reason the rung exists — and what
a player inherits above it belongs to [Part VI](../entities/README).
Outward, it stops where the player stops being a player. How a hit is
resolved once it lands is [damage and
death](../entities/damage-and-death#the-number-the-arrow-decides) in Part
VI; what your client is *told* about everyone else is [what the client is
told](../networking/what-the-client-is-told#one-entitys-tick-and-the-gates-it-does-not-pass)
in Part IX; the ledger behind the block you already saw break is [prediction
and acknowledgement](../client/prediction-and-acks#the-four-writes) in
Part X; drawing a player, its skin and its model parts is Part XI's; and the chat session a `ServerPlayer` carries — the public half of message signing,
the key itself never leaving the client — belongs to [chat and
signing](../networking/chat-and-signing#what-the-signature-covers). The
two game-mode objects, `ServerPlayerGameMode` and `MultiPlayerGameMode`, are
the sharpest border of all: this part says what they hold, and what they
*do* with a block is Part V's two click pages.

Three things a reader will look for here have no lecture. Two are declined: `Hotbar`, and the
`HotbarManager` just outside these packages that keeps the nine *saved*
creative hotbars, belong to the creative screen's saved hotbars, which this
book does not cover; and sleep is
half-explained on purpose, with [player
anatomy](player-anatomy#what-player-owns) naming the fields and the
refusals a bed answers with while the *everyone is asleep* half — the night
skip and the weather reset — belongs to [the level
tick](../server/server-level-tick#a-freeze-stops-the-clock-and-not-the-sleep-check).
The third is simply missing, and is the one gap this part admits rather than
declines: nobody explains the walk between those two halves — what one player
lying down does over the hundred ticks of `Player.SLEEP_DURATION`
that follow, and which of the two owners is driving during them.

## Reference this part uses

[Attributes](../../reference/attributes), because reach, attack damage,
attack speed, sweeping ratio and knockback are all attributes — and attack
damage and knockback, two of those that decide what a hit is worth, are not
synced to the client at all. [Packets](../../reference/packets) for the
movement, attack and health packets by name. [Data
components](../../reference/components) for the components that make an
item a weapon. [Damage outside
`LivingEntity`](../../reference/non-living-damage) for what a swing meets
when the target is not a living entity. Then [game
rules](../../reference/gamerules), [level data and
rules](../../reference/level-data-and-rules) and [diagram
lanes](../../reference/lanes).

---

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