package net.minecraft.world.level.block;

import net.minecraft.world.level.block.state.StateHolder;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.level.LevelReader;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.world.level.BlockGetter;
import java.util.Random;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.BlockBehaviour;

public class CoralWallFanBlock extends BaseCoralWallFanBlock {
    private final Block deadBlock;
    
    protected CoralWallFanBlock(final Block bvr, final Properties c) {
        super(c);
        this.deadBlock = bvr;
    }
    
    @Override
    public void onPlace(final BlockState cfj1, final Level bqb, final BlockPos fu, final BlockState cfj4, final boolean boolean5) {
        this.tryScheduleDieTick(cfj1, bqb, fu);
    }
    
    @Override
    public void tick(final BlockState cfj, final ServerLevel zd, final BlockPos fu, final Random random) {
        if (!BaseCoralPlantTypeBlock.scanForWater(cfj, zd, fu)) {
            zd.setBlock(fu, (((StateHolder<O, BlockState>)this.deadBlock.defaultBlockState()).setValue((Property<Comparable>)CoralWallFanBlock.WATERLOGGED, false)).<Comparable, Comparable>setValue((Property<Comparable>)CoralWallFanBlock.FACING, (Comparable)cfj.<V>getValue((Property<V>)CoralWallFanBlock.FACING)), 2);
        }
    }
    
    @Override
    public BlockState updateShape(final BlockState cfj1, final Direction fz, final BlockState cfj3, final LevelAccessor bqc, final BlockPos fu5, final BlockPos fu6) {
        if (fz.getOpposite() == cfj1.<Direction>getValue((Property<Direction>)CoralWallFanBlock.FACING) && !cfj1.canSurvive(bqc, fu5)) {
            return Blocks.AIR.defaultBlockState();
        }
        if (cfj1.<Boolean>getValue((Property<Boolean>)CoralWallFanBlock.WATERLOGGED)) {
            bqc.getLiquidTicks().scheduleTick(fu5, Fluids.WATER, Fluids.WATER.getTickDelay(bqc));
        }
        this.tryScheduleDieTick(cfj1, bqc, fu5);
        return super.updateShape(cfj1, fz, cfj3, bqc, fu5, fu6);
    }
}
