Hi, can someone send me guide for correct networking on 1.21? Migrated from 1.20.4 to 1.21, as described in blog (https://fabricmc.net/2024/04/19/1205.html), but have such error. Source code: https://github.com/Hunkarada/Nen
Related to error code is here: https://github.com/Hunkarada/Nen/blob/master/src/main/java/hunkarada/nen/common/network/packet/SyncPacket.java https://github.com/Hunkarada/Nen/blob/master/src/main/java/hunkarada/nen/common/register/NenModRegister.java
#Networking issue
1 messages · Page 1 of 1 (latest)
LOOOOOOOL
THE WHOLE ERROR WAS BECAUSE OF MY PATHS
Caused by: java.lang.ClassCastException: class hunkarada.nen.common.network.packets.SyncPacket cannot be cast to class net.minecraft.network.packet.UnknownCustomPayload (hunkarada.nen.common.network.packets.SyncPacket and net.minecraft.network.packet.UnknownCustomPayload are in unnamed module of loader net.fabricmc.loader.impl.launch.knot.KnotClassLoader @42e26948)
this part
I renamed hunkarada.nen.common.network.packet.SyncPacket to hunkarada.nen.common.networks.packets.SyncPacket and it WORKS
stupid name collision, caused by ???
maybe this is because of mixin?
and
it's not resolved
I still need help with that
and this should not be paths related
it worked maybe because of another network error
because error was like (Invalid player data)
and it reproduced only once
oh, if I reconnect to server, it throws invalid player data
fixed issue with invalid player data, now only fails at encoding (old error)
so, it can't cast my SyncPacket class to UnknownCustomPayload
my class implements CustomPayload interface
and in blog of fabric (here https://fabricmc.net/2024/04/19/1205.html) it says, that it can be some strange cast errors, but cast() method in my code didn't work at all
so, why it tries to do so?
I can't do this manually, it's different classes from different packages
OMG IT WAS MORE STUPID THAN I THROUGHT
But, you may ask, how do you get the decoder if it’s not in Id? Good question. **The answer: you need to register it in ModInitializer on both ends (sender and receiver). **In fact, Fabric API will happily crash if you don’t before calling registerGlobalReceiver.
from blog
so basicly, I fucked up in registring things