package com.dairymoose.modernlife.blocks;

import net.minecraft.core.BlockPos;
import net.minecraft.util.StringRepresentable;
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.EnumProperty;
import net.minecraft.world.level.block.state.properties.Property;

/* loaded from: outputsrg.jar:com/dairymoose/modernlife/blocks/GlassCoffeeTableBlock.class */
public class GlassCoffeeTableBlock extends CoffeeTableBlock {
    public static final EnumProperty<GlassTableType> TYPE = EnumProperty.create("type", GlassTableType.class);

    /* loaded from: outputsrg.jar:com/dairymoose/modernlife/blocks/GlassCoffeeTableBlock$GlassTableType.class */
    public enum GlassTableType implements StringRepresentable {
        single,
        mid,
        three_way_n,
        three_way_e,
        three_way_s,
        three_way_w,
        one_border_n,
        one_border_e,
        one_border_s,
        one_border_w,
        x_axis,
        z_axis,
        s_end,
        w_end,
        n_end,
        e_end,
        ne_corner,
        se_corner,
        nw_corner,
        sw_corner,
        ne_four_corner,
        se_four_corner,
        nw_four_corner,
        sw_four_corner;

        public String getSerializedName() {
            return name().toLowerCase();
        }
    }

    @Override // com.dairymoose.modernlife.blocks.SmallTableBlock
    protected BlockState getNewState(LevelAccessor world, BlockPos pos) {
        BlockState nState = world.getBlockState(pos.north());
        BlockState eState = world.getBlockState(pos.east());
        BlockState sState = world.getBlockState(pos.south());
        BlockState wState = world.getBlockState(pos.west());
        int adjacentTableCount = 0;
        boolean nTable = nState.is(this);
        boolean eTable = eState.is(this);
        boolean sTable = sState.is(this);
        boolean wTable = wState.is(this);
        BlockState neState = world.getBlockState(pos.north().east());
        BlockState nwState = world.getBlockState(pos.north().west());
        BlockState seState = world.getBlockState(pos.south().east());
        BlockState swState = world.getBlockState(pos.south().west());
        boolean neTable = neState.is(this);
        boolean nwTable = nwState.is(this);
        boolean seTable = seState.is(this);
        boolean swTable = swState.is(this);
        if (nTable) {
            adjacentTableCount = 0 + 1;
        }
        if (eTable) {
            adjacentTableCount++;
        }
        if (sTable) {
            adjacentTableCount++;
        }
        if (wTable) {
            adjacentTableCount++;
        }
        if (adjacentTableCount >= 2) {
            if (nTable && eTable && !sTable && !wTable) {
                if (neTable) {
                    return (BlockState) defaultBlockState().setValue(TYPE, GlassTableType.sw_four_corner);
                }
                return (BlockState) defaultBlockState().setValue(TYPE, GlassTableType.sw_corner);
            }
            if (nTable && wTable && !sTable && !eTable) {
                if (nwTable) {
                    return (BlockState) defaultBlockState().setValue(TYPE, GlassTableType.se_four_corner);
                }
                return (BlockState) defaultBlockState().setValue(TYPE, GlassTableType.se_corner);
            }
            if (sTable && eTable && !nTable && !wTable) {
                if (seTable) {
                    return (BlockState) defaultBlockState().setValue(TYPE, GlassTableType.nw_four_corner);
                }
                return (BlockState) defaultBlockState().setValue(TYPE, GlassTableType.nw_corner);
            }
            if (sTable && wTable && !nTable && !eTable) {
                if (swTable) {
                    return (BlockState) defaultBlockState().setValue(TYPE, GlassTableType.ne_four_corner);
                }
                return (BlockState) defaultBlockState().setValue(TYPE, GlassTableType.ne_corner);
            }
            if (adjacentTableCount == 2 && wTable && eTable) {
                return (BlockState) defaultBlockState().setValue(TYPE, GlassTableType.x_axis);
            }
            if (adjacentTableCount == 2 && nTable && sTable) {
                return (BlockState) defaultBlockState().setValue(TYPE, GlassTableType.z_axis);
            }
            if (adjacentTableCount == 3) {
                if (wTable && nTable && eTable) {
                    if (nwTable || neTable) {
                        return (BlockState) defaultBlockState().setValue(TYPE, GlassTableType.one_border_n);
                    }
                    return (BlockState) defaultBlockState().setValue(TYPE, GlassTableType.three_way_n);
                }
                if (nTable && eTable && sTable) {
                    if (seTable || neTable) {
                        return (BlockState) defaultBlockState().setValue(TYPE, GlassTableType.one_border_e);
                    }
                    return (BlockState) defaultBlockState().setValue(TYPE, GlassTableType.three_way_e);
                }
                if (eTable && sTable && wTable) {
                    if (seTable || swTable) {
                        return (BlockState) defaultBlockState().setValue(TYPE, GlassTableType.one_border_s);
                    }
                    return (BlockState) defaultBlockState().setValue(TYPE, GlassTableType.three_way_s);
                }
                if (sTable && wTable && nTable) {
                    if (swTable || nwTable) {
                        return (BlockState) defaultBlockState().setValue(TYPE, GlassTableType.one_border_w);
                    }
                    return (BlockState) defaultBlockState().setValue(TYPE, GlassTableType.three_way_w);
                }
            }
            return (BlockState) defaultBlockState().setValue(TYPE, GlassTableType.mid);
        }
        if (adjacentTableCount == 1) {
            if (nTable) {
                return (BlockState) defaultBlockState().setValue(TYPE, GlassTableType.s_end);
            }
            if (eTable) {
                return (BlockState) defaultBlockState().setValue(TYPE, GlassTableType.w_end);
            }
            if (sTable) {
                return (BlockState) defaultBlockState().setValue(TYPE, GlassTableType.n_end);
            }
            if (wTable) {
                return (BlockState) defaultBlockState().setValue(TYPE, GlassTableType.e_end);
            }
        }
        return defaultBlockState();
    }

    @Override // com.dairymoose.modernlife.blocks.SmallTableBlock
    protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
        builder.add(new Property[]{TYPE});
    }

    public GlassCoffeeTableBlock(Properties p_i48377_1_) {
        super(p_i48377_1_, true);
        registerDefaultState((BlockState) defaultBlockState().setValue(TYPE, GlassTableType.single));
    }
}
