These is a way to check all the tiles within a given range of the player. Find the players tile position, (player.position / 16) then subtract half the distance you want to check within, then use nested for loops to search through each tile, checking to see if it's your tile. If the range your checking is small, say within 3 tiles of the player that'd be about 72 tiles to check each time. (3 left of player 2 on player 3 right of player for a width of 8, 3 above player 3 on player 3 below player for a height of 9) Which may seem like a lot, but probably wouldn't create any noticeable frame loss. If you did that for within a distance of 20 tiles, that'd be 1806 tiles to check, which could start to become problematic.
If the tile should have an effect as soon as it's onscreen, like the Heart Lantern, that's actually extremely easy to do. Every game update the game counts every tile while applying lighting effects and stores the number in an array. This array is used to determine which zone you're in and also whether the Camp Fire and Heart Lantern buffs should be applied or not. Stone has a Tile ID of 1. If I wanted to know how many Stone tiles were onscreen I could use - WorldGen.tileCount[1]
To know how many of your custom tiles are onscreen use - WorldGen.tileCount[TileDef.byName["InternalName:TileName"]]
To sum up, try this...
Code:
using System;
using TAPI;
using Terraria;
namespace InternalName {
public class MPlayer : ModPlayer {
public override void MidUpdate() {
if (WorldGen.tileCount[TileDef.byName["InternalName:TileName"]] > 0)
player.AddBuff("InternalName:BuffName", 1800); // The number is the duration of the buff in ticks. ~60 ticks per second
}
}
}