package net.minecraft.world.item;

import java.util.Map;
import javax.annotation.Nullable;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Block;

public class StandingAndWallBlockItem extends BlockItem {
    protected final Block wallBlock;
    
    public StandingAndWallBlockItem(final Block bvr1, final Block bvr2, final Properties a) {
        super(bvr1, a);
        this.wallBlock = bvr2;
    }
    
    @Nullable
    @Override
    protected BlockState getPlacementState(final BlockPlaceContext bin) {
        final BlockState cfj3 = this.wallBlock.getStateForPlacement(bin);
        BlockState cfj4 = null;
        final LevelReader bqd5 = bin.getLevel();
        final BlockPos fu6 = bin.getClickedPos();
        for (final Direction fz10 : bin.getNearestLookingDirections()) {
            if (fz10 != Direction.UP) {
                final BlockState cfj5 = (fz10 == Direction.DOWN) ? this.getBlock().getStateForPlacement(bin) : cfj3;
                if (cfj5 != null && cfj5.canSurvive(bqd5, fu6)) {
                    cfj4 = cfj5;
                    break;
                }
            }
        }
        return (cfj4 != null && bqd5.isUnobstructed(cfj4, fu6, CollisionContext.empty())) ? cfj4 : null;
    }
    
    @Override
    public void registerBlocks(final Map<Block, Item> map, final Item bke) {
        super.registerBlocks(map, bke);
        map.put(this.wallBlock, bke);
    }
}
