package net.minecraft.world.level.block;

import net.minecraft.server.level.ServerLevel;
import java.util.Random;
import net.minecraft.world.level.Level;
import java.util.Iterator;
import net.minecraft.tags.Tag;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.state.BlockBehaviour;

public class NetherrackBlock extends Block implements BonemealableBlock {
    public NetherrackBlock(final Properties c) {
        super(c);
    }
    
    @Override
    public boolean isValidBonemealTarget(final BlockGetter bpg, final BlockPos fu, final BlockState cfj, final boolean boolean4) {
        if (!bpg.getBlockState(fu.above()).propagatesSkylightDown(bpg, fu)) {
            return false;
        }
        for (final BlockPos fu2 : BlockPos.betweenClosed(fu.offset(-1, -1, -1), fu.offset(1, 1, 1))) {
            if (bpg.getBlockState(fu2).is(BlockTags.NYLIUM)) {
                return true;
            }
        }
        return false;
    }
    
    @Override
    public boolean isBonemealSuccess(final Level bqb, final Random random, final BlockPos fu, final BlockState cfj) {
        return true;
    }
    
    @Override
    public void performBonemeal(final ServerLevel zd, final Random random, final BlockPos fu, final BlockState cfj) {
        boolean boolean6 = false;
        boolean boolean7 = false;
        for (final BlockPos fu2 : BlockPos.betweenClosed(fu.offset(-1, -1, -1), fu.offset(1, 1, 1))) {
            final BlockState cfj2 = zd.getBlockState(fu2);
            if (cfj2.is(Blocks.WARPED_NYLIUM)) {
                boolean7 = true;
            }
            if (cfj2.is(Blocks.CRIMSON_NYLIUM)) {
                boolean6 = true;
            }
            if (boolean7 && boolean6) {
                break;
            }
        }
        if (boolean7 && boolean6) {
            zd.setBlock(fu, random.nextBoolean() ? Blocks.WARPED_NYLIUM.defaultBlockState() : Blocks.CRIMSON_NYLIUM.defaultBlockState(), 3);
        }
        else if (boolean7) {
            zd.setBlock(fu, Blocks.WARPED_NYLIUM.defaultBlockState(), 3);
        }
        else if (boolean6) {
            zd.setBlock(fu, Blocks.CRIMSON_NYLIUM.defaultBlockState(), 3);
        }
    }
}
