package net.minecraft.world.level.block;

import net.minecraft.world.level.block.state.AbstractStateHolder;
import com.google.common.collect.Maps;
import com.google.common.collect.ImmutableMap;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.item.BlockPlaceContext;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.core.Direction;
import java.util.Map;
import net.minecraft.world.level.block.state.properties.DirectionProperty;

public class WallSkullBlock extends AbstractSkullBlock {
    public static final DirectionProperty FACING;
    private static final Map<Direction, VoxelShape> AABBS;
    
    protected WallSkullBlock(final SkullBlock.Type a, final Properties c) {
        super(a, c);
        this.registerDefaultState(((AbstractStateHolder<O, BlockState>)this.stateDefinition.any()).<Comparable, Direction>setValue((Property<Comparable>)WallSkullBlock.FACING, Direction.NORTH));
    }
    
    @Override
    public String getDescriptionId() {
        return this.asItem().getDescriptionId();
    }
    
    @Override
    public VoxelShape getShape(final BlockState byj, final BlockGetter bjg, final BlockPos fk, final CollisionContext cvq) {
        return WallSkullBlock.AABBS.get(byj.getValue((Property<Object>)WallSkullBlock.FACING));
    }
    
    @Override
    public BlockState getStateForPlacement(final BlockPlaceContext bcq) {
        BlockState byj3 = this.defaultBlockState();
        final BlockGetter bjg4 = bcq.getLevel();
        final BlockPos fk5 = bcq.getClickedPos();
        final Direction[] nearestLookingDirections;
        final Direction[] arr6 = nearestLookingDirections = bcq.getNearestLookingDirections();
        for (final Direction fp10 : nearestLookingDirections) {
            if (fp10.getAxis().isHorizontal()) {
                final Direction fp11 = fp10.getOpposite();
                byj3 = ((AbstractStateHolder<O, BlockState>)byj3).<Comparable, Direction>setValue((Property<Comparable>)WallSkullBlock.FACING, fp11);
                if (!bjg4.getBlockState(fk5.relative(fp10)).canBeReplaced(bcq)) {
                    return byj3;
                }
            }
        }
        return null;
    }
    
    @Override
    public BlockState rotate(final BlockState byj, final Rotation btu) {
        return ((AbstractStateHolder<O, BlockState>)byj).<Comparable, Direction>setValue((Property<Comparable>)WallSkullBlock.FACING, btu.rotate(byj.<Direction>getValue((Property<Direction>)WallSkullBlock.FACING)));
    }
    
    @Override
    public BlockState mirror(final BlockState byj, final Mirror bsu) {
        return byj.rotate(bsu.getRotation(byj.<Direction>getValue((Property<Direction>)WallSkullBlock.FACING)));
    }
    
    @Override
    protected void createBlockStateDefinition(final StateDefinition.Builder<Block, BlockState> a) {
        a.add(WallSkullBlock.FACING);
    }
    
    static {
        FACING = HorizontalDirectionalBlock.FACING;
        AABBS = Maps.<Direction, Object>newEnumMap(ImmutableMap.<Direction, VoxelShape>of(Direction.NORTH, Block.box(4.0, 4.0, 8.0, 12.0, 12.0, 16.0), Direction.SOUTH, Block.box(4.0, 4.0, 0.0, 12.0, 12.0, 8.0), Direction.EAST, Block.box(0.0, 4.0, 4.0, 8.0, 12.0, 12.0), Direction.WEST, Block.box(8.0, 4.0, 4.0, 16.0, 12.0, 12.0)));
    }
}
