package xyz.tbvns.rogue_block.Events;

import net.fabricmc.fabric.api.entity.event.v1.ServerLivingEntityEvents;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.server.network.ServerPlayerEntity;
import xyz.tbvns.rogue_block.Managers.WorldManager;

public class PlayerDeathEvent implements ServerLivingEntityEvents.AfterDamage {
    @Override
    public void afterDamage(LivingEntity livingEntity, DamageSource damageSource, float v, float v1, boolean b) {
        if (livingEntity instanceof ServerPlayerEntity) {
            if (livingEntity.getHealth() <= 0) {
                livingEntity.setHealth(1);
            }

            WorldManager.teleportToLobbyWorld((ServerPlayerEntity) livingEntity);
        }
    }
}
