valence/crates
Ryan Johnson 11ba70586e
Decoupled Packet Handlers (#315)
## Description

Closes #296 

- Redesigned the packet decoder to return packet _frames_ which are just
the packet ID + data in raw form.
- Made packet frame decoding happen in the client's tokio task. This has
a few advantages:
- Packet frame decoding (decompression + decryption + more) can happen
in parallel.
- Because packets are parsed as soon as they arrive, an accurate
timestamp can be included with the packet. This enables us to implement
client ping calculation accurately.
- `PacketEvent`s are now sent in the event loop instead of a giant match
on the serverbound packets. This is good because:
- Packets can now be handled from completely decoupled systems by
reading `PacketEvent` events.
- The entire packet is available in binary form to users, so we don't
need to worry about losing information when transforming packets to
events. I.e. an escape hatch is always available.
  - The separate packet handlers can run in parallel thanks to bevy_ecs.
- The inventory packet handler systems have been unified and moved
completely to the inventory module. This also fixed some issues where
certain inventory events could _only_ be handled one tick late.
- Reorganized the client module and moved things into submodules.
- The "default event handler" has been removed in favor of making
clients a superset of `PlayerEntityBundle`. It is no longer necessary to
insert `PlayerEntityBundle` when clients join. This does mean you can't
insert other entity types on the client, but that design doesn't work
for a variety of reasons. We will need an "entity visibility" system
later anyway.

## Test Plan

Steps:
1. Run examples and tests.
2023-04-08 19:55:31 +00:00
..
dump_schedule dump_schedule utility (#300) 2023-03-23 01:01:50 -07:00
packet_inspector Decoupled Packet Handlers (#315) 2023-04-08 19:55:31 +00:00
playground Decoupled Packet Handlers (#315) 2023-04-08 19:55:31 +00:00
valence Decoupled Packet Handlers (#315) 2023-04-08 19:55:31 +00:00
valence_anvil Decoupled Packet Handlers (#315) 2023-04-08 19:55:31 +00:00
valence_nbt Update to 1.19.4 (#302) 2023-03-31 14:58:47 -07:00
valence_protocol Decoupled Packet Handlers (#315) 2023-04-08 19:55:31 +00:00
valence_protocol_macros Decoupled Packet Handlers (#315) 2023-04-08 19:55:31 +00:00
valence_spatial_index Reorganize Packages (#180) 2022-12-29 16:51:05 -08:00
valence_stresser Decoupled Packet Handlers (#315) 2023-04-08 19:55:31 +00:00