package com.dairymoose.modernlife.blocks; import java.util.stream.Stream; import javax.annotation.Nullable; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.util.StringRepresentable; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; 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.EnumProperty; import net.minecraft.world.level.block.state.properties.Property; import net.minecraft.world.phys.BlockHitResult; 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/CatwalkBlock.class */ public class CatwalkBlock extends Block { protected static final VoxelShape SHAPE_WEST_LONG_WALL = (VoxelShape) Stream.of(Block.box(0.8d, 1.0d, 0.0d, 2.4d, 16.0d, 16.0d)).reduce((v1, v2) -> { return Shapes.join(v1, v2, BooleanOp.OR); }).get(); protected static final VoxelShape SHAPE_EAST_LONG_WALL = (VoxelShape) Stream.of(Block.box(13.6d, 1.0d, 0.0d, 15.2d, 16.0d, 16.0d)).reduce((v1, v2) -> { return Shapes.join(v1, v2, BooleanOp.OR); }).get(); protected static final VoxelShape SHAPE_NORTH_LONG_WALL = (VoxelShape) Stream.of(Block.box(0.0d, 1.0d, 0.8d, 16.0d, 16.0d, 2.4d)).reduce((v1, v2) -> { return Shapes.join(v1, v2, BooleanOp.OR); }).get(); protected static final VoxelShape SHAPE_SOUTH_LONG_WALL = (VoxelShape) Stream.of(Block.box(0.0d, 1.0d, 13.6d, 16.0d, 16.0d, 15.2d)).reduce((v1, v2) -> { return Shapes.join(v1, v2, BooleanOp.OR); }).get(); protected static final VoxelShape SHAPE_WEST_WALL = (VoxelShape) Stream.of(Block.box(0.8d, 1.0d, 0.8d, 2.4d, 16.0d, 15.2d)).reduce((v1, v2) -> { return Shapes.join(v1, v2, BooleanOp.OR); }).get(); protected static final VoxelShape SHAPE_EAST_WALL = (VoxelShape) Stream.of(Block.box(13.6d, 1.0d, 0.8d, 15.2d, 16.0d, 13.6d)).reduce((v1, v2) -> { return Shapes.join(v1, v2, BooleanOp.OR); }).get(); protected static final VoxelShape SHAPE_NORTH_WALL = (VoxelShape) Stream.of(Block.box(2.4d, 1.0d, 0.8d, 13.6d, 16.0d, 2.4d)).reduce((v1, v2) -> { return Shapes.join(v1, v2, BooleanOp.OR); }).get(); protected static final VoxelShape SHAPE_SOUTH_WALL = (VoxelShape) Stream.of(Block.box(2.4d, 1.0d, 13.6d, 15.2d, 16.0d, 15.2d)).reduce((v1, v2) -> { return Shapes.join(v1, v2, BooleanOp.OR); }).get(); protected static final VoxelShape SHAPE_FLOOR_BIG = (VoxelShape) Stream.of(Block.box(0.0d, 0.0d, 0.0d, 16.0d, 1.0d, 16.0d)).reduce((v1, v2) -> { return Shapes.join(v1, v2, BooleanOp.OR); }).get(); protected static final VoxelShape SHAPE_FLOOR = (VoxelShape) Stream.of(Block.box(0.8d, 0.0d, 0.8d, 15.2d, 1.0d, 15.2d)).reduce((v1, v2) -> { return Shapes.join(v1, v2, BooleanOp.OR); }).get(); protected static final VoxelShape SHAPE_X_AXIS = (VoxelShape) Stream.of((Object[]) new VoxelShape[]{SHAPE_NORTH_WALL, SHAPE_SOUTH_WALL, SHAPE_FLOOR}).reduce((v1, v2) -> { return Shapes.join((VoxelShape) v1, (VoxelShape) v2, BooleanOp.OR); }).get(); protected static final VoxelShape SHAPE_Z_AXIS = (VoxelShape) Stream.of((Object[]) new VoxelShape[]{SHAPE_EAST_WALL, SHAPE_WEST_WALL, SHAPE_FLOOR}).reduce((v1, v2) -> { return Shapes.join((VoxelShape) v1, (VoxelShape) v2, BooleanOp.OR); }).get(); protected static final VoxelShape SHAPE_ONE_BORDER_N = (VoxelShape) Stream.of((Object[]) new VoxelShape[]{SHAPE_SOUTH_WALL, SHAPE_FLOOR}).reduce((v1, v2) -> { return Shapes.join((VoxelShape) v1, (VoxelShape) v2, BooleanOp.OR); }).get(); protected static final VoxelShape SHAPE_ONE_BORDER_E = (VoxelShape) Stream.of((Object[]) new VoxelShape[]{SHAPE_WEST_WALL, SHAPE_FLOOR}).reduce((v1, v2) -> { return Shapes.join((VoxelShape) v1, (VoxelShape) v2, BooleanOp.OR); }).get(); protected static final VoxelShape SHAPE_ONE_BORDER_W = (VoxelShape) Stream.of((Object[]) new VoxelShape[]{SHAPE_EAST_WALL, SHAPE_FLOOR}).reduce((v1, v2) -> { return Shapes.join((VoxelShape) v1, (VoxelShape) v2, BooleanOp.OR); }).get(); protected static final VoxelShape SHAPE_ONE_BORDER_S = (VoxelShape) Stream.of((Object[]) new VoxelShape[]{SHAPE_NORTH_WALL, SHAPE_FLOOR}).reduce((v1, v2) -> { return Shapes.join((VoxelShape) v1, (VoxelShape) v2, BooleanOp.OR); }).get(); protected static final VoxelShape SHAPE_NORTH_END = (VoxelShape) Stream.of((Object[]) new VoxelShape[]{SHAPE_NORTH_WALL, SHAPE_EAST_WALL, SHAPE_WEST_WALL, SHAPE_FLOOR}).reduce((v1, v2) -> { return Shapes.join((VoxelShape) v1, (VoxelShape) v2, BooleanOp.OR); }).get(); protected static final VoxelShape SHAPE_EAST_END = (VoxelShape) Stream.of((Object[]) new VoxelShape[]{SHAPE_EAST_WALL, SHAPE_NORTH_WALL, SHAPE_SOUTH_WALL, SHAPE_FLOOR}).reduce((v1, v2) -> { return Shapes.join((VoxelShape) v1, (VoxelShape) v2, BooleanOp.OR); }).get(); protected static final VoxelShape SHAPE_SOUTH_END = (VoxelShape) Stream.of((Object[]) new VoxelShape[]{SHAPE_SOUTH_WALL, SHAPE_EAST_WALL, SHAPE_WEST_WALL, SHAPE_FLOOR}).reduce((v1, v2) -> { return Shapes.join((VoxelShape) v1, (VoxelShape) v2, BooleanOp.OR); }).get(); protected static final VoxelShape SHAPE_WEST_END = (VoxelShape) Stream.of((Object[]) new VoxelShape[]{SHAPE_WEST_WALL, SHAPE_NORTH_WALL, SHAPE_SOUTH_WALL, SHAPE_FLOOR}).reduce((v1, v2) -> { return Shapes.join((VoxelShape) v1, (VoxelShape) v2, BooleanOp.OR); }).get(); protected static final VoxelShape SHAPE_NE_CORNER = (VoxelShape) Stream.of((Object[]) new VoxelShape[]{SHAPE_NORTH_WALL, SHAPE_EAST_WALL, SHAPE_FLOOR}).reduce((v1, v2) -> { return Shapes.join((VoxelShape) v1, (VoxelShape) v2, BooleanOp.OR); }).get(); protected static final VoxelShape SHAPE_NW_CORNER = (VoxelShape) Stream.of((Object[]) new VoxelShape[]{SHAPE_NORTH_WALL, SHAPE_WEST_WALL, SHAPE_FLOOR}).reduce((v1, v2) -> { return Shapes.join((VoxelShape) v1, (VoxelShape) v2, BooleanOp.OR); }).get(); protected static final VoxelShape SHAPE_SE_CORNER = (VoxelShape) Stream.of((Object[]) new VoxelShape[]{SHAPE_SOUTH_WALL, SHAPE_EAST_WALL, SHAPE_FLOOR}).reduce((v1, v2) -> { return Shapes.join((VoxelShape) v1, (VoxelShape) v2, BooleanOp.OR); }).get(); protected static final VoxelShape SHAPE_SW_CORNER = (VoxelShape) Stream.of((Object[]) new VoxelShape[]{SHAPE_SOUTH_WALL, SHAPE_WEST_WALL, SHAPE_FLOOR}).reduce((v1, v2) -> { return Shapes.join((VoxelShape) v1, (VoxelShape) v2, BooleanOp.OR); }).get(); protected static final VoxelShape SHAPE_BOX = (VoxelShape) Stream.of((Object[]) new VoxelShape[]{SHAPE_WEST_WALL, SHAPE_EAST_WALL, SHAPE_NORTH_WALL, SHAPE_SOUTH_WALL, SHAPE_FLOOR}).reduce((v1, v2) -> { return Shapes.join((VoxelShape) v1, (VoxelShape) v2, BooleanOp.OR); }).get(); public static final EnumProperty TYPE = EnumProperty.create("type", CatwalkType.class); public static final BooleanProperty NE_POST = BooleanProperty.create("ne_post"); public static final BooleanProperty SE_POST = BooleanProperty.create("se_post"); public static final BooleanProperty SW_POST = BooleanProperty.create("sw_post"); public static final BooleanProperty NW_POST = BooleanProperty.create("nw_post"); public static final BooleanProperty ALTERED = BooleanProperty.create("altered"); /* loaded from: outputsrg.jar:com/dairymoose/modernlife/blocks/CatwalkBlock$CatwalkType.class */ public enum CatwalkType implements StringRepresentable { single, mid, 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; public String getSerializedName() { return name().toLowerCase(); } } public VoxelShape getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel) { switch ((CatwalkType) bs.getValue(TYPE)) { case single: return SHAPE_BOX; case mid: return SHAPE_FLOOR; case one_border_n: return SHAPE_ONE_BORDER_N; case one_border_e: return SHAPE_ONE_BORDER_E; case one_border_s: return SHAPE_ONE_BORDER_S; case one_border_w: return SHAPE_ONE_BORDER_W; case x_axis: return SHAPE_X_AXIS; case z_axis: return SHAPE_Z_AXIS; case s_end: return SHAPE_SOUTH_END; case w_end: return SHAPE_WEST_END; case n_end: return SHAPE_NORTH_END; case e_end: return SHAPE_EAST_END; case ne_corner: return SHAPE_NE_CORNER; case nw_corner: return SHAPE_NW_CORNER; case se_corner: return SHAPE_SE_CORNER; case sw_corner: return SHAPE_SW_CORNER; default: return SHAPE_BOX; } } public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult p_225533_6_) { if (player.isSteppingCarefully() && hand == InteractionHand.MAIN_HAND && player.getItemInHand(hand).isEmpty()) { if (!level.isClientSide) { CatwalkType initialType = (CatwalkType) state.getValue(TYPE); Direction dir = player.getDirection(); CatwalkType newType = null; if (initialType == CatwalkType.w_end && dir == Direction.NORTH) { newType = CatwalkType.nw_corner; } else if (initialType == CatwalkType.w_end && dir == Direction.SOUTH) { newType = CatwalkType.sw_corner; } else if (initialType == CatwalkType.w_end) { newType = CatwalkType.x_axis; } else if (initialType == CatwalkType.e_end && dir == Direction.NORTH) { newType = CatwalkType.ne_corner; } else if (initialType == CatwalkType.e_end && dir == Direction.SOUTH) { newType = CatwalkType.se_corner; } else if (initialType == CatwalkType.e_end) { newType = CatwalkType.x_axis; } else if (initialType == CatwalkType.s_end && dir == Direction.EAST) { newType = CatwalkType.se_corner; } else if (initialType == CatwalkType.s_end && dir == Direction.WEST) { newType = CatwalkType.sw_corner; } else if (initialType == CatwalkType.s_end) { newType = CatwalkType.z_axis; } else if (initialType == CatwalkType.n_end && dir == Direction.EAST) { newType = CatwalkType.ne_corner; } else if (initialType == CatwalkType.n_end && dir == Direction.WEST) { newType = CatwalkType.nw_corner; } else if (initialType == CatwalkType.n_end) { newType = CatwalkType.z_axis; } else if (initialType == CatwalkType.x_axis && dir == Direction.NORTH) { newType = CatwalkType.one_border_s; } else if (initialType == CatwalkType.x_axis && dir == Direction.SOUTH) { newType = CatwalkType.one_border_n; } else if (initialType == CatwalkType.z_axis && dir == Direction.WEST) { newType = CatwalkType.one_border_e; } else if (initialType == CatwalkType.z_axis && dir == Direction.EAST) { newType = CatwalkType.one_border_w; } else if (initialType == CatwalkType.one_border_e || initialType == CatwalkType.one_border_w || initialType == CatwalkType.one_border_n || initialType == CatwalkType.one_border_s) { newType = CatwalkType.mid; } else if (initialType == CatwalkType.ne_corner && dir == Direction.WEST) { newType = CatwalkType.one_border_s; } else if (initialType == CatwalkType.ne_corner && dir == Direction.SOUTH) { newType = CatwalkType.one_border_w; } else if (initialType == CatwalkType.nw_corner && dir == Direction.EAST) { newType = CatwalkType.one_border_s; } else if (initialType == CatwalkType.nw_corner && dir == Direction.SOUTH) { newType = CatwalkType.one_border_e; } else if (initialType == CatwalkType.se_corner && dir == Direction.WEST) { newType = CatwalkType.one_border_n; } else if (initialType == CatwalkType.se_corner && dir == Direction.NORTH) { newType = CatwalkType.one_border_w; } else if (initialType == CatwalkType.sw_corner && dir == Direction.EAST) { newType = CatwalkType.one_border_n; } else if (initialType == CatwalkType.sw_corner && dir == Direction.NORTH) { newType = CatwalkType.one_border_e; } if (newType != initialType && newType != null) { level.setBlock(pos, (BlockState) ((BlockState) state.setValue(ALTERED, true)).setValue(TYPE, newType), 2); } } return InteractionResult.CONSUME; } return InteractionResult.PASS; } @Nullable public BlockState getStateForPlacement(BlockPlaceContext context) { return getNewState(context.getLevel(), context.getClickedPos()); } public BlockState updateShape(BlockState state, Direction dir, BlockState updater, LevelAccessor world, BlockPos pos, BlockPos updaterPos) { if (((Boolean) state.getValue(ALTERED)).booleanValue()) { return state; } return getNewState(world, pos); } protected BlockState applyCatwalkPosts(BlockState state, boolean useNePost, boolean useNwPost, boolean useSePost, boolean useSwPost) { return (BlockState) ((BlockState) ((BlockState) ((BlockState) state.setValue(NE_POST, Boolean.valueOf(useNePost))).setValue(NW_POST, Boolean.valueOf(useNwPost))).setValue(SE_POST, Boolean.valueOf(useSePost))).setValue(SW_POST, Boolean.valueOf(useSwPost)); } 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); boolean useNePost = false; boolean useNwPost = false; boolean useSePost = false; boolean useSwPost = false; if (nTable && eTable && !neTable) { useNePost = true; } if (nTable && wTable && !nwTable) { useNwPost = true; } if (sTable && eTable && !seTable) { useSePost = true; } if (sTable && wTable && !swTable) { useSwPost = true; } 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, CatwalkType.sw_corner); } return (BlockState) ((BlockState) defaultBlockState().setValue(TYPE, CatwalkType.sw_corner)).setValue(NE_POST, true); } if (nTable && wTable && !sTable && !eTable) { if (nwTable) { return (BlockState) defaultBlockState().setValue(TYPE, CatwalkType.se_corner); } return (BlockState) ((BlockState) defaultBlockState().setValue(TYPE, CatwalkType.se_corner)).setValue(NW_POST, true); } if (sTable && eTable && !nTable && !wTable) { if (seTable) { return (BlockState) defaultBlockState().setValue(TYPE, CatwalkType.nw_corner); } return (BlockState) ((BlockState) defaultBlockState().setValue(TYPE, CatwalkType.nw_corner)).setValue(SE_POST, true); } if (sTable && wTable && !nTable && !eTable) { if (swTable) { return (BlockState) defaultBlockState().setValue(TYPE, CatwalkType.ne_corner); } return (BlockState) ((BlockState) defaultBlockState().setValue(TYPE, CatwalkType.ne_corner)).setValue(SW_POST, true); } if (adjacentTableCount == 2 && wTable && eTable) { return (BlockState) defaultBlockState().setValue(TYPE, CatwalkType.x_axis); } if (adjacentTableCount == 2 && nTable && sTable) { return (BlockState) defaultBlockState().setValue(TYPE, CatwalkType.z_axis); } if (adjacentTableCount == 3) { if (wTable && nTable && eTable) { return applyCatwalkPosts((BlockState) defaultBlockState().setValue(TYPE, CatwalkType.one_border_n), useNePost, useNwPost, useSePost, useSwPost); } if (nTable && eTable && sTable) { return applyCatwalkPosts((BlockState) defaultBlockState().setValue(TYPE, CatwalkType.one_border_e), useNePost, useNwPost, useSePost, useSwPost); } if (eTable && sTable && wTable) { return applyCatwalkPosts((BlockState) defaultBlockState().setValue(TYPE, CatwalkType.one_border_s), useNePost, useNwPost, useSePost, useSwPost); } if (sTable && wTable && nTable) { return applyCatwalkPosts((BlockState) defaultBlockState().setValue(TYPE, CatwalkType.one_border_w), useNePost, useNwPost, useSePost, useSwPost); } } if (adjacentTableCount == 4 && !seTable && !swTable && !neTable && !nwTable) { return applyCatwalkPosts((BlockState) defaultBlockState().setValue(TYPE, CatwalkType.mid), useNePost, useNwPost, useSePost, useSwPost); } return applyCatwalkPosts((BlockState) defaultBlockState().setValue(TYPE, CatwalkType.mid), useNePost, useNwPost, useSePost, useSwPost); } if (adjacentTableCount == 1) { if (nTable) { return (BlockState) defaultBlockState().setValue(TYPE, CatwalkType.s_end); } if (eTable) { return (BlockState) defaultBlockState().setValue(TYPE, CatwalkType.w_end); } if (sTable) { return (BlockState) defaultBlockState().setValue(TYPE, CatwalkType.n_end); } if (wTable) { return (BlockState) defaultBlockState().setValue(TYPE, CatwalkType.e_end); } } return applyCatwalkPosts(defaultBlockState(), useNePost, useNwPost, useSePost, useSwPost); } protected void createBlockStateDefinition(StateDefinition.Builder builder) { builder.add(new Property[]{TYPE, NE_POST, NW_POST, SE_POST, SW_POST, ALTERED}); } public CatwalkBlock(Properties p_i48377_1_) { super(p_i48377_1_); registerDefaultState((BlockState) ((BlockState) ((BlockState) ((BlockState) ((BlockState) ((BlockState) defaultBlockState().setValue(TYPE, CatwalkType.single)).setValue(NE_POST, false)).setValue(NW_POST, false)).setValue(SE_POST, false)).setValue(SW_POST, false)).setValue(ALTERED, false)); } }