-
-
Notifications
You must be signed in to change notification settings - Fork 179
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
[1.21] Add ICustomHolderSet
support for StreamCodec
created from ByteBufCodecs#holderSet
#991
[1.21] Add ICustomHolderSet
support for StreamCodec
created from ByteBufCodecs#holderSet
#991
Conversation
|
a2c84c7
to
8601fda
Compare
src/main/java/net/neoforged/neoforge/registries/holdersets/ICustomHolderSet.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach will blow up on a NeoForge -> Vanilla connection because vanilla will try to handle the custom holder sets as HolderSet.Direct
s: The decoder will first attempt to create an ArrayList
with an initial size of Math.min(varInt, 65536)
which will throw an IllegalArgumentException
due to a negative value. If the decoder were to get past this list issue, then the data emitted by the specific implementations will either misbehave or crash when the decoder attempts to read the first entry: The AndHolderSet
and OrHolderSet
write a List<HolderSet>
(would attempt to read the list size as the first Holder
or part thereof), the NotHolderSet
writes a nested HolderSet
(would attempt to read the direct holder size or named holder set marker [the var-int being repurposed in this PR] as the first Holder
or part thereof) and the AnyHolderSet
writes nothing (would attempt to read past the buffer's end or into data that should be handled by another decoder).
I currently have no idea how this could be solved in a way that is vanilla-compatible. While it's definitely not great in terms of packet size (especially for the AnyHolderSet
), I would consider it safer to keep the fallback to HolderSet.Direct
for custom holder sets for the time being as it retains full vanilla network compatibility.
Beyond that, wouldn't making |
No, marking a registry as synced does not blow up the connection as registry sync only happens on NF<->NF connections |
This only happens if a |
…odec # Conflicts: # src/main/java/net/neoforged/neoforge/registries/NeoForgeRegistries.java
ICustomHolderSet
support for StreamCodec
created from ByteBufCodecs#holderSet
ICustomHolderSet
support for StreamCodec
created from ByteBufCodecs#holderSet
Changed target to |
@RaymondBlaze, this PR introduces breaking changes. Compatibility checks
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Impl looks fine. Couple changes needed for sanity, then should be good to go.
Fixes #981.
This PR adds support for
ICustomHolderSet
forStreamCodec
created fromByteBufCodecs#holderSet
.Introduced tests for
HolderSet
relatedCodec
andStreamCodec
.Changes
HolderSetType
is no longer a functional interface due to the newly introducedmakeStreamCodec
method.NeoForgeRegistries.HOLDER_SET_TYPES
is now synced asByteBufCodecs#holderSet
's implementation uses raw id forHolderSetType
.Implementation Note
ByteBufCodecs#holderSet
's implementation made use of the vanilla unused negativeVarInt
values(starting from -1) asHolderSetType
ids to supportICustomHolderSet
.StreamCodec
instance forICustomHolderSet
created fromHolderSetType#makeStreamCodec
method are lazily computed and cached in theStreamCodec
instance created fromByteBufCodecs#holderSet
for better performance, which is a bit different from the implementation ofHolderSetCodec
which doesn't cache the createdCodec
fromHolderSetType#makeCodec
.