package com.dairymoose.modernlife.blocks; import com.dairymoose.modernlife.tileentities.NightStandBlockEntity; import com.dairymoose.modernlife.util.ModernLifeUtil; import java.util.List; import java.util.stream.Stream; import javax.annotation.Nullable; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.TextComponent; import net.minecraft.world.Containers; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.MenuProvider; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.ChestMenu; import net.minecraft.world.inventory.MenuType; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.EntityBlock; import net.minecraft.world.level.block.Mirror; import net.minecraft.world.level.block.Rotation; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.entity.BlockEntity; 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.DirectionProperty; import net.minecraft.world.level.block.state.properties.Property; import net.minecraft.world.level.material.Material; 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; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; /* loaded from: outputsrg.jar:com/dairymoose/modernlife/blocks/NightStandBlock.class */ public class NightStandBlock extends Block implements EntityBlock { protected String containerDisplayLabel; protected static final VoxelShape SHAPE_SOUTH = (VoxelShape) Stream.of((Object[]) new VoxelShape[]{Block.box(0.0d, 2.0d, 0.0d, 16.0d, 16.0d, 14.0d), Block.box(5.0d, 11.6d, 15.0d, 11.0d, 12.6d, 16.0d), Block.box(15.0d, 0.0d, 0.0d, 16.0d, 2.0d, 1.0d), Block.box(0.0d, 0.0d, 13.0d, 1.0d, 2.0d, 14.0d), Block.box(0.0d, 0.0d, 0.0d, 1.0d, 2.0d, 1.0d), Block.box(15.0d, 0.0d, 13.0d, 16.0d, 2.0d, 14.0d), Block.box(5.0d, 5.475d, 14.0d, 6.0d, 6.475d, 15.0d), Block.box(5.0d, 5.475d, 15.0d, 11.0d, 6.475d, 16.0d), Block.box(10.0d, 5.475d, 14.0d, 11.0d, 6.475d, 15.0d), Block.box(5.0d, 11.6d, 14.0d, 6.0d, 12.6d, 15.0d), Block.box(10.0d, 11.6d, 14.0d, 11.0d, 12.6d, 15.0d)}).reduce((v1, v2) -> { return Shapes.join((VoxelShape) v1, (VoxelShape) v2, BooleanOp.OR); }).get(); protected static final VoxelShape SHAPE_WEST = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_SOUTH); protected static final VoxelShape SHAPE_NORTH = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_WEST); protected static final VoxelShape SHAPE_EAST = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_NORTH); public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING; @OnlyIn(Dist.CLIENT) public void appendHoverText(ItemStack itemStack, @Nullable BlockGetter blockReader, List list, TooltipFlag tooltipFlag) { list.add(new TextComponent("Stores up to 18 items")); } public NightStandBlock() { super(Properties.of(Material.WOOD).sound(SoundType.WOOD).strength(1.5f)); this.containerDisplayLabel = "Night Stand"; registerDefaultState((BlockState) this.stateDefinition.any().setValue(FACING, Direction.SOUTH)); } 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 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 NightStandBlock(Properties props) { super(props); this.containerDisplayLabel = "Night Stand"; registerDefaultState((BlockState) this.stateDefinition.any().setValue(FACING, Direction.SOUTH)); } public void onRemove(BlockState p_196243_1_, Level p_196243_2_, BlockPos p_196243_3_, BlockState p_196243_4_, boolean p_196243_5_) { if (!p_196243_1_.is(p_196243_4_.getBlock())) { BlockEntity lvt_6_1_ = p_196243_2_.getBlockEntity(p_196243_3_); if (lvt_6_1_ instanceof NightStandBlockEntity) { Containers.dropContents(p_196243_2_, p_196243_3_, (NightStandBlockEntity) lvt_6_1_); p_196243_2_.updateNeighbourForOutputSignal(p_196243_3_, this); } super.onRemove(p_196243_1_, p_196243_2_, p_196243_3_, p_196243_4_, p_196243_5_); } } public MenuProvider getMenuProvider(BlockState p_220052_1_, final Level p_220052_2_, final BlockPos p_220052_3_) { return new MenuProvider() { // from class: com.dairymoose.modernlife.blocks.NightStandBlock.1 /* renamed from: createMenu */ public AbstractContainerMenu createMenu(int paramInt, Inventory paramInventory, Player paramPlayer) { BlockEntity tileEntity = p_220052_2_.getBlockEntity(p_220052_3_); if (tileEntity instanceof NightStandBlockEntity) { NightStandBlockEntity nightStandBlockEntity = (NightStandBlockEntity) tileEntity; return new ChestMenu(MenuType.GENERIC_9x2, paramInt, paramInventory, nightStandBlockEntity, 2); } return null; } public Component getDisplayName() { return new TextComponent(NightStandBlock.this.containerDisplayLabel); } }; } public BlockEntity newBlockEntity(BlockPos pos, BlockState state) { NightStandBlockEntity toReturn = (NightStandBlockEntity) NightStandBlockEntity.NIGHT_STAND.create(pos, state); return toReturn; } public InteractionResult use(BlockState p_225533_1_, Level p_225533_2_, BlockPos p_225533_3_, Player p_225533_4_, InteractionHand p_225533_5_, BlockHitResult p_225533_6_) { MenuProvider lvt_7_1_ = getMenuProvider(p_225533_1_, p_225533_2_, p_225533_3_); if (lvt_7_1_ != null) { p_225533_4_.openMenu(lvt_7_1_); } return InteractionResult.CONSUME; } protected void createBlockStateDefinition(StateDefinition.Builder builder) { builder.add(new Property[]{FACING}); } /* renamed from: com.dairymoose.modernlife.blocks.NightStandBlock$2 */ /* loaded from: outputsrg.jar:com/dairymoose/modernlife/blocks/NightStandBlock$2.class */ static /* synthetic */ class C00412 { static final /* synthetic */ int[] $SwitchMap$net$minecraft$core$Direction = new int[Direction.values().length]; static { try { $SwitchMap$net$minecraft$core$Direction[Direction.NORTH.ordinal()] = 1; } catch (NoSuchFieldError e) { } try { $SwitchMap$net$minecraft$core$Direction[Direction.SOUTH.ordinal()] = 2; } catch (NoSuchFieldError e2) { } try { $SwitchMap$net$minecraft$core$Direction[Direction.EAST.ordinal()] = 3; } catch (NoSuchFieldError e3) { } try { $SwitchMap$net$minecraft$core$Direction[Direction.WEST.ordinal()] = 4; } catch (NoSuchFieldError e4) { } } } public VoxelShape getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel) { switch (C00412.$SwitchMap$net$minecraft$core$Direction[bs.getValue(FACING).ordinal()]) { case 1: return SHAPE_NORTH; case 2: return SHAPE_SOUTH; case 3: return SHAPE_EAST; case 4: return SHAPE_WEST; default: return SHAPE_NORTH; } } public BlockState getStateForPlacement(BlockPlaceContext context) { context.getLevel().getFluidState(context.getClickedPos()); return (BlockState) defaultBlockState().setValue(FACING, context.getHorizontalDirection().getOpposite()); } }