Fabric Waystones

Fabric Waystones

16M Downloads

Client network handling is abusing Fabric API impl details

i509VCB opened this issue ยท 0 comments

commented

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.