Skip to content

Commit

Permalink
Merge pull request #676 from RakambdaOrg/fix/gh-675
Browse files Browse the repository at this point in the history
Fabric: fix packet encoding when joining server
  • Loading branch information
Rakambda authored May 2, 2024
2 parents 4e0e516 + dd20007 commit 62f5719
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import fr.rakambda.fallingtree.common.network.ClientPacketHandler;
import fr.rakambda.fallingtree.fabric.network.FallingTreeConfigPacket;
import net.fabricmc.fabric.api.client.networking.v1.ClientConfigurationNetworking;
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;

public class FabricClientPacketHandler implements ClientPacketHandler{
private final FallingTreeCommon<?> mod;
Expand All @@ -15,9 +14,7 @@ public FabricClientPacketHandler(FallingTreeCommon<?> mod){

@Override
public void registerClient(){
PayloadTypeRegistry.configurationS2C().register(FallingTreeConfigPacket.TYPE, FallingTreeConfigPacket.CODEC);
ClientConfigurationNetworking.registerGlobalReceiver(FallingTreeConfigPacket.TYPE, (packet, sender) -> {
mod.getPacketUtils().onClientConfigurationPacket(packet.getPacket());
});
ClientConfigurationNetworking.registerGlobalReceiver(FallingTreeConfigPacket.TYPE,
(packet, sender) -> mod.getPacketUtils().onClientConfigurationPacket(packet.getPacket()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import fr.rakambda.fallingtree.common.network.ConfigurationPacket;
import fr.rakambda.fallingtree.common.network.ServerPacketHandler;
import lombok.RequiredArgsConstructor;
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
import net.fabricmc.fabric.api.networking.v1.ServerConfigurationConnectionEvents;
import net.fabricmc.fabric.api.networking.v1.ServerConfigurationNetworking;

Expand All @@ -13,6 +14,7 @@ public class FabricServerPacketHandler implements ServerPacketHandler{

@Override
public void registerServer(){
PayloadTypeRegistry.configurationS2C().register(FallingTreeConfigPacket.TYPE, FallingTreeConfigPacket.CODEC);
ServerConfigurationConnectionEvents.CONFIGURE.register(((handler, server) -> {
var packet = ConfigurationPacket.get(mod.getConfiguration());
ServerConfigurationNetworking.send(handler, new FallingTreeConfigPacket(packet));
Expand Down

0 comments on commit 62f5719

Please sign in to comment.