Skip to content

Commit

Permalink
Fix blog post networking code (#88)
Browse files Browse the repository at this point in the history
* Fix blog post networking code

* Fix context fields
  • Loading branch information
kevinthegreat1 authored Apr 29, 2024
1 parent b7af8f2 commit 03f4491
Showing 1 changed file with 8 additions and 8 deletions.
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

0 comments on commit 03f4491

Please sign in to comment.