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 EffectCure syncing by introducing connection aware StreamCodec #1041

Merged

Conversation

RaymondBlaze
Copy link
Contributor

Due to the nature of the StreamCodec, modifying vanilla StreamCodecs due to NeoForge's extra data has always been hard when it comes to keep NeoForge<->Vanilla connection compatibility.

In some cases, we can make use of unused fields like list size (like in the Ingredient's StreamCodec) to conditionally write or read NeoForge specific data, but that's not always applicable, like #986.

The workaround for #986 in this PR is to patch RegistryFriendlyByteBuf to let it contain NeoForge's ConnectionType and thus providing context for StreamCodec to handle serialization/deserialization differently for NEOFORGE and OTHER connections.

…nto connection-aware-stream-codec

# Conflicts:
#	patches/net/minecraft/world/effect/MobEffectInstance.java.patch
@neoforged-pr-publishing
Copy link

neoforged-pr-publishing bot commented May 30, 2024

  • Publish PR to GitHub Packages

Last commit published: e71a8d4206bebeae304a4e0aa6f0168b080f3685.

PR Publishing

The artifacts published by this PR:

Repository Declaration

In order to use the artifacts published by the PR, add the following repository to your buildscript:

repositories {
    maven {
        name 'Maven for PR #1041' // https://github.com/neoforged/NeoForge/pull/1041
        url 'https://prmaven.neoforged.net/NeoForge/pr1041'
        content {
            includeModule('net.neoforged', 'neoforge')
            includeModule('net.neoforged', 'testframework')
        }
    }
}

MDK installation

In order to setup a MDK using the latest PR version, run the following commands in a terminal.
The script works on both *nix and Windows as long as you have the JDK bin folder on the path.
The script will clone the MDK in a folder named NeoForge-pr1041.
On Powershell you will need to remove the -L flag from the curl invocation.

mkdir NeoForge-pr1041
cd NeoForge-pr1041
curl -L https://prmaven.neoforged.net/NeoForge/pr1041/net/neoforged/neoforge/20.6.121-beta-pr-1041-connection-aware-stream-codec/mdk-pr1041.zip -o mdk.zip
jar xf mdk.zip
rm mdk.zip || del mdk.zip

To test a production environment, you can download the installer from here.

@RaymondBlaze RaymondBlaze requested a review from XFactHD June 1, 2024 12:47
Copy link
Member

@XFactHD XFactHD left a comment

Choose a reason for hiding this comment

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

Looks fine to me now. Have you tested whether connecting an NF server to a vanilla client and vice-versa and then interacting with something referencing effects such as potions works fine?

@RaymondBlaze
Copy link
Contributor Author

Looks fine to me now. Have you tested whether connecting an NF server to a vanilla client and vice-versa and then interacting with something referencing effects such as potions works fine?

After the latest commit replacing StreamCodec#unit usage, potion with custom effect (containing custom cures on NF server) can be now used in both connections.

@RaymondBlaze RaymondBlaze requested a review from XFactHD June 4, 2024 02:59
@RaymondBlaze RaymondBlaze requested a review from XFactHD June 5, 2024 03:11
@Matyrobbrt Matyrobbrt added bug A bug or error 1.20.6 Targeted at Minecraft 1.20.6 labels Jun 5, 2024
XFactHD
XFactHD previously approved these changes Jun 6, 2024
Shadows-of-Fire
Shadows-of-Fire previously approved these changes Jun 6, 2024
Copy link
Contributor

@Shadows-of-Fire Shadows-of-Fire left a comment

Choose a reason for hiding this comment

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

Seems fine with me. If we encounter problems with the type-tightening from ByteBuf to RFBB on the mob effect instance codec, we can adjust it to downcast when available.

I suspect we will not encounter such issues, I don't envision anyone syncing specifically MobEffectInstance.Details outside of the Play phase, given that the only usage is in MobEffectInstance which requires RFBB.

@Shadows-of-Fire Shadows-of-Fire added the last call Planned to be resolved by the end of the week, awaiting any last-minute comments label Jun 6, 2024
Copy link
Member

@Technici4n Technici4n left a comment

Choose a reason for hiding this comment

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

Basically two suggestions. What do you think @Shadows-of-Fire and @XFactHD?

@RaymondBlaze RaymondBlaze dismissed stale reviews from XFactHD and Shadows-of-Fire via e71a8d4 June 8, 2024 13:11
@Matyrobbrt Matyrobbrt merged commit 6837166 into neoforged:1.20.x Jun 10, 2024
4 checks passed
@RaymondBlaze RaymondBlaze deleted the connection-aware-stream-codec branch July 16, 2024 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.20.6 Targeted at Minecraft 1.20.6 bug A bug or error last call Planned to be resolved by the end of the week, awaiting any last-minute comments
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants