Skip to content

Commit

Permalink
fix(docs): Apply Xfact's suggestions
Browse files Browse the repository at this point in the history
Co-authored-by: Dennis C <xfacthd@gmx.de>
  • Loading branch information
ChampionAsh5357 and XFactHD authored May 22, 2024
1 parent f245f90 commit a8cf187
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions docs/networking/streamcodecs.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ Unless you are manually handling the buffer object, you will generally never cal
| `QUATERNIONF` | `Quaternionf` |
| `GAME_PROFILE` | `GameProfile` |

\* `byte[]` can be limited to a certan number of values via `ByteBufCodecs#byteArray`.
\* `byte[]` can be limited to a certain number of values via `ByteBufCodecs#byteArray`.

\* `String` can be limited to a certan number of characters via `ByteBufCodecs#stringUtf8`.
\* `String` can be limited to a certain number of characters via `ByteBufCodecs#stringUtf8`.

Additionally, there are some static instances that encode and decode primivites and objects using a different method.

Expand All @@ -60,7 +60,7 @@ Additionally, there are some static instances that encode and decode primivites

#### Variable-Sized Number

`VAR_INT` and `VAR_LONG` are alternatives of `INT` where the value is encoded to be as small as possible. This is done by encoding seven bits at a time, using the upper bit as a marker of whether there is more data for this number. Numbers between 0 and 2^28-1 for integers or 0 and 2^56-1 for longs will be sent shorter or equal to the number of bytes in a integer or long, respectively. If the values of your numbers are normally between this range, these variable stream codecs should be used.
`VAR_INT` and `VAR_LONG` are alternatives of `INT` and `LONG` respectively where the value is encoded to be as small as possible. This is done by encoding seven bits at a time, using the upper bit as a marker of whether there is more data for this number. Numbers between 0 and 2^28-1 for integers or 0 and 2^56-1 for longs will be sent shorter or equal to the number of bytes in a integer or long, respectively. If the values of your numbers are normally in this range and generally at the lower end of it, then these variable stream codecs should be used.

#### Trusted Tags

Expand Down Expand Up @@ -180,7 +180,7 @@ public static final StreamCodec<ByteBuf, IEventBus> UNIT_STREAM_CODEC =
```
### Lazy Initialized

Sometimes, a stream codec may rely on data that is not present when it is constructed. In these situations `NeoForgeStreamCodecs#lazy` can be used to for a stream codec to construct itself on first read/write. The method takes in a supplied stream codec.
Sometimes, a stream codec may rely on data that is not present when it is constructed. In these situations `NeoForgeStreamCodecs#lazy` can be used for a stream codec to construct itself on first read/write. The method takes in a supplied stream codec.

```java
public static final StreamCodec<ByteBuf, IEventBus> LAZY_STREAM_CODEC =
Expand Down Expand Up @@ -263,7 +263,7 @@ public enum ExampleIdObject {
ByIdMap.continuous(
ExampleIdObject::getId,
ExampleIdObject.values(),
ByIdMap.OutOfBoundsStrategy.ZERO
ByIdMap.OutOfBoundsStrategy.ZERO
);

ExampleIdObject(int id) { /* ... */ }
Expand Down Expand Up @@ -314,7 +314,7 @@ public static final StreamCodec<RegistryFriendlyByteBuf, Holder<SoundEvent>> STR

### Holder Sets

Tags or sets of holder wrapped registry objects can be sent using `holderSet`. This takes in a `ResourceKey` represent the registry the registry objects are in.
Tags or sets of holder wrapped registry objects can be sent using `holderSet`. This takes in a `ResourceKey` representing the registry the registry objects are in.

```java
public static final StreamCodec<RegistryFriendlyByteBuf, HolderSet<Item>> HOLDER_SET_STREAM_CODEC =
Expand All @@ -323,7 +323,7 @@ public static final StreamCodec<RegistryFriendlyByteBuf, HolderSet<Item>> HOLDER

### Recursive

Sometimes, an object may reference an object of the same type as a field. For example, `MobEffectinstance` takes in an optional `MobEffectinstance` if there is a hidden effect. In this case, `StreamCodec#recursive` can be used to supply the stream codec as part of a function to create the stream codec.
Sometimes, an object may reference an object of the same type as a field. For example, `MobEffectInstance` takes in an optional `MobEffectInstance` if there is a hidden effect. In this case, `StreamCodec#recursive` can be used to supply the stream codec as part of a function to create the stream codec.

```java
// Define our recursive object
Expand Down

1 comment on commit a8cf187

@neoforged-pages-deployments
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploying with Cloudflare Pages

Name Result
Last commit: a8cf18788c4372f279ddfc4b65f3a0b047a02d43
Status: ✅ Deploy successful!
Preview URL: https://175a1a3b.neoforged-docs-previews.pages.dev
PR Preview URL: https://pr-80.neoforged-docs-previews.pages.dev

Please sign in to comment.