package xyz.tbvns.rogue_block.Events;

import net.fabricmc.fabric.api.event.player.UseBlockCallback;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import xyz.tbvns.rogue_block.Managers.WorldManager;

public class PlayerStartButtonEvent implements UseBlockCallback {
    @Override
    public ActionResult interact(PlayerEntity playerEntity, World world, Hand hand, BlockHitResult blockHitResult) {
        if (blockHitResult.getBlockPos().equals(new BlockPos(0, 13, 0))) {
            if (!world.isClient) {
                WorldManager.createNewRunWorld(world.getServer());
                WorldManager.teleportToRunWorld(world.getServer());
                WorldManager.clearAchievements(world.getServer());
            }
        }
        return ActionResult.PASS;
    }
}
