package com.acethewildfire.acesbs.block.custom;

import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.tooltip.TooltipType;
import net.minecraft.text.Text;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

import java.util.List;
import java.util.Random;

public class StableEndtropyBlock extends Block {
    public StableEndtropyBlock(Settings settings) {
        super(settings);
    }

    Random r = new Random();

//    @Override
//    protected ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hit) {
//        world.playSound(player, pos, SoundEvents.BLOCK_AMETHYST_BLOCK_CHIME, SoundCategory.BLOCKS, 1f, 1f);
//        return ActionResult.SUCCESS;
//    }

    @Override
    public void onSteppedOn(World world, BlockPos pos, BlockState state, Entity entity) {

        if (entity instanceof LivingEntity){
            ((LivingEntity) entity).addStatusEffect(new StatusEffectInstance(
                    StatusEffects.LEVITATION,
                    20 * 5,
                    2
            ));
        }

//        if (entity instanceof PlayerEntity){
//            world.playSound(entity, pos, SoundEvents.ENTITY_ENDERMAN_HURT, SoundCategory.BLOCKS, 1f, 0.4f);
//        }


        super.onSteppedOn(world, pos, state, entity);
    }

    @Override
    public void onLandedUpon(World world, BlockState state, BlockPos pos, Entity entity, double fallDistance) {
        // Never take fall damage
        if (entity.bypassesLandingEffects()) {
            super.onLandedUpon(world, state, pos, entity, 0);
        } else {
            entity.handleFallDamage(fallDistance, 0.0F, world.getDamageSources().fall());
        }
    }
}
