package net.minecraft.world.level.block;

import net.minecraft.world.level.block.state.StateHolder;
import com.google.common.collect.Maps;
import com.google.common.collect.ImmutableMap;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.LevelAccessor;
import javax.annotation.Nullable;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.item.BlockPlaceContext;
import net.minecraft.world.level.LevelReader;
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.level.block.state.properties.WoodType;
import net.minecraft.world.level.block.state.BlockBehaviour;
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 WallSignBlock extends SignBlock {
    public static final DirectionProperty FACING;
    private static final Map<Direction, VoxelShape> AABBS;
    
    public WallSignBlock(final Properties c, final WoodType cgs) {
        super(c, cgs);
        this.registerDefaultState((((StateHolder<O, BlockState>)this.stateDefinition.any()).setValue((Property<Comparable>)WallSignBlock.FACING, Direction.NORTH)).<Comparable, Boolean>setValue((Property<Comparable>)WallSignBlock.WATERLOGGED, false));
    }
    
    @Override
    public String getDescriptionId() {
        return this.asItem().getDescriptionId();
    }
    
    @Override
    public VoxelShape getShape(final BlockState cfj, final BlockGetter bpg, final BlockPos fu, final CollisionContext der) {
        return WallSignBlock.AABBS.get(cfj.getValue((Property<Object>)WallSignBlock.FACING));
    }
    
    @Override
    public boolean canSurvive(final BlockState cfj, final LevelReader bqd, final BlockPos fu) {
        return bqd.getBlockState(fu.relative(cfj.<Direction>getValue((Property<Direction>)WallSignBlock.FACING).getOpposite())).getMaterial().isSolid();
    }
    
    @Nullable
    @Override
    public BlockState getStateForPlacement(final BlockPlaceContext bin) {
        BlockState cfj3 = this.defaultBlockState();
        final FluidState cxa4 = bin.getLevel().getFluidState(bin.getClickedPos());
        final LevelReader bqd5 = bin.getLevel();
        final BlockPos fu6 = bin.getClickedPos();
        final Direction[] nearestLookingDirections;
        final Direction[] arr7 = nearestLookingDirections = bin.getNearestLookingDirections();
        for (final Direction fz11 : nearestLookingDirections) {
            if (fz11.getAxis().isHorizontal()) {
                final Direction fz12 = fz11.getOpposite();
                cfj3 = ((StateHolder<O, BlockState>)cfj3).<Comparable, Direction>setValue((Property<Comparable>)WallSignBlock.FACING, fz12);
                if (cfj3.canSurvive(bqd5, fu6)) {
                    return ((StateHolder<O, BlockState>)cfj3).<Comparable, Boolean>setValue((Property<Comparable>)WallSignBlock.WATERLOGGED, cxa4.getType() == Fluids.WATER);
                }
            }
        }
        return null;
    }
    
    @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>)WallSignBlock.FACING) && !cfj1.canSurvive(bqc, fu5)) {
            return Blocks.AIR.defaultBlockState();
        }
        return super.updateShape(cfj1, fz, cfj3, bqc, fu5, fu6);
    }
    
    @Override
    public BlockState rotate(final BlockState cfj, final Rotation cap) {
        return ((StateHolder<O, BlockState>)cfj).<Comparable, Direction>setValue((Property<Comparable>)WallSignBlock.FACING, cap.rotate(cfj.<Direction>getValue((Property<Direction>)WallSignBlock.FACING)));
    }
    
    @Override
    public BlockState mirror(final BlockState cfj, final Mirror bzj) {
        return cfj.rotate(bzj.getRotation(cfj.<Direction>getValue((Property<Direction>)WallSignBlock.FACING)));
    }
    
    @Override
    protected void createBlockStateDefinition(final StateDefinition.Builder<Block, BlockState> a) {
        a.add(WallSignBlock.FACING, WallSignBlock.WATERLOGGED);
    }
    
    static {
        FACING = HorizontalDirectionalBlock.FACING;
        AABBS = Maps.<Direction, Object>newEnumMap(ImmutableMap.<Direction, VoxelShape>of(Direction.NORTH, Block.box(0.0, 4.5, 14.0, 16.0, 12.5, 16.0), Direction.SOUTH, Block.box(0.0, 4.5, 0.0, 16.0, 12.5, 2.0), Direction.EAST, Block.box(0.0, 4.5, 0.0, 2.0, 12.5, 16.0), Direction.WEST, Block.box(14.0, 4.5, 0.0, 16.0, 12.5, 16.0)));
    }
}
