package xyz.tbvns.rogue_block.client;

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientEntityEvents;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.fabricmc.fabric.api.entity.event.v1.ServerPlayerEvents;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerWorldEvents;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.platform.fabric.FabricAudiences;
import net.kyori.adventure.platform.fabric.FabricClientAudiences;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.world.CreateWorldScreen;
import net.minecraft.world.gen.chunk.FlatChunkGenerator;
import net.minecraft.world.gen.chunk.FlatChunkGeneratorConfig;
import xyz.tbvns.rogue_block.Packets.PacketManager;
import xyz.tbvns.rogue_block.Packets.registeredPackets.BytesPacket;
import xyz.tbvns.rogue_block.client.Events.ClientTickEvent;

import java.util.Arrays;

public class Rogue_blockClient implements ClientModInitializer {

    public static final FabricClientAudiences audiences =  FabricClientAudiences.builder().build();

    @Override
    public void onInitializeClient() {
        PacketManager.setup();

        ClientTickEvents.START_WORLD_TICK.register(new ClientTickEvent());

        ClientPlayNetworking.registerGlobalReceiver(BytesPacket.ID, (payload, context) -> {
            context.client().execute(() -> {
                BytesPacket packet = (BytesPacket) payload;
                System.out.println(Arrays.toString(packet.bytes()));
            });
        });
    }
}
