RegionIO/internal/protocol/ids.go
Master290 57214fbd76 Run the world clock so day and night happen
set_time was declared nowhere and sent never, so the client's sky was frozen
wherever it started: the sun did not move, night did not fall, and nothing in
the world had a time.

26.1.2 replaced the old (gameTime, dayTime, doDaylightCycle) triple with a
registry of named clocks. The packet now carries a fixed-width game time plus a
map from world clock to (totalTicks, partialTick, rate); the client advances
each clock locally at its rate and drives the minecraft:day timeline -- a
keyframe track over a 24000-tick period -- from the overworld clock. The clock
registry is already among the 28 we sync, so the id is looked up rather than
hardcoded and the server refuses to start if it is missing.

The counter rides the entity tick loop because that is the only loop already
running at 20 TPS. It belongs on the single authoritative tick the engine still
needs; putting a sixth ticker beside the five that exist would make that worse.
Broadcast every second, which is what vanilla does -- the client interpolates in
between, so the resend only corrects drift.

The clock also persists now. The world metadata file was written once and never
touched again; it is atomically rewritable, carries gameTime and dayTime, and a
file written before those fields existed still opens and resumes at dawn as it
did. Saved every 30 seconds alongside the chunk autosave, and once more on
shutdown after the final flush.
2026-07-27 02:45:28 +03:00

130 lines
3 KiB
Go

package protocol
// Packet IDs, grouped by state and direction. Serverbound = client→server,
// Clientbound = server→client. Values are for protocol 775 (26.1.2).
// Handshaking, serverbound.
const (
HandshakeID = 0x00
)
// Status, serverbound.
const (
StatusRequestID = 0x00
PingRequestID = 0x01
)
// Status, clientbound.
const (
StatusResponseID = 0x00
PongResponseID = 0x01
)
// Login, serverbound.
const (
LoginStartID = 0x00
EncryptionResponse = 0x01
LoginPluginResponse = 0x02
LoginAcknowledgedID = 0x03
CookieResponseLogin = 0x04
)
// Login, clientbound.
const (
LoginDisconnectID = 0x00
EncryptionRequest = 0x01
LoginSuccessID = 0x02
SetCompressionID = 0x03
LoginPluginReq = 0x04
CookieRequestLogin = 0x05
)
// Configuration, serverbound.
const (
ConfigClientInformation = 0x00
ConfigCookieResponse = 0x01
ConfigCustomPayload = 0x02
ConfigFinishServerbound = 0x03
ConfigKeepAliveServer = 0x04
ConfigPong = 0x05
ConfigResourcePackResp = 0x06
ConfigKnownPacksServer = 0x07
)
// Configuration, clientbound.
const (
ConfigCookieRequest = 0x00
ConfigCustomPayloadCB = 0x01
ConfigDisconnect = 0x02
ConfigFinishClientbound = 0x03
ConfigKeepAliveCB = 0x04
ConfigPing = 0x05
ConfigRegistryData = 0x07
ConfigUpdateEnabledFeatures = 0x0c
ConfigUpdateTags = 0x0d
ConfigKnownPacksCB = 0x0e
)
// Play, clientbound (protocol 775).
const (
PlayLogin = 0x31
PlayGameEvent = 0x26
PlayKeepAliveCB = 0x2c
PlayPlayerPosition = 0x48
PlayDefaultSpawnPos = 0x61
PlayChunkCacheCenter = 0x5e
PlayLevelChunk = 0x2d
PlayForgetLevelChunk = 0x25
PlayAbilities = 0x40
PlaySetHeldSlot = 0x69
PlayDisconnect = 0x20
PlayBlockUpdate = 0x08
PlayBlockChangedAck = 0x04
PlaySystemChat = 0x79
PlayLightUpdate = 0x30
PlayPlayerInfoRemove = 0x45
PlayPlayerInfoUpdate = 0x46
PlaySetTime = 0x71
// Entity packets
PlayAddEntity = 0x01
PlayTeleportEntity = 0x7d
PlayMoveEntityPos = 0x35
PlayMoveEntityPosRot = 0x36
PlayMoveEntityRot = 0x38
PlaySetEntityMotion = 0x65
PlayRemoveEntities = 0x4d
PlaySetEntityData = 0x63
PlaySetEquipment = 0x66
)
// Play, serverbound (protocol 775).
const (
PlayAcceptTeleport = 0x00
PlayKeepAliveServer = 0x1c
PlayClientTickEnd = 0x0d
PlayClientInformation = 0x0e
PlayCustomPayload = 0x16
PlayMovePos = 0x1e
PlayMovePosRot = 0x1f
PlayMoveRot = 0x20
PlayMoveStatusOnly = 0x21
PlayPlayerLoaded = 0x2c
PlayPlayerAction = 0x29
PlayUseItemOn = 0x42
PlaySetCreativeSlot = 0x38
PlaySetCarriedItem = 0x35
PlayChatMessage = 0x09
)
// GameEvent sub-IDs carried by the clientbound game_event packet.
const (
GameEventStartWaitingChunks = 13
)
// NextState values carried by the handshake packet.
const (
NextStateStatus = 1
NextStateLogin = 2
NextStateTransfer = 3
)