Network client: apply the block entity data, difficulty, spawn, chunk centre, tick rate, animations and server data the server sends
With single player on its server thread, the window is the server's client and dropped several packets the in-frame game never needed: - ClientboundBlockEntityDataPacket and the block entities of chunk packets: the block entity of that type loads the tag (signs, spawners), as handleBlockEntityData and LevelChunk.replaceWithPacketData do. - ClientboundChangeDifficultyPacket: the level data's difficulty and lock. - ClientboundSetDefaultSpawnPositionPacket: the respawn data spawn compasses point at. - ClientboundSetChunkCacheCenterPacket: ClientChunkCache's view centre; columns outside the storage (the server's radius + 3) are ignored or dropped, as ClientChunkCache.Storage does. - ClientboundAnimatePacket: wake up, and the critical and magic critical hit emitters. - ClientboundTickingStatePacket / ClientboundTickingStepPacket (new in the protocol crate): the level's TickRateManager. A frozen level holds its time and non-player entities, and the server's rate only ever slows the client timer down (Minecraft.getTickTargetMillis). - ClientboundServerDataPacket: the server list entry keeps a valid icon (ServerList.saveSingleServer); single player has no entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -574,6 +574,14 @@ packet!(
|
||||
);
|
||||
packet!(Text { text: Tag => Nbt });
|
||||
packet!(SetChunkCacheCenter { x: i32 => VarInt, z: i32 => VarInt });
|
||||
packet!(
|
||||
/// ClientboundTickingStatePacket: the tick rate and whether the level is frozen.
|
||||
TickingState { rate: f32 => Float, frozen: bool => Bool }
|
||||
);
|
||||
packet!(
|
||||
/// ClientboundTickingStepPacket: the ticks a frozen level runs (`/tick step`).
|
||||
TickingStep { steps: i32 => VarInt }
|
||||
);
|
||||
packet!(Distance { distance: i32 => VarInt });
|
||||
packet!(SetCursorItem { item: Option<Stack> => Slot });
|
||||
packet!(SetDefaultSpawnPosition { pos: GlobalPos => GlobalPos, yaw: f32 => Float, pitch: f32 => Float });
|
||||
@@ -1062,6 +1070,8 @@ packet_enum!(Clientbound, crate::ids::play::clientbound {
|
||||
TabList(TabList) = TAB_LIST,
|
||||
TakeItemEntity(TakeItemEntity) = TAKE_ITEM_ENTITY,
|
||||
TeleportEntity(TeleportEntity) = TELEPORT_ENTITY,
|
||||
TickingState(TickingState) = TICKING_STATE,
|
||||
TickingStep(TickingStep) = TICKING_STEP,
|
||||
UpdateMobEffect(UpdateMobEffect) = UPDATE_MOB_EFFECT,
|
||||
UpdateTags(UpdateTags) = UPDATE_TAGS,
|
||||
});
|
||||
@@ -1523,6 +1533,11 @@ mod tests {
|
||||
relatives: 0,
|
||||
on_ground: true,
|
||||
}),
|
||||
Clientbound::TickingState(TickingState {
|
||||
rate: 40.0,
|
||||
frozen: true,
|
||||
}),
|
||||
Clientbound::TickingStep(TickingStep { steps: 7 }),
|
||||
];
|
||||
for p in packets {
|
||||
round_trip(p, Clientbound::encode, Clientbound::decode);
|
||||
|
||||
Reference in New Issue
Block a user