public static bool CheckSpawn(int x, int y)
{
if (x < 10 || x > Main.maxTilesX - 10 || (y < 10 || y > Main.maxTilesX - 10) || (Main.tile[x, y - 1] == null || !Main.tile[x, y - 1].active() || (int)Main.tile[x, y - 1].type != 79))
return false;
for (int index1 = x - 1; index1 <= x + 1; ++index1)
{
for (int index2 = y - 3; index2 < y; ++index2)
{
if (Main.tile[index1, index2] == null)
return false;
if (Main.tile[index1, index2].nactive() && Main.tileSolid[(int)Main.tile[index1, index2].type] && !Main.tileSolidTop[(int)Main.tile[index1, index2].type])
{
Main.NewText("Your bed is obstructed.", byte.MaxValue, (byte)240, (byte)20, false);
return false;
}
}
}
return WorldGen.StartRoomCheck(x, y - 1);
}