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

Client network handling is abusing Fabric API impl details #15

Closed
i509VCB opened this issue Nov 22, 2020 · 0 comments
Closed

Client network handling is abusing Fabric API impl details #15

i509VCB opened this issue Nov 22, 2020 · 0 comments

Comments

@i509VCB
Copy link
Contributor

i509VCB commented Nov 22, 2020

So I notice at this line you cast the packet context to the client play network handler:
https://github.com/LordDeatHunter/FabricWaystones/blob/main/src/main/java/wraith/waystones/WaystonesClient.java#L29

In my testing of the new networking api on AOF 3, I noticed your mod causes the client to disconnect due to the use of the implementation detail where the packet context is mixed into the client play network handler.

The specific error is:

[17:02:32] [Netty Epoll Client IO #3/ERROR]: Encountered exception while handling in channel with name "waystones:waystone_packet"
java.lang.ClassCastException: net.fabricmc.fabric.impl.networking.ClientSidePacketRegistryImpl$1 cannot be cast to net.minecraft.class_634
	at wraith.waystones.WaystonesClient.lambda$registerPacketHandlers$0(WaystonesClient.java:29) ~[wraith-waystones-1.0.9.jar:?]
	at net.fabricmc.fabric.impl.networking.ClientSidePacketRegistryImpl.lambda$register$0(ClientSidePacketRegistryImpl.java:65) ~[4ce7287c-cfbc-485c-ae9f-89c2e40c3485.jar:?]
	at net.fabricmc.fabric.impl.networking.client.ClientPlayNetworkAddon.receive(ClientPlayNetworkAddon.java:87) ~[a474943c-f5db-4baf-94b5-5a464f8767b4.jar:?]

To solve this issue, I would get the network handler from the Minecraft client (MinecraftClient.getInstance().getNetworkHandler()), OR upcast the player to ClientPlayerEntity and then get the network handler from the client player entity.

LordDeatHunter added a commit that referenced this issue Nov 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant