package com.dairymoose.modernlife.blocks;

import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.FaceAttachedHorizontalDirectionalBlock;
import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.DirectionProperty;

/* loaded from: outputsrg.jar:com/dairymoose/modernlife/blocks/AbstractWallBlock.class */
public abstract class AbstractWallBlock extends Block {
    public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING;

    public BlockState rotate(BlockState state, Rotation rotation) {
        return (BlockState) state.setValue(FACING, rotation.rotate(state.getValue(FACING)));
    }

    public BlockState mirror(BlockState state, Mirror mirror) {
        return state.rotate(mirror.getRotation(state.getValue(FACING)));
    }

    public AbstractWallBlock(Properties p_i241196_1_) {
        super(p_i241196_1_);
    }

    public boolean canSurvive(BlockState p_196260_1_, LevelReader p_196260_2_, BlockPos p_196260_3_) {
        return FaceAttachedHorizontalDirectionalBlock.canAttach(p_196260_2_, p_196260_3_, p_196260_1_.getValue(FACING).getOpposite());
    }

    public BlockState getStateForPlacement(BlockPlaceContext context) {
        Direction[] var2 = context.getNearestLookingDirections();
        for (Direction lvt_5_1_ : var2) {
            if (lvt_5_1_.getAxis() != Direction.Axis.Y) {
                BlockState lvt_6_2_ = (BlockState) defaultBlockState().setValue(FACING, lvt_5_1_.getOpposite());
                if (lvt_6_2_.canSurvive(context.getLevel(), context.getClickedPos())) {
                    return lvt_6_2_;
                }
            }
        }
        return defaultBlockState();
    }
}
