package xyz.tbvns.rogue_block.client.Events;

import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.minecraft.block.Blocks;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import xyz.tbvns.rogue_block.client.Gui.UpgradeScreen;

public class ClientTickEvent implements ClientTickEvents.StartWorldTick {
    @Override
    public void onStartTick(ClientWorld clientWorld) {
        if (clientWorld.getRegistryKey().getValue().equals(Identifier.of("rogue_block:lobby"))) {
            BlockPos pos = MinecraftClient.getInstance().player.getBlockPos();
            if (clientWorld.getBlockState(pos).getBlock().equals(Blocks.END_GATEWAY)) {
                MinecraftClient.getInstance().setScreen(new UpgradeScreen());
                MinecraftClient.getInstance().cameraEntity.setVelocity(new Vec3d(1.3, 0.7, 0));
            }
        }
    }
}
