package com.dairymoose.modernlife.blocks;

import com.dairymoose.modernlife.util.ModernLifeUtil;
import java.util.stream.Stream;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.EnumProperty;
import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;

/* loaded from: outputsrg.jar:com/dairymoose/modernlife/blocks/MetalDuctBlock.class */
public class MetalDuctBlock extends Block {
    protected static final VoxelShape SHAPE_Y = (VoxelShape) Stream.of((Object[]) new VoxelShape[]{Block.box(4.5d, 15.25d, 4.0d, 11.5d, 16.25d, 12.0d), Block.box(3.5d, 0.0d, 3.0d, 12.5d, 4.5d, 13.0d), Block.box(3.5d, 5.5d, 3.0d, 12.5d, 10.0d, 13.0d), Block.box(3.5d, 11.0d, 3.0d, 12.5d, 15.5d, 13.0d), Block.box(4.5d, 4.5d, 4.0d, 11.5d, 5.5d, 12.0d), Block.box(4.5d, 10.0d, 4.0d, 11.5d, 11.0d, 12.0d)}).reduce((v1, v2) -> {
        return Shapes.join(v1, v2, BooleanOp.OR);
    }).get();
    protected static final VoxelShape SHAPE_Z = ModernLifeUtil.RotateVoxelShapeXAxis(SHAPE_Y);
    protected static final VoxelShape SHAPE_X = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_Z);
    public static final EnumProperty<Direction.Axis> AXIS = BlockStateProperties.AXIS;

    public MetalDuctBlock(Properties p_i48377_1_) {
        super(p_i48377_1_);
        registerDefaultState((BlockState) this.stateDefinition.any().setValue(AXIS, Direction.Axis.Y));
    }

    public VoxelShape getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel) {
        if (bs.getValue(AXIS) == Direction.Axis.X) {
            return SHAPE_X;
        }
        if (bs.getValue(AXIS) == Direction.Axis.Z) {
            return SHAPE_Z;
        }
        return SHAPE_Y;
    }

    protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
        builder.add(new Property[]{AXIS});
    }

    public BlockState getStateForPlacement(BlockPlaceContext context) {
        if (context.getClickedFace() == Direction.NORTH || context.getClickedFace() == Direction.SOUTH) {
            return (BlockState) defaultBlockState().setValue(AXIS, Direction.Axis.Z);
        }
        if (context.getClickedFace() == Direction.EAST || context.getClickedFace() == Direction.WEST) {
            return (BlockState) defaultBlockState().setValue(AXIS, Direction.Axis.X);
        }
        if (context.getClickedFace() == Direction.UP || context.getClickedFace() == Direction.DOWN) {
            return (BlockState) defaultBlockState().setValue(AXIS, Direction.Axis.Y);
        }
        return defaultBlockState();
    }
}
