Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix blog post networking code #88

Merged
merged 2 commits into from
Apr 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions _posts/2024-04-19-1205.md
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,9 @@ var nbt = PacketCodecs.NBT_COMPOUND;

// Serializing a registry value (by raw ID)
// Note: these require RegistryByteBuf!
PacketCodecs<RegistryByteBuf, Item> item = PacketCodecs.registryValue(RegistryKeys.ITEM);
PacketCodec<RegistryByteBuf, Item> item = PacketCodecs.registryValue(RegistryKeys.ITEM);
// Or, RegistryEntry
PacketCodecs<RegistryByteBuf, Biome> biome = PacketCodecs.registryEntry(RegistryKeys.BIOME);
PacketCodec<RegistryByteBuf, Biome> biome = PacketCodecs.registryEntry(RegistryKeys.BIOME);

// Serializing an Enum
var axis = PacketCodecs.indexed(i -> Direction.Axis.VALUES[i], Direction.Axis::ordinal);
Expand Down Expand Up @@ -400,12 +400,12 @@ Then, you can change the receiver. Instead of long parameters, the event callbac

Here are the available fields in the context object:

| `PayloadTypeRegistry` | Class | Fields |
| --------------------- | ---------------------- | ------------------------------------ |
| `playC2S` | `ServerPlayNetworking` | `player`, `responseSender` |
| `playS2C` | `ClientPlayNetworking` | `client`, `player`, `responseSender` |
| `configurationC2S` | `ServerConfigurationNetworking` | `networkHandler`, `responseSender` |
| `configurationS2C` | `ClientConfigurationNetworking` | `responseSender` |
| `PayloadTypeRegistry` | Class | Context Fields |
|-----------------------|---------------------------------|--------------------------------------|
| `playC2S` | `ServerPlayNetworking` | `player`, `responseSender` |
| `playS2C` | `ClientPlayNetworking` | `client`, `player`, `responseSender` |
| `configurationC2S` | `ServerConfigurationNetworking` | `networkHandler`, `responseSender` |
| `configurationS2C` | `ClientConfigurationNetworking` | `responseSender` |

Note that the field shortcuts might be added later.

Expand Down
Loading