content: package com.github.alexthe666.rats.server.block;
  
  import com.github.alexthe666.rats.registry.RatsBlockEntityRegistry;
  import com.github.alexthe666.rats.server.block.entity.RatAttractorBlockEntity;
  import net.minecraft.ChatFormatting;
  import net.minecraft.core.BlockPos;
  import net.minecraft.network.chat.Component;
  import net.minecraft.server.level.ServerLevel;
  import net.minecraft.util.RandomSource;
  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.Block;
  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.level.block.state.StateDefinition;
  import net.minecraft.world.level.block.state.properties.BlockStateProperties;
  import net.minecraft.world.level.block.state.properties.BooleanProperty;
  import net.minecraft.world.level.pathfinder.PathComputationType;
  import net.minecraft.world.phys.shapes.CollisionContext;
  import net.minecraft.world.phys.shapes.VoxelShape;
  import org.jetbrains.annotations.Nullable;
  
  import java.util.List;
  
  @SuppressWarnings("deprecation")
  public class RatAttractorBlock extends BaseEntityBlock {
  	public static final BooleanProperty POWERED = BlockStateProperties.POWERED;
  	public static final BooleanProperty CONNECTED_UP = BooleanProperty.create("up");
  	private static final VoxelShape AABB = Block.box(4, 0, 4, 12, 8, 12);
  
  	public RatAttractorBlock(BlockBehaviour.Properties properties) {
  		super(properties);
  		this.registerDefaultState(this.getStateDefinition().any().setValue(POWERED, false).setValue(CONNECTED_UP, false));
  	}
  
  	@Override
  	public void neighborChanged(BlockState state, Level level, BlockPos pos, Block block, BlockPos fromPos, boolean isMoving) {
  		if (!level.isClientSide()) {
  			this.updateState(state, level, pos);
  		}
  	}
  
  	@Override
  	public VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) {
  		return AABB;
  	}
  
  	@Override
  	public void appendHoverText(ItemStack stack, @Nullable BlockGetter level, List<Component> tooltip, TooltipFlag flag) {
  		tooltip.add(Component.translatable("block.rats.rat_attractor.desc").withStyle(ChatFormatting.GRAY));
  	}
  
  	@Override
  	public RenderShape getRenderShape(BlockState state) {
  		return RenderShape.MODEL;
  	}
  
  	@Override
  	public void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) {
  		if (!level.isClientSide()) {
  			this.updateState(state, level, pos);
  		}
  	}
  
  	public void updateState(BlockState state, Level level, BlockPos pos) {
  		boolean flag = state.getValue(POWERED);
  		boolean flag1 = level.hasNeighborSignal(pos);
  
  		boolean flag2 = state.getValue(CONNECTED_UP);
  		boolean flag3 = !level.getBlockState(pos.above()).isAir();
  
  		if (flag1 != flag) {
  			level.setBlock(pos, state.setValue(POWERED, flag1).setValue(CONNECTED_UP, flag3), 3);
  			level.updateNeighbourForOutputSignal(pos.below(), this);
  		}
  		if (flag2 != flag3) {
  			level.setBlock(pos, state.setValue(CONNECTED_UP, flag3), 3);
  		}
  
  	}
  
  	@Override
  	protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
  		builder.add(POWERED, CONNECTED_UP);
  	}
  
  	@Nullable
  	@Override
  	public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
  		return new RatAttractorBlockEntity(pos, state);
  	}
  
  	@Nullable
  	@Override
  	public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> type) {
  		return createTickerHelper(type, RatsBlockEntityRegistry.RAT_ATTRACTOR.get(), RatAttractorBlockEntity::tick);
  	}
  
  	@Override
  	public boolean isPathfindable(BlockState state, BlockGetter getter, BlockPos pos, PathComputationType type) {
  		return false;
  	}
  }
  