content: package com.github.alexthe666.rats.server.block;
  
  import com.github.alexthe666.rats.registry.RatsBlockEntityRegistry;
  import com.github.alexthe666.rats.server.block.entity.RatQuarryBlockEntity;
  import net.minecraft.ChatFormatting;
  import net.minecraft.core.BlockPos;
  import net.minecraft.network.chat.Component;
  import net.minecraft.world.Containers;
  import net.minecraft.world.InteractionHand;
  import net.minecraft.world.InteractionResult;
  import net.minecraft.world.entity.player.Player;
  import net.minecraft.world.item.ItemStack;
  import net.minecraft.world.item.TooltipFlag;
  import net.minecraft.world.level.BlockGetter;
  import net.minecraft.world.level.Level;
  import net.minecraft.world.level.block.BaseEntityBlock;
  import net.minecraft.world.level.block.RenderShape;
  import net.minecraft.world.level.block.entity.BlockEntity;
  import net.minecraft.world.level.block.entity.BlockEntityTicker;
  import net.minecraft.world.level.block.entity.BlockEntityType;
  import net.minecraft.world.level.block.state.BlockBehaviour;
  import net.minecraft.world.level.block.state.BlockState;
  import net.minecraft.world.phys.BlockHitResult;
  import org.jetbrains.annotations.Nullable;
  
  import java.util.List;
  
  @SuppressWarnings("deprecation")
  public class RatQuarryBlock extends BaseEntityBlock {
  
  	public RatQuarryBlock(BlockBehaviour.Properties properties) {
  		super(properties);
  	}
  
  	@Override
  	public void onRemove(BlockState state, Level level, BlockPos pos, BlockState newState, boolean isMoving) {
  		BlockEntity tileentity = level.getBlockEntity(pos);
  		if (tileentity instanceof RatQuarryBlockEntity quarry) {
  			Containers.dropContents(level, pos, quarry);
  			level.updateNeighbourForOutputSignal(pos, this);
  		}
  		super.onRemove(state, level, pos, newState, isMoving);
  	}
  
  	@Override
  	public RenderShape getRenderShape(BlockState state) {
  		return RenderShape.MODEL;
  	}
  
  	@Nullable
  	@Override
  	public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
  		return new RatQuarryBlockEntity(pos, state);
  	}
  
  	@Nullable
  	@Override
  	public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> type) {
  		return createTickerHelper(type, RatsBlockEntityRegistry.RAT_QUARRY.get(), RatQuarryBlockEntity::tick);
  	}
  
  	@Override
  	public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
  		if (!player.isCrouching()) {
  			if (level.isClientSide()) {
  				return InteractionResult.SUCCESS;
  			} else {
  				player.openMenu(state.getMenuProvider(level, pos));
  				return InteractionResult.CONSUME;
  			}
  
  		}
  		return InteractionResult.FAIL;
  	}
  
  	@Override
  	public void appendHoverText(ItemStack stack, @Nullable BlockGetter level, List<Component> tooltip, TooltipFlag flagIn) {
  		tooltip.add(Component.translatable("block.rats.rat_quarry.desc0").withStyle(ChatFormatting.GRAY));
  		tooltip.add(Component.translatable("block.rats.rat_quarry.desc1").withStyle(ChatFormatting.GRAY));
  	}
  }
  