package com.dairymoose.modernlife.blocks;

import java.util.stream.Stream;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.LevelAccessor;
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.BooleanProperty;
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/DeckBlock.class */
public class DeckBlock extends Block {
    protected static final VoxelShape SHAPE_SOUTH = (VoxelShape) Stream.of((Object[]) new VoxelShape[]{Block.box(2.5d, 13.5d, 0.0d, 5.5d, 15.5d, 16.0d), Block.box(10.5d, 13.5d, 0.0d, 13.5d, 15.5d, 16.0d), Block.box(0.0d, 14.0d, 0.5d, 16.0d, 16.0d, 3.5d), Block.box(0.0d, 14.0d, 4.5d, 16.0d, 16.0d, 7.5d), Block.box(0.0d, 14.0d, 8.5d, 16.0d, 16.0d, 11.5d), Block.box(0.0d, 14.0d, 12.5d, 16.0d, 16.0d, 15.5d)}).reduce((v1, v2) -> {
        return Shapes.join(v1, v2, BooleanOp.OR);
    }).get();
    protected static final VoxelShape WITH_SUPPORT = (VoxelShape) Stream.of((Object[]) new VoxelShape[]{SHAPE_SOUTH, Block.box(6.0d, 0.0d, 6.0d, 10.0d, 14.0d, 10.0d)}).reduce((v1, v2) -> {
        return Shapes.join(v1, v2, BooleanOp.OR);
    }).get();
    public static final BooleanProperty SUPPORT = BooleanProperty.create("support");

    public DeckBlock(Properties p_i48377_1_) {
        super(p_i48377_1_);
        registerDefaultState((BlockState) this.stateDefinition.any().setValue(SUPPORT, Boolean.FALSE));
    }

    public int getFlammability(BlockState state, BlockGetter world, BlockPos pos, Direction face) {
        if (this.material.isFlammable()) {
            return 20;
        }
        return 0;
    }

    public int getFireSpreadSpeed(BlockState state, BlockGetter world, BlockPos pos, Direction face) {
        if (this.material.isFlammable()) {
            return 5;
        }
        return 0;
    }

    public BlockState updateShape(BlockState p_196271_1_, Direction p_196271_2_, BlockState p_196271_3_, LevelAccessor p_196271_4_, BlockPos p_196271_5_, BlockPos p_196271_6_) {
        if (p_196271_4_.getBlockState(p_196271_5_.below()).m_204336_(BlockTags.WOODEN_FENCES)) {
            return (BlockState) defaultBlockState().setValue(SUPPORT, true);
        }
        return defaultBlockState();
    }

    public BlockState getStateForPlacement(BlockPlaceContext context) {
        if (context.getLevel().getBlockState(context.getClickedPos().below()).m_204336_(BlockTags.WOODEN_FENCES)) {
            return (BlockState) defaultBlockState().setValue(SUPPORT, true);
        }
        return defaultBlockState();
    }

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

    public VoxelShape getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel) {
        if (((Boolean) bs.getValue(SUPPORT)).booleanValue()) {
            return WITH_SUPPORT;
        }
        return SHAPE_SOUTH;
    }
}
