package com.r3944realms.leashedplayer.network;

import com.r3944realms.leashedplayer.LeashedPlayer;
import com.r3944realms.leashedplayer.network.client.SyncLeashRopeLength;
import com.r3944realms.leashedplayer.network.client.UpdatePlayerMovement;
import com.r3944realms.leashedplayer.network.server.DecreaseLeashRopeLength;
import com.r3944realms.leashedplayer.network.server.IncreaseLeashRopeLength;
import net.minecraft.network.syncher.SynchedEntityData;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent;
import net.neoforged.neoforge.network.registration.PayloadRegistrar;

@EventBusSubscriber(modid = LeashedPlayer.MOD_ID, bus = EventBusSubscriber.Bus.MOD)
public class LeashedPlayerNetwork {

    @SubscribeEvent
    public static void registerPackets(RegisterPayloadHandlersEvent event) {
        PayloadRegistrar registrar = event.registrar(LeashedPlayer.MOD_ID);
        registrar.playToClient(
                UpdatePlayerMovement.TYPE,
                UpdatePlayerMovement.STREAM_CODEC,
                UpdatePlayerMovement::handle
        );
        registrar.playToClient(
                SyncLeashRopeLength.TYPE,
                SyncLeashRopeLength.STREAM_CODEC,
                SyncLeashRopeLength::handle
        );
        registrar.playToServer(
                IncreaseLeashRopeLength.TYPE,
                IncreaseLeashRopeLength.STREAM_CODEC,
                IncreaseLeashRopeLength::handle
        );
        registrar.playToServer(
                DecreaseLeashRopeLength.TYPE,
                DecreaseLeashRopeLength.STREAM_CODEC,
                DecreaseLeashRopeLength::handle
        );
    }

}
