package net.minecraft.world.level.block;

import net.minecraft.world.level.block.state.StateHolder;
import net.minecraft.world.level.block.state.StateDefinition;
import java.util.Random;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import javax.annotation.Nullable;
import net.minecraft.world.item.BlockPlaceContext;
import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.properties.BooleanProperty;

public class RedstoneLampBlock extends Block {
    public static final BooleanProperty LIT;
    
    public RedstoneLampBlock(final Properties c) {
        super(c);
        this.registerDefaultState(((StateHolder<O, BlockState>)this.defaultBlockState()).<Comparable, Boolean>setValue((Property<Comparable>)RedstoneLampBlock.LIT, false));
    }
    
    @Nullable
    @Override
    public BlockState getStateForPlacement(final BlockPlaceContext bin) {
        return ((StateHolder<O, BlockState>)this.defaultBlockState()).<Comparable, Boolean>setValue((Property<Comparable>)RedstoneLampBlock.LIT, bin.getLevel().hasNeighborSignal(bin.getClickedPos()));
    }
    
    @Override
    public void neighborChanged(final BlockState cfj, final Level bqb, final BlockPos fu3, final Block bvr, final BlockPos fu5, final boolean boolean6) {
        if (bqb.isClientSide) {
            return;
        }
        final boolean boolean7 = cfj.<Boolean>getValue((Property<Boolean>)RedstoneLampBlock.LIT);
        if (boolean7 != bqb.hasNeighborSignal(fu3)) {
            if (boolean7) {
                bqb.getBlockTicks().scheduleTick(fu3, this, 4);
            }
            else {
                bqb.setBlock(fu3, ((StateHolder<O, BlockState>)cfj).<Comparable>cycle((Property<Comparable>)RedstoneLampBlock.LIT), 2);
            }
        }
    }
    
    @Override
    public void tick(final BlockState cfj, final ServerLevel zd, final BlockPos fu, final Random random) {
        if (cfj.<Boolean>getValue((Property<Boolean>)RedstoneLampBlock.LIT) && !zd.hasNeighborSignal(fu)) {
            zd.setBlock(fu, ((StateHolder<O, BlockState>)cfj).<Comparable>cycle((Property<Comparable>)RedstoneLampBlock.LIT), 2);
        }
    }
    
    @Override
    protected void createBlockStateDefinition(final StateDefinition.Builder<Block, BlockState> a) {
        a.add(RedstoneLampBlock.LIT);
    }
    
    static {
        LIT = RedstoneTorchBlock.LIT;
    }
}
