package net.minecraft.world.level.block;

import net.minecraft.world.level.material.PushReaction;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.LightLayer;
import java.util.Random;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.item.ItemStack;
import javax.annotation.Nullable;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockBehaviour;

public class IceBlock extends HalfTransparentBlock {
    public IceBlock(final Properties c) {
        super(c);
    }
    
    @Override
    public void playerDestroy(final Level bqb, final Player bec, final BlockPos fu, final BlockState cfj, @Nullable final BlockEntity cdl, final ItemStack bki) {
        super.playerDestroy(bqb, bec, fu, cfj, cdl, bki);
        if (EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, bki) == 0) {
            if (bqb.dimensionType().ultraWarm()) {
                bqb.removeBlock(fu, false);
                return;
            }
            final Material cxd8 = bqb.getBlockState(fu.below()).getMaterial();
            if (cxd8.blocksMotion() || cxd8.isLiquid()) {
                bqb.setBlockAndUpdate(fu, Blocks.WATER.defaultBlockState());
            }
        }
    }
    
    @Override
    public void randomTick(final BlockState cfj, final ServerLevel zd, final BlockPos fu, final Random random) {
        if (zd.getBrightness(LightLayer.BLOCK, fu) > 11 - cfj.getLightBlock(zd, fu)) {
            this.melt(cfj, zd, fu);
        }
    }
    
    protected void melt(final BlockState cfj, final Level bqb, final BlockPos fu) {
        if (bqb.dimensionType().ultraWarm()) {
            bqb.removeBlock(fu, false);
            return;
        }
        bqb.setBlockAndUpdate(fu, Blocks.WATER.defaultBlockState());
        bqb.neighborChanged(fu, Blocks.WATER, fu);
    }
    
    @Override
    public PushReaction getPistonPushReaction(final BlockState cfj) {
        return PushReaction.NORMAL;
    }
}
